Initial implementation of frame enqueuing. Queues require maxLength to be initalised to set

congestion threshold.
This commit is contained in:
gardners 2011-09-05 12:49:37 +09:30
parent c3e220e5c1
commit 27a454ef72
3 changed files with 27 additions and 5 deletions

View File

@ -550,8 +550,9 @@ int ob_unlimitsize(overlay_buffer *b);
typedef struct overlay_txqueue {
struct overlay_frame *first;
struct overlay_frame *last;
int length;
int maxLength;
int length; /* # frames in queue */
int maxLength; /* max # frames in queue before we consider ourselves congested */
/* Latency target in ms for this traffic class.
Frames older than the latency target will get dropped. */
int latencyTarget;
@ -776,4 +777,5 @@ int overlay_frame_set_me_as_source(overlay_frame *f);
int overlay_update_sequence_number();
int packetEncipher(unsigned char *packet,int maxlen,int *len,int cryptoflags);
int overlayServerMode();
int overlay_payload_enqueue(int q,overlay_frame *p);

View File

@ -209,8 +209,10 @@ int overlay_frame_process(int interface,overlay_frame *f)
if (overlay_get_nexthop(f->destination,f->nexthop,&len))
return WHY("Could not find next hop for host - dropping frame");
f->ttl--;
/* Queue frame for dispatch */
/* Queue frame for dispatch.
Don't forget to put packet in the correct queue based on type.
(e.g., mesh management, voice, video, ordinary or opportunistic). */
WHY("forwarding of frames not implemented");
/* If the frame was a broadcast frame, then we need to hang around

View File

@ -136,9 +136,27 @@ overlay_buffer *overlay_payload_unpackage(overlay_frame *b) {
int overlay_payload_enqueue(int q,overlay_frame *p)
{
/* Add payload p to queue q.
Queues get scanned from first to last, so we should append new entries
on the end of the queue.
Complain if there are too many frames in the queue.
*/
return WHY("not implemented");
if (q<0||q>=OQ_MAX) return WHY("Invalid queue specified");
if (!p) return WHY("Cannot queue NULL");
if (overlay_tx[q].length>=overlay_tx[q].maxLength) return WHY("Queue congested");
overlay_frame *l=overlay_tx[q].last;
if (l) l->next=p;
p->prev=l;
p->next=NULL;
overlay_tx[q].last=p;
if (!overlay_tx[q].first) overlay_tx[q].first=p;
overlay_tx[q].length++;
return 0;
}
int op_free(overlay_frame *p)