Add and preserve QOS bit flags in packet header

This commit is contained in:
Jeremy Lakeman 2012-10-09 16:09:33 +10:30
parent e28deeb6d5
commit 1f379ea209
8 changed files with 29 additions and 15 deletions

View File

@ -797,6 +797,7 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option *
mdp.out.src.port=port;
bcopy(srcsid,mdp.out.src.sid,SID_SIZE);
bcopy(ping_sid,&mdp.out.dst.sid[0],SID_SIZE);
mdp.out.queue=OQ_MESH_MANAGEMENT;
/* Set port to well known echo port (from /etc/services) */
mdp.out.dst.port=7;
mdp.out.payload_length=4+8;

View File

@ -204,12 +204,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
time.
#define OF_CRYPTO_PARANOID 0x0c Encrypted and digitally signed frame, with final destination address also encrypted. */
/* Data compression */
#define OF_COMPRESS_BITS 0x03
#define OF_COMPRESS_NONE 0x00
#define OF_COMPRESS_GZIP 0x01 /* Frame compressed with gzip */
#define OF_COMPRESS_BZIP2 0x02 /* bzip2 */
#define OF_COMPRESS_RESERVED 0x03 /* Reserved for another compression system */
/* QOS packet queue bits */
#define OF_QUEUE_BITS 0x03
#define RFS_PLUS250 0xfa
#define RFS_PLUS456 0xfb

View File

@ -103,16 +103,19 @@ int overlayServerMode()
for(i=0;i<OQ_MAX;i++) {
overlay_tx[i].maxLength=100;
overlay_tx[i].latencyTarget=1000; /* Keep packets in queue for 1 second by default */
overlay_tx[i].transmit_delay=10; /* Hold onto packets for 10ms before trying to send a full packet */
overlay_tx[i].transmit_delay=5; /* Hold onto packets for 10ms before trying to send a full packet */
overlay_tx[i].grace_period=100; /* Delay sending a packet for up to 100ms if servald has other processing to do */
}
/* expire voice/video call packets much sooner, as they just aren't any use if late */
overlay_tx[OQ_ISOCHRONOUS_VOICE].latencyTarget=500;
overlay_tx[OQ_ISOCHRONOUS_VIDEO].latencyTarget=500;
overlay_tx[OQ_ISOCHRONOUS_VOICE].latencyTarget=200;
overlay_tx[OQ_ISOCHRONOUS_VIDEO].latencyTarget=200;
/* try to send voice packets without any delay, and before other background processing */
overlay_tx[OQ_ISOCHRONOUS_VOICE].transmit_delay=0;
overlay_tx[OQ_ISOCHRONOUS_VOICE].grace_period=0;
/* Routing payloads, ack's and nacks need to be sent immediately */
overlay_tx[OQ_MESH_MANAGEMENT].transmit_delay=0;
/* opportunistic traffic can be significantly delayed */
overlay_tx[OQ_OPPORTUNISTIC].transmit_delay=200;

View File

@ -371,6 +371,8 @@ int overlay_saw_mdp_containing_frame(struct overlay_frame *f, time_ms_t now)
overlay_mdp_frame mdp;
bzero(&mdp, sizeof(overlay_mdp_frame));
mdp.in.queue = f->queue;
/* Get source and destination addresses */
if (f->destination)
bcopy(f->destination->sid,mdp.in.dst.sid,SID_SIZE);
@ -910,9 +912,11 @@ int overlay_mdp_dispatch(overlay_mdp_frame *mdp,int userGeneratedFrameP,
break;
}
// TODO include priority in packet header
frame->queue=OQ_ORDINARY;
/* Make sure voice traffic gets priority */
frame->queue=mdp->out.queue;
if (frame->queue==0)
frame->queue = OQ_ORDINARY;
/* Make sure only voice traffic gets priority */
if ((frame->type&OF_TYPE_BITS)==OF_TYPE_DATA_VOICE) {
frame->queue=OQ_ISOCHRONOUS_VOICE;
rhizome_saw_voice_traffic();

View File

@ -92,8 +92,6 @@ int overlay_forward_payload(struct overlay_frame *f){
if (!qf)
return WHY("Could not clone frame for queuing");
// TODO include priority in packet header
qf->queue=OQ_ORDINARY;
/* Make sure voice traffic gets priority */
if ((qf->type&OF_TYPE_BITS)==OF_TYPE_DATA_VOICE) {
qf->queue=OQ_ISOCHRONOUS_VOICE;
@ -224,6 +222,8 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
break;
}
f.queue = (f.modifiers & OF_QUEUE_BITS) +1;
/* Get time to live */
f.ttl=ob_get(b);

View File

@ -24,6 +24,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
static int op_append_type(struct overlay_buffer *headers, struct overlay_frame *p)
{
unsigned char c[3];
// pack the QOS queue into the modifiers
int q_bits = p->queue;
if (q_bits>0) q_bits--;
if (q_bits>3) q_bits=3;
p->modifiers = (p->modifiers & ~OF_QUEUE_BITS)|q_bits;
switch(p->type&OF_TYPE_FLAG_BITS)
{
case OF_TYPE_FLAG_NORMAL:
@ -195,7 +202,7 @@ int overlay_payload_enqueue(struct overlay_frame *p)
return WHYF("Destination %s is unreachable (%d)", alloca_tohex_sid(p->destination->sid), r);
}
if (p->queue<0||p->queue>=OQ_MAX)
if (p->queue>=OQ_MAX)
return WHY("Invalid queue specified");
overlay_txqueue *queue = &overlay_tx[p->queue];

View File

@ -723,6 +723,7 @@ typedef struct overlay_mdp_data_frame {
uint16_t payload_length;
// temporary hack to improve reliability before implementing per-packet nack's
int send_copies;
int queue;
unsigned char payload[MDP_MTU-100];
} overlay_mdp_data_frame;

View File

@ -60,6 +60,7 @@ doc_single_link="Start 2 instances on one link"
test_single_link() {
set_instance +A
executeOk_servald mdp ping $SIDB 3
tfw_cat --stdout --stderr
}
setup_multihop_linear() {
@ -77,6 +78,7 @@ test_multihop_linear() {
wait_until --sleep=0.25 instances_see_each_other +A +B +C +D
set_instance +A
executeOk_servald mdp ping $SIDD 3
tfw_cat --stdout --stderr
}
runTests "$@"