Further work on MDP, including dispatching low-priority data when

it can fit in frames.  A nasty bug in queue code needs fixing.
Also, we only send tick frames at present, and need to add code
for dispatching packets at other times (bandwidth allowance permitting).
So the whole bandwidth management code needs to get finished.
This commit is contained in:
gardners 2012-03-22 08:26:19 +10:30
parent 76ef948455
commit c7dd475d50
3 changed files with 18 additions and 8 deletions

View File

@ -159,7 +159,7 @@ int overlay_interface_args(char *arg)
for(i=0;arg[i];i++)
{
if (arg[i]==',') {
if (arg[i]==','||arg[i]=='\n') {
interface[len]=0;
if (overlay_interface_arg(interface)) return WHY("Could not add interface");
len=0;
@ -572,6 +572,7 @@ int overlay_interface_discover()
int overlay_stuff_packet_from_queue(int i,overlay_buffer *e,int q,long long now,overlay_frame *pax[],int *frame_pax,int frame_max_pax)
{
printf("Stuffing from queue #%d\n",q);
overlay_frame **p=&overlay_tx[q].first;
while(p&&*p)
{
@ -698,11 +699,13 @@ int overlay_tick_interface(int i, long long now)
/* Add advertisements for ROUTES not Rhizome bundles.
Rhizome bundle advertisements are lower priority */
overlay_route_add_advertisements(i,e);
ob_limitsize(e,overlay_interfaces[i].mtu);
/* 4. XXX Add lower-priority queued data */
overlay_stuff_packet_from_queue(i,e,OQ_ISOCHRONOUS_VIDEO,now,pax,&frame_pax,MAX_FRAME_PAX);
overlay_stuff_packet_from_queue(i,e,OQ_ORDINARY,now,pax,&frame_pax,MAX_FRAME_PAX);
overlay_stuff_packet_from_queue(i,e,OQ_OPPORTUNISTIC,now,pax,&frame_pax,MAX_FRAME_PAX);
/* 5. XXX Fill the packet up to a suitable size with anything that seems a good idea */
overlay_rhizome_add_advertisements(i,e);

View File

@ -288,7 +288,7 @@ int overlay_mdp_poll()
switch(mdp->packetTypeAndFlags&(MDP_NOCRYPT|MDP_NOSIGN)) {
case 0: /* crypted and signed (using CryptBox authcryption primitive) */
frame->modifiers=OF_CRYPTO_SIGNED|OF_CRYPTO_CIPHERED;
ob_free(frame->payload);
op_free(frame);
return WHY("ciphered+signed MDP frames not implemented");
break;
case MDP_NOSIGN:
@ -297,7 +297,7 @@ int overlay_mdp_poll()
of representing the ciphered stream segment.
*/
frame->modifiers=OF_CRYPTO_CIPHERED;
ob_free(frame->payload);
op_free(frame);
return WHY("ciphered MDP packets not implemented");
break;
case MDP_NOCRYPT:
@ -306,15 +306,21 @@ int overlay_mdp_poll()
CryptoSign key, and allow queries as to the authenticity of said key
via authcrypted channel between the parties. */
frame->modifiers=OF_CRYPTO_SIGNED;
ob_free(frame->payload);
op_free(frame);
return WHY("signed MDP packets not implemented");
break;
case MDP_NOSIGN|MDP_NOCRYPT: /* clear text and no signature */
frame->modifiers=0;
/* Copy payload body in */
frame->payload=ob_new(4 /* dst port */
frame->payload=ob_new(1 /* frame type (MDP) */
+1 /* MDP version */
+4 /* dst port */
+4 /* src port */
+mdp->out.payload_length);
/* MDP version 1 */
ob_append_byte(frame->payload,0x01);
ob_append_byte(frame->payload,0x01);
/* Destination port */
ob_append_int(frame->payload,mdp->out.dst.port);
/* XXX we should probably pull the source port from the bindings
On that note, when a binding is granted, we should probably

View File

@ -1168,7 +1168,8 @@ int overlay_route_tick()
if (overlay_route_tick_next_neighbour_id>=overlay_neighbour_count) overlay_route_tick_next_neighbour_id=0;
}
/* Tweak neighbour bundle size to spread it out over the required time */
/* Tweak neighbour bundle size to spread it out over the required time.
XXX Does this behave correctly when there are no neighbours? */
long long neighbour_time=overlay_gettime_ms()-start_time;
if (neighbour_time>2) overlay_route_tick_neighbour_bundle_size/=neighbour_time;
else if (neighbour_time==0) overlay_route_tick_neighbour_bundle_size*=2;