def on_discover_participant(match, state):
    """It happens for discovered participants."""
    local_address = parse_guid(state, match[0], match[1])
    full_addr = parse_guid(state, match[0], match[1], match[2])
    full_addr = " ".join(full_addr.split())
    log_process(local_address, "",
                "Discovered new participant (%s)" % full_addr, state)
def on_update_remote_participant(match, state):
    """It happens when updating remote participant."""
    local_address = parse_guid(state, match[0], match[1])
    full_addr = parse_guid(state, match[0], match[1], match[2])
    full_addr = " ".join(full_addr.split())
    part_oid = get_oid(match[3])
    log_process(
        local_address, "",
        "Discovered/Updated participant (%s - %s)" % (full_addr, part_oid),
        state, 1)
def on_send_gap(match, state):
    """It happens when the writer send a GAP message."""
    writer_oid = get_oid(match[0])
    remote_part = parse_guid(state, match[1], match[2], match[3])
    reader_oid = get_oid(match[4])
    sn_start = parse_sn(match[5])
    sn_end = parse_sn(match[6])
    verb = 1 if is_builtin_entity(match[0]) else 0
    log_send(
        remote_part, writer_oid,
        "Sent GAP to reader %s for [%d, %d)" % (reader_oid, sn_start, sn_end),
        state, verb)
    add_statistics_packet(writer_oid, 'send', 'GAP', state)

    # Check for large sequence number issues.
    if sn_end - sn_start >= (1 << 31):
        log_warning("[LP-1] Large Sequence Number difference in GAP.", state)

    # Check for reliable packet lost
    if 'packets_lost' not in state:
        return
    losts = []
    for k in state['packets_lost']:
        info = k.split("-")
        oid = info[0]
        seqnum = int(info[1])
        if oid == writer_oid and seqnum >= sn_start and seqnum < sn_end:
            log_warning("DATA (%d) may have been lost" % seqnum, state)
            losts.append(k)
    for k in losts:
        state['packets_lost'].remove(k)
def on_receive_data(match, state):
    """It happens when the reader receives data."""
    comm = "best-effort" if match[0] == "Be" else "reliable"
    reader_oid = get_oid(match[1])
    packet = match[2]
    seqnum = parse_sn(match[3], 16 if match[0] == "Be" else 10)
    remote = match[5].split('.')
    writer_addr = parse_guid(state, remote[0], remote[1], remote[2])
    writer_oid = get_oid(remote[3])

    # Sequece number check
    full_id = writer_addr + "." + writer_oid + ' to ' + reader_oid
    if 'last_sn' not in state:
        state['last_sn'] = {}
    if full_id in state['last_sn']:
        prev_seqnum = state['last_sn'][full_id]
        diff = seqnum - prev_seqnum
        # Add a warning message per missing packet to have a good count in
        # the warning summary.
        for _ in range(diff - 1):
            log_warning("Missing packet for %s" % full_id, state)
    state['last_sn'][full_id] = seqnum

    # Show the message after any possible warning.
    verb = 1 if is_builtin_entity(remote[3]) else 0
    log_recv(
        writer_addr, reader_oid, "Received %s (%d) from writer %s (%s)" %
        (packet, seqnum, writer_oid, comm), state, verb)
 def on_unregister_given_not_asserted_entity(match, state):
     """Internal function for the specific entity."""
     remote_part = parse_guid(state, match[0], match[1], match[2])
     remote_oid = get_oid(match[3])
     log_warning(
         "%s %s is unregistering remote %s not previsouly asserted" %
         (remote_part, remote_oid, entity), state, 2)
def on_send_preemptive_gap(match, state):
    """It happens when sending a preemptive GAP message."""
    writer_oid = get_oid(match[0])
    reader_addr = parse_guid(state, match[1], match[2], match[3])
    reader_oid = get_oid(match[4])
    verb = 1 if is_builtin_entity(match[0]) else 0
    log_send(reader_addr, writer_oid,
             "Sent preemptive GAP to volatile reader %s" % (reader_oid), state,
             verb)
def on_resend_data(match, state):
    """It happens when the writer resend a DATA message."""
    writer_oid = get_oid(match[0])
    remote_part = parse_guid(state, match[1], match[2], match[3])
    remote_oid = get_oid(match[4])
    seqnum = parse_sn(match[5])
    verb = 1 if is_builtin_entity(match[0]) else 0
    log_send(remote_part, writer_oid,
             "Resend DATA (%d) to reader %s" % (seqnum, remote_oid), state,
             verb)
def on_receive_ack(match, state):
    """It happens when receiving an ACK message."""
    writer_oid = get_oid(match[0])
    remote = match[1].split('.')
    reader_addr = parse_guid(state, remote[0], remote[1], remote[2])
    reader_oid = get_oid(remote[3])
    seqnum = parse_sn(match[2])
    verb = 1 if is_builtin_entity(match[0]) else 0
    log_recv(reader_addr, writer_oid,
             "Received ACKNACK from reader %s for %d" % (reader_oid, seqnum),
             state, verb)
 def match_entity(match, state):
     """It happens when a specific entity is matched."""
     entity2_addr = parse_guid(state, match[0], match[1], match[2])
     entity2_oid = get_oid(match[3])
     entity1_oid = get_oid(match[4])
     verb = 1 if is_builtin_entity(match[4]) else 0
     reliable = match[5]  # Best-Effort or Reliable
     log_process(
         entity2_addr, entity1_oid,
         "Discovered %s %s %s %s" % (kind, reliable, entity2, entity2_oid),
         state, verb)
def on_send_nack(match, state):
    """It happens when a NACK message is sent."""
    reader_oid = get_oid(match[0])
    lead = parse_sn(match[1])
    bitcount = int(match[2])
    remote = match[4].split('.')
    writer_addr = parse_guid(state, remote[0], remote[1], remote[2])
    writer_oid = get_oid(remote[3])
    verb = 1 if is_builtin_entity(remote[3]) else 0
    log_send(
        writer_addr, reader_oid, "Sent NACK to writer %s for %d count %d" %
        (writer_oid, lead, bitcount), state, verb)
def on_receive_hb(match, state):
    """It happens when the write receives a HB."""
    reader_oid = get_oid(match[0])
    sn_start = parse_sn(match[1])
    sn_end = parse_sn(match[2])
    remote = match[4].split('.')
    writer_addr = parse_guid(state, remote[0], remote[1], remote[2])
    writer_oid = get_oid(remote[3])
    verb = 1 if is_builtin_entity(remote[3]) else 0
    log_recv(
        writer_addr, reader_oid, "Received HB from writer %s for [%d, %d]" %
        (writer_oid, sn_start, sn_end), state, verb)
def on_receive_out_order_data(match, state):
    """It happens when the received data sequence number isn't contiguous."""
    reader_oid = get_oid(match[0])
    kind = "old" if match[1] == "old" else "future"
    seqnum = parse_sn(match[2])
    remote = match[3].split('.')
    writer_addr = parse_guid(state, remote[0], remote[1], remote[2])
    writer_oid = get_oid(remote[3])
    verb = 1 if is_builtin_entity(remote[3]) else 0
    log_recv(
        writer_addr, reader_oid,
        "Received %s DATA (%d) from writer %s" % (kind, seqnum, writer_oid),
        state, verb)
def on_parse_packet(match, state):
    """It happens when an RTPS message is parsed."""
    addr = parse_guid(state, match[1], match[2])
    log_recv(addr, "", "Received %s packet" % match[0], state, 2)
    add_statistics_packet(addr, 'receive', match[0], state)
示例#14
0
def on_discover_publication(match, state):
    """It happens for discovered writers."""
    remote_addr = parse_guid(state, match[0], match[1], match[2])
    pub_oid = get_oid(match[3])
    log_process(remote_addr, "", "Discovered new publication %s" % pub_oid,
                state)
示例#15
0
def on_update_endpoint(match, state):
    """It happens when updating an endpoint."""
    remote_addr = parse_guid(state, match[0], match[1], match[2])
    pub_oid = get_oid(match[3])
    log_process(remote_addr, "", "Discovered/Updated publication %s" % pub_oid,
                state, 1)
示例#16
0
def on_announce_local_publication(match, state):
    """It happens when announcing a writer."""
    local_addr = parse_guid(state, match[0], match[1], match[2])
    pub_oid = get_oid(match[3])
    log_process(local_addr, "", "Announcing new writer %s" % pub_oid, state)
示例#17
0
def on_announce_local_subscription(match, state):
    """It happens when announcing a reader."""
    local_addr = parse_guid(state, match[0], match[1], match[2])
    sub_oid = get_oid(match[3])
    log_process(local_addr, "", "Announcing new reader %s" % sub_oid, state)