mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 09:26:37 +00:00
Record packet timing info
This commit is contained in:
parent
3dfd64f4da
commit
383cc2371d
@ -70,6 +70,9 @@ struct subscriber{
|
||||
|
||||
// if reachable&REACHABLE_UNICAST send packets to this address, else use the interface broadcast address
|
||||
struct sockaddr_in address;
|
||||
time_ms_t last_probe;
|
||||
time_ms_t last_rx;
|
||||
time_ms_t last_tx;
|
||||
|
||||
// public signing key details for remote peers
|
||||
unsigned char sas_public[SAS_SIZE];
|
||||
|
@ -305,7 +305,7 @@ overlay_mdp_service_probe(overlay_mdp_frame *mdp)
|
||||
if (probe->addr.sin_family!=AF_INET)
|
||||
RETURN(WHY("Unsupported address family"));
|
||||
|
||||
if (peer->reachable == REACHABLE_NONE || peer->reachable == REACHABLE_INDIRECT){
|
||||
if (peer->reachable == REACHABLE_NONE || peer->reachable == REACHABLE_INDIRECT || (peer->reachable & REACHABLE_ASSUMED)){
|
||||
reachable_unicast(peer, &overlay_interfaces[probe->interface], probe->addr.sin_addr, probe->addr.sin_port);
|
||||
}
|
||||
RETURN(0);
|
||||
@ -318,6 +318,11 @@ int overlay_send_probe(struct subscriber *peer, struct sockaddr_in addr, overlay
|
||||
if (!interface)
|
||||
return WHY("I don't know which interface to use");
|
||||
|
||||
time_ms_t now = gettime_ms();
|
||||
|
||||
if (peer && peer->last_probe+1000>now)
|
||||
return -1;
|
||||
|
||||
struct overlay_frame *frame=malloc(sizeof(struct overlay_frame));
|
||||
bzero(frame,sizeof(struct overlay_frame));
|
||||
frame->type=OF_TYPE_DATA;
|
||||
@ -335,6 +340,9 @@ int overlay_send_probe(struct subscriber *peer, struct sockaddr_in addr, overlay
|
||||
if ((!peer) || !(peer->reachable&REACHABLE))
|
||||
my_subscriber->send_full=1;
|
||||
|
||||
if (peer)
|
||||
peer->last_probe=gettime_ms();
|
||||
|
||||
if (overlay_mdp_encode_ports(frame->payload, MDP_PORT_ECHO, MDP_PORT_PROBE)){
|
||||
op_free(frame);
|
||||
return -1;
|
||||
|
@ -214,6 +214,7 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
|
||||
// always update the IP address we heard them from, even if we don't need to use it right now
|
||||
context.sender->address = f.recvaddr;
|
||||
context.sender->last_rx = now;
|
||||
|
||||
// if this is a dummy announcement for a node that isn't in our routing table
|
||||
if (context.sender->reachable == REACHABLE_NONE &&
|
||||
@ -221,7 +222,8 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
packet_flags&PACKET_UNICAST){
|
||||
|
||||
// mark this subscriber as reachable directly via unicast.
|
||||
reachable_unicast(context.sender, interface, f.recvaddr.sin_addr, ntohs(f.recvaddr.sin_port));
|
||||
context.sender->interface = interface;
|
||||
set_reachable(context.sender, REACHABLE_UNICAST|REACHABLE_ASSUMED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,6 +308,9 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
|
||||
int next_payload = b->position + payload_len;
|
||||
|
||||
if (f.source)
|
||||
f.source->last_rx = now;
|
||||
|
||||
// if we can't understand one of the addresses, skip processing the payload
|
||||
if (context.invalid_addresses)
|
||||
goto next;
|
||||
|
@ -420,6 +420,11 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
goto skip;
|
||||
}
|
||||
|
||||
if (frame->destination)
|
||||
frame->destination->last_tx=now;
|
||||
if (frame->next_hop)
|
||||
frame->next_hop->last_tx=now;
|
||||
|
||||
// don't send rhizome adverts if the packet contains a voice payload
|
||||
if (frame->queue==OQ_ISOCHRONOUS_VOICE)
|
||||
packet->add_advertisements=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user