mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Only ack soon if we have been asked to
This commit is contained in:
parent
e3b616421f
commit
8935db4184
@ -97,6 +97,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define PAYLOAD_FLAG_ONE_HOP (1<<2)
|
||||
#define PAYLOAD_FLAG_CIPHERED (1<<4)
|
||||
#define PAYLOAD_FLAG_SIGNED (1<<5)
|
||||
#define PAYLOAD_FLAG_ACK_SOON (1<<6)
|
||||
|
||||
/* Time-to-live is a 'uint5_t'.
|
||||
*/
|
||||
|
@ -471,7 +471,8 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
|
||||
process_incoming_frame(now, interface, &f, &context);
|
||||
|
||||
// We may need to schedule an ACK / NACK soon when we receive a payload addressed to us, or broadcast
|
||||
if (f.next_hop == my_subscriber || f.destination == my_subscriber || !f.destination)
|
||||
if (f.modifiers & PAYLOAD_FLAG_ACK_SOON &&
|
||||
(f.next_hop == my_subscriber || f.destination == my_subscriber || !f.destination))
|
||||
link_state_ack_soon(context.sender);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
static int overlay_frame_build_header(int packet_version, struct decode_context *context,
|
||||
struct overlay_buffer *buff,
|
||||
int queue, int type, int modifiers, int ttl, int sequence,
|
||||
int queue, int type, int modifiers, char will_retransmit,
|
||||
int ttl, int sequence,
|
||||
struct broadcast *broadcast, struct subscriber *next_hop,
|
||||
struct subscriber *destination, struct subscriber *source)
|
||||
{
|
||||
@ -33,7 +34,9 @@ static int overlay_frame_build_header(int packet_version, struct decode_context
|
||||
return WHYF("invalid ttl=%d", ttl);
|
||||
|
||||
int flags = modifiers & (PAYLOAD_FLAG_CIPHERED | PAYLOAD_FLAG_SIGNED);
|
||||
|
||||
if (will_retransmit)
|
||||
flags|=PAYLOAD_FLAG_ACK_SOON;
|
||||
|
||||
if (ttl==1 && !broadcast)
|
||||
flags |= PAYLOAD_FLAG_ONE_HOP;
|
||||
if (destination && destination==next_hop)
|
||||
@ -81,7 +84,8 @@ static int overlay_frame_build_header(int packet_version, struct decode_context
|
||||
}
|
||||
|
||||
int overlay_frame_append_payload(struct decode_context *context, int encapsulation,
|
||||
struct overlay_frame *p, struct overlay_buffer *b)
|
||||
struct overlay_frame *p, struct overlay_buffer *b,
|
||||
char will_retransmit)
|
||||
{
|
||||
/* Convert a payload (frame) structure into a series of bytes.
|
||||
Assumes that any encryption etc has already been done.
|
||||
@ -103,9 +107,10 @@ int overlay_frame_append_payload(struct decode_context *context, int encapsulati
|
||||
if ((!p->destination) && !is_all_matching(p->broadcast_id.id,BROADCAST_LEN,0)){
|
||||
broadcast = &p->broadcast_id;
|
||||
}
|
||||
|
||||
|
||||
if (overlay_frame_build_header(p->packet_version, context, b,
|
||||
p->queue, p->type, p->modifiers, p->ttl, p->mdp_sequence&0xFF,
|
||||
p->queue, p->type, p->modifiers, will_retransmit,
|
||||
p->ttl, p->mdp_sequence&0xFF,
|
||||
broadcast, p->next_hop,
|
||||
p->destination, p->source))
|
||||
goto cleanup;
|
||||
|
@ -445,8 +445,12 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
frame = overlay_queue_remove(queue, frame);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (overlay_frame_append_payload(&packet->context, packet->destination->encapsulation, frame, packet->buffer)){
|
||||
|
||||
char will_retransmit=1;
|
||||
if (frame->packet_version<1 || frame->resend<=0 || packet->seq==-1)
|
||||
will_retransmit=0;
|
||||
|
||||
if (overlay_frame_append_payload(&packet->context, packet->destination->encapsulation, frame, packet->buffer, will_retransmit)){
|
||||
// payload was not queued, delay the next attempt slightly
|
||||
frame->delay_until = now + 5;
|
||||
goto skip;
|
||||
@ -469,7 +473,7 @@ overlay_stuff_packet(struct outgoing_packet *packet, overlay_txqueue *queue, tim
|
||||
}
|
||||
|
||||
// dont retransmit if we aren't sending sequence numbers, or we've been asked not to
|
||||
if (frame->packet_version<1 || frame->resend<=0 || packet->seq==-1){
|
||||
if (!will_retransmit){
|
||||
if (config.debug.overlayframes)
|
||||
DEBUGF("Not waiting for retransmission (%d, %d, %d)", frame->packet_version, frame->resend, packet->seq);
|
||||
remove_destination(frame, destination_index);
|
||||
|
3
serval.h
3
serval.h
@ -547,7 +547,8 @@ int overlay_frame_resolve_addresses(struct overlay_frame *f);
|
||||
time_ms_t overlay_time_until_next_tick();
|
||||
|
||||
int overlay_frame_append_payload(struct decode_context *context, int encapsulation,
|
||||
struct overlay_frame *p, struct overlay_buffer *b);
|
||||
struct overlay_frame *p, struct overlay_buffer *b,
|
||||
char will_retransmit);
|
||||
int overlay_packet_init_header(int packet_version, int encapsulation,
|
||||
struct decode_context *context, struct overlay_buffer *buff,
|
||||
char unicast, char interface, int seq);
|
||||
|
Loading…
x
Reference in New Issue
Block a user