Add stub functions for retransmission / throttling

This commit is contained in:
Jeremy Lakeman 2013-05-13 12:23:44 +09:30
parent b4100590f6
commit b10746b3a5
4 changed files with 55 additions and 30 deletions

View File

@ -564,3 +564,13 @@ int overlay_send_tick_packet(struct overlay_interface *interface){
overlay_fill_send_packet(&packet, gettime_ms());
return 0;
}
int overlay_queue_nack(struct subscriber *neighbour, struct overlay_interface *interface, int sequence)
{
return 0;
}
int overlay_queue_ack(struct subscriber *neighbour, struct overlay_interface *interface, int sequence)
{
return 0;
}

View File

@ -38,6 +38,9 @@ struct link{
struct overlay_interface *interface;
struct subscriber *receiver;
// What's the last ack we've heard so we don't process nacks twice.
int last_ack_seq;
// neighbour path version when path scores were last updated
char path_version;
@ -180,6 +183,7 @@ static struct link *find_link(struct neighbour *neighbour, struct subscriber *re
link = *link_ptr = emalloc_zero(sizeof(struct link));
link->receiver = receiver;
link->path_version = neighbour->path_version -1;
link->last_ack_seq = -1;
}
break;
}
@ -808,41 +812,56 @@ int link_receive(overlay_mdp_frame *mdp)
if (receiver == my_subscriber)
continue;
// ignore other incoming links to our neighbour
// TODO build a map of everyone in our 2 hop neighbourhood to control broadcast flooding?
if (receiver == sender){
// who can our neighbour hear?
// TODO build a map of everyone in our 2 hop neighbourhood to control broadcast flooding?
if (transmitter == my_subscriber && interface_id != -1){
// TODO get matching neighbour link and combine scores
// TODO use ack_sequence && ack_mask to control (re)sending packets
// they can hear us? we can route through them!
interface = &overlay_interfaces[interface_id];
if (interface->state != INTERFACE_STATE_UP)
continue;
if (neighbour->neighbour_link_timeout < now)
changed = 1;
neighbour->neighbour_link_timeout = now + interface->tick_ms * 5;
}else
if (transmitter!=my_subscriber || interface_id==-1)
continue;
interface = &overlay_interfaces[interface_id];
if (interface->state != INTERFACE_STATE_UP)
continue;
}else if(transmitter == my_subscriber)
transmitter = NULL;
struct link *link = find_link(neighbour, receiver, transmitter?1:0);
if (!link)
continue;
if (link && transmitter == my_subscriber){
// TODO combine our link stats with theirs
if (transmitter == my_subscriber && receiver == sender && interface_id != -1){
// TODO get matching neighbour link and combine scores
// they can hear us? we can route through them!
if (neighbour->neighbour_link_timeout < now)
changed = 1;
neighbour->neighbour_link_timeout = now + interface->tick_ms * 5;
version = link->link_version;
if (drop_rate != link->drop_rate || transmitter != link->transmitter)
version++;
// process new nacks
if (ack_seq != link->last_ack_seq){
int i;
for (i=0;i<32;i++){
int nack_seq = (ack_seq -1 -i)&0xFF;
if (nack_seq == link->last_ack_seq)
break;
if (!(ack_mask & (1<<i))){
overlay_queue_nack(sender, interface, nack_seq);
if (config.debug.verbose && config.debug.linkstate)
DEBUGF("LINK STATE; neighbour %s missed seq %d from %s",
alloca_tohex_sid(sender->sid), nack_seq, interface->name);
}
}
}
// process ack
overlay_queue_ack(sender, interface, ack_seq);
link->last_ack_seq = ack_seq;
}
if (link && (link->transmitter != transmitter || link->link_version != version)){
if (link->transmitter != transmitter || link->link_version != version){
changed = 1;
link->transmitter = transmitter;
link->link_version = version;

View File

@ -540,6 +540,9 @@ int overlay_payload_enqueue(struct overlay_frame *p);
int overlay_queue_remaining(int queue);
int overlay_queue_schedule_next(time_ms_t next_allowed_packet);
int overlay_send_tick_packet(struct overlay_interface *interface);
int overlay_queue_nack(struct subscriber *neighbour, struct overlay_interface *interface, int sequence);
int overlay_queue_ack(struct subscriber *neighbour, struct overlay_interface *interface, int sequence);
int overlay_rhizome_saw_advertisements(int i, struct overlay_frame *f, time_ms_t now);
int rhizome_server_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
int rhizome_saw_voice_traffic();

View File

@ -437,13 +437,6 @@ test_unreliable_links2() {
set_instance +A
executeOk_servald mdp ping --timeout=3 $SIDD 5
tfw_cat --stdout --stderr
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDC:INDIRECT :"
assertStdoutGrep --matches=1 "^$SIDD:INDIRECT :"
set_instance +D
executeOk_servald route print
assertStdoutGrep --matches=1 "^$SIDA:INDIRECT :"
assertStdoutGrep --matches=1 "^$SIDB:INDIRECT :"
}
setup_circle() {