Fix: Sends small packets in the MPPPP frame (for reorder).
Fix: Calculates jitter and jitter traces for analysis.
This commit is contained in:
parent
ff1db279d1
commit
81ca38323a
4 changed files with 94 additions and 52 deletions
7
debian/changelog
vendored
7
debian/changelog
vendored
|
|
@ -1,3 +1,10 @@
|
||||||
|
l2tpns (2.2.1-2fdn1.3) unstable; urgency=low
|
||||||
|
|
||||||
|
* Fix: Sends small packets in the MPPPP frame (for reorder).
|
||||||
|
* Fix: Calculates jitter and jitter traces for analysis.
|
||||||
|
|
||||||
|
-- Fernando Alves <fernando.alves@sameswireless.fr> Wed, 15 Feb 2012 14:15:59 +0100
|
||||||
|
|
||||||
l2tpns (2.2.1-2fdn1.2) unstable; urgency=low
|
l2tpns (2.2.1-2fdn1.2) unstable; urgency=low
|
||||||
|
|
||||||
* Fix: MLPPP improvments.
|
* Fix: MLPPP improvments.
|
||||||
|
|
|
||||||
22
l2tpns.c
22
l2tpns.c
|
|
@ -102,6 +102,7 @@ uint32_t eth_tx = 0;
|
||||||
|
|
||||||
static uint32_t ip_pool_size = 1; // Size of the pool of addresses used for dynamic address allocation.
|
static uint32_t ip_pool_size = 1; // Size of the pool of addresses used for dynamic address allocation.
|
||||||
time_t time_now = 0; // Current time in seconds since epoch.
|
time_t time_now = 0; // Current time in seconds since epoch.
|
||||||
|
uint64_t time_now_ms = 0; // Current time in milliseconds since epoch.
|
||||||
static char time_now_string[64] = {0}; // Current time as a string.
|
static char time_now_string[64] = {0}; // Current time as a string.
|
||||||
static int time_changed = 0; // time_now changed
|
static int time_changed = 0; // time_now changed
|
||||||
char main_quit = 0; // True if we're in the process of exiting.
|
char main_quit = 0; // True if we're in the process of exiting.
|
||||||
|
|
@ -240,6 +241,10 @@ static clockt now(double *f)
|
||||||
time_now = t.tv_sec;
|
time_now = t.tv_sec;
|
||||||
time_changed++;
|
time_changed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Time in milliseconds
|
||||||
|
time_now_ms = (t.tv_sec * 1000) + (t.tv_usec/1000);
|
||||||
|
|
||||||
return (t.tv_sec - basetime) * 10 + t.tv_usec / 100000 + 1;
|
return (t.tv_sec - basetime) * 10 + t.tv_usec / 100000 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1492,11 +1497,12 @@ static void processipout(uint8_t *buf, int len)
|
||||||
s = members[b->current_ses];
|
s = members[b->current_ses];
|
||||||
t = session[s].tunnel;
|
t = session[s].tunnel;
|
||||||
sp = &session[s];
|
sp = &session[s];
|
||||||
|
|
||||||
if ((num_of_links > 1) && (len > MINFRAGLEN))
|
|
||||||
{
|
|
||||||
LOG(4, s, t, "MPPP: (1)Session number becomes: %d\n", s);
|
LOG(4, s, t, "MPPP: (1)Session number becomes: %d\n", s);
|
||||||
|
|
||||||
|
if (num_of_links > 1)
|
||||||
|
{
|
||||||
|
if(len > MINFRAGLEN)
|
||||||
|
{
|
||||||
//for rotate traffic among the member links
|
//for rotate traffic among the member links
|
||||||
uint32_t divisor = num_of_links;
|
uint32_t divisor = num_of_links;
|
||||||
if (divisor > 2)
|
if (divisor > 2)
|
||||||
|
|
@ -1545,6 +1551,16 @@ static void processipout(uint8_t *buf, int len)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Send it as one frame
|
// Send it as one frame
|
||||||
|
uint8_t *p = makeppp(fragbuf, sizeof(fragbuf), buf, len, s, t, PPPIP, 0, bid, MP_BOTH_BITS);
|
||||||
|
if (!p) return;
|
||||||
|
tunnelsend(fragbuf, len + (p-fragbuf), t); // send it...
|
||||||
|
LOG(4, s, t, "MPPP: packet sent as one frame\n");
|
||||||
|
update_session_out_stat(s, sp, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Send it as one frame (NO MPPP Frame)
|
||||||
uint8_t *p = makeppp(fragbuf, sizeof(fragbuf), buf, len, s, t, PPPIP, 0, 0, 0);
|
uint8_t *p = makeppp(fragbuf, sizeof(fragbuf), buf, len, s, t, PPPIP, 0, 0, 0);
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
tunnelsend(fragbuf, len + (p-fragbuf), t); // send it...
|
tunnelsend(fragbuf, len + (p-fragbuf), t); // send it...
|
||||||
|
|
|
||||||
6
l2tpns.h
6
l2tpns.h
|
|
@ -261,6 +261,7 @@ typedef struct {
|
||||||
tunnelidt tid; // Fragment originating tunnel
|
tunnelidt tid; // Fragment originating tunnel
|
||||||
uint8_t flags; // MP frame flags
|
uint8_t flags; // MP frame flags
|
||||||
uint32_t seq; // fragment seq num
|
uint32_t seq; // fragment seq num
|
||||||
|
uint32_t jitteravg;
|
||||||
uint16_t length; // Fragment length
|
uint16_t length; // Fragment length
|
||||||
uint8_t data[MAXFRAGLEN]; // Fragment data
|
uint8_t data[MAXFRAGLEN]; // Fragment data
|
||||||
} fragmentt;
|
} fragmentt;
|
||||||
|
|
@ -408,6 +409,11 @@ typedef struct
|
||||||
|
|
||||||
// Last Multilink frame sequence number received
|
// Last Multilink frame sequence number received
|
||||||
uint32_t last_seq;
|
uint32_t last_seq;
|
||||||
|
|
||||||
|
// jitter average of the session
|
||||||
|
uint32_t jitteravg;
|
||||||
|
// time in milliseconds of the last fragment.
|
||||||
|
uint64_t prev_time;
|
||||||
} sessionlocalt;
|
} sessionlocalt;
|
||||||
|
|
||||||
// session flags
|
// session flags
|
||||||
|
|
|
||||||
41
ppp.c
41
ppp.c
|
|
@ -21,6 +21,7 @@ extern int tunfd;
|
||||||
extern char hostname[];
|
extern char hostname[];
|
||||||
extern uint32_t eth_tx;
|
extern uint32_t eth_tx;
|
||||||
extern time_t time_now;
|
extern time_t time_now;
|
||||||
|
extern uint64_t time_now_ms;
|
||||||
extern configt *config;
|
extern configt *config;
|
||||||
|
|
||||||
static int add_lcp_auth(uint8_t *b, int size, int authtype);
|
static int add_lcp_auth(uint8_t *b, int size, int authtype);
|
||||||
|
|
@ -1876,6 +1877,11 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
|
|
||||||
sess_local[s].last_seq = seq_num;
|
sess_local[s].last_seq = seq_num;
|
||||||
|
|
||||||
|
// calculate the jitter average
|
||||||
|
uint32_t ljitter = time_now_ms - sess_local[s].prev_time;
|
||||||
|
sess_local[s].jitteravg = (sess_local[s].jitteravg + ljitter)>>1;
|
||||||
|
sess_local[s].prev_time = time_now_ms;
|
||||||
|
|
||||||
uint32_t Mmin;
|
uint32_t Mmin;
|
||||||
|
|
||||||
if (seq_num < this_fragmentation->M)
|
if (seq_num < this_fragmentation->M)
|
||||||
|
|
@ -1902,7 +1908,7 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
{
|
{
|
||||||
// There have a long break of the link !!!!!!!!
|
// There have a long break of the link !!!!!!!!
|
||||||
// M_offset is bigger that the fragmentation buffer size
|
// M_offset is bigger that the fragmentation buffer size
|
||||||
LOG(3, s, t, "MPPP: M_offset out of range, min:%d, begin_seq:%d\n", Mmin, this_fragmentation->start_seq);
|
LOG(3, s, t, "MPPP: M_offset out of range, min:%d, begin_seq:%d, jitteravg:%d\n", Mmin, this_fragmentation->start_seq, sess_local[s].jitteravg);
|
||||||
|
|
||||||
// Calculate the new start index, the previous frag are lost
|
// Calculate the new start index, the previous frag are lost
|
||||||
begin_index = (M_offset + this_fragmentation->start_index) & MAXFRAGNUM_MASK;
|
begin_index = (M_offset + this_fragmentation->start_index) & MAXFRAGNUM_MASK;
|
||||||
|
|
@ -1927,7 +1933,7 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
if (frag_offset >= MAXFRAGNUM)
|
if (frag_offset >= MAXFRAGNUM)
|
||||||
{
|
{
|
||||||
// frag_offset is bigger that the fragmentation buffer size
|
// frag_offset is bigger that the fragmentation buffer size
|
||||||
LOG(3, s, t, "MPPP: Index out of range, seq:%d, begin_seq:%d, size frag:%d\n", seq_num, this_fragmentation->start_seq, l);
|
LOG(3, s, t, "MPPP: Index out of range, seq:%d, begin_seq:%d, jitteravg:%d\n", seq_num, this_fragmentation->start_seq, sess_local[s].jitteravg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1939,13 +1945,15 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
|
|
||||||
if (this_frag->length > 0)
|
if (this_frag->length > 0)
|
||||||
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
||||||
LOG(3, this_frag->sid, this_frag->tid, "MPPP: (INSERT) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
LOG(3, this_frag->sid, this_frag->tid, "MPPP: (INSERT) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_frag->seq, frag_index, this_frag->flags);
|
this_frag->seq, frag_index, this_frag->flags, this_frag->jitteravg);
|
||||||
|
|
||||||
this_frag->length = l;
|
this_frag->length = l;
|
||||||
this_frag->sid = s;
|
this_frag->sid = s;
|
||||||
|
this_frag->tid = t;
|
||||||
this_frag->flags = flags;
|
this_frag->flags = flags;
|
||||||
this_frag->seq = seq_num;
|
this_frag->seq = seq_num;
|
||||||
|
this_frag->jitteravg = sess_local[s].jitteravg;
|
||||||
memcpy(this_frag->data, p, l);
|
memcpy(this_frag->data, p, l);
|
||||||
|
|
||||||
LOG(4, s, t, "MPPP: seq_num:%d frag_index:%d INSERTED flags: %02X\n", seq_num, frag_index, flags);
|
LOG(4, s, t, "MPPP: seq_num:%d frag_index:%d INSERTED flags: %02X\n", seq_num, frag_index, flags);
|
||||||
|
|
@ -1967,8 +1975,9 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
{
|
{
|
||||||
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
||||||
LOG(3, this_fragmentation->fragment[frag_index_next].sid, this_fragmentation->fragment[frag_index_next].tid,
|
LOG(3, this_fragmentation->fragment[frag_index_next].sid, this_fragmentation->fragment[frag_index_next].tid,
|
||||||
"MPPP: (NEXT) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
"MPPP: (NEXT) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_fragmentation->fragment[frag_index_next].seq, frag_index_next, this_fragmentation->fragment[frag_index_next].flags);
|
this_fragmentation->fragment[frag_index_next].seq, frag_index_next,
|
||||||
|
this_fragmentation->fragment[frag_index_next].flags, this_fragmentation->fragment[frag_index_next].jitteravg);
|
||||||
// this frag is lost
|
// this frag is lost
|
||||||
this_fragmentation->fragment[frag_index_next].length = 0;
|
this_fragmentation->fragment[frag_index_next].length = 0;
|
||||||
this_fragmentation->fragment[frag_index_next].flags = 0;
|
this_fragmentation->fragment[frag_index_next].flags = 0;
|
||||||
|
|
@ -1985,8 +1994,9 @@ void processmpin(sessionidt s, tunnelidt t, uint8_t *p, uint16_t l)
|
||||||
{
|
{
|
||||||
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
// This fragment is lost, It was around the buffer and it was never completed the packet.
|
||||||
LOG(3, this_fragmentation->fragment[frag_index_prev].sid, this_fragmentation->fragment[frag_index_prev].tid,
|
LOG(3, this_fragmentation->fragment[frag_index_prev].sid, this_fragmentation->fragment[frag_index_prev].tid,
|
||||||
"MPPP: (PREV) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
"MPPP: (PREV) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_fragmentation->fragment[frag_index_prev].seq, frag_index_prev, this_fragmentation->fragment[frag_index_prev].flags);
|
this_fragmentation->fragment[frag_index_prev].seq, frag_index_prev,
|
||||||
|
this_fragmentation->fragment[frag_index_prev].flags, this_fragmentation->fragment[frag_index_prev].jitteravg);
|
||||||
|
|
||||||
this_fragmentation->fragment[frag_index_prev].length = 0;
|
this_fragmentation->fragment[frag_index_prev].length = 0;
|
||||||
this_fragmentation->fragment[frag_index_prev].flags = 0;
|
this_fragmentation->fragment[frag_index_prev].flags = 0;
|
||||||
|
|
@ -2030,8 +2040,9 @@ find_frame:
|
||||||
{
|
{
|
||||||
// This fragment is lost, it was never completed the packet.
|
// This fragment is lost, it was never completed the packet.
|
||||||
LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
|
LOG(3, this_fragmentation->fragment[end_index].sid, this_fragmentation->fragment[end_index].tid,
|
||||||
"MPPP: (FIND END) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
"MPPP: (FIND END) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_fragmentation->fragment[end_index].seq, begin_index, this_fragmentation->fragment[end_index].flags);
|
this_fragmentation->fragment[end_index].seq, begin_index,
|
||||||
|
this_fragmentation->fragment[end_index].flags, this_fragmentation->fragment[end_index].jitteravg);
|
||||||
// this frag is lost
|
// this frag is lost
|
||||||
this_fragmentation->fragment[end_index].length = 0;
|
this_fragmentation->fragment[end_index].length = 0;
|
||||||
this_fragmentation->fragment[end_index].flags = 0;
|
this_fragmentation->fragment[end_index].flags = 0;
|
||||||
|
|
@ -2060,8 +2071,9 @@ find_frame:
|
||||||
{
|
{
|
||||||
// This fragment is lost, it was never completed the packet.
|
// This fragment is lost, it was never completed the packet.
|
||||||
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
|
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
|
||||||
"MPPP: (FIND BEGIN) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
"MPPP: (FIND BEGIN) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_fragmentation->fragment[begin_index].seq, begin_index, this_fragmentation->fragment[begin_index].flags);
|
this_fragmentation->fragment[begin_index].seq, begin_index,
|
||||||
|
this_fragmentation->fragment[begin_index].flags, this_fragmentation->fragment[begin_index].jitteravg);
|
||||||
// this frag is lost
|
// this frag is lost
|
||||||
this_fragmentation->fragment[begin_index].length = 0;
|
this_fragmentation->fragment[begin_index].length = 0;
|
||||||
this_fragmentation->fragment[begin_index].flags = 0;
|
this_fragmentation->fragment[begin_index].flags = 0;
|
||||||
|
|
@ -2157,8 +2169,9 @@ assembling_frame:
|
||||||
(this_fragmentation->fragment[begin_index].seq != this_fragmentation->start_seq))
|
(this_fragmentation->fragment[begin_index].seq != this_fragmentation->start_seq))
|
||||||
{
|
{
|
||||||
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
|
LOG(3, this_fragmentation->fragment[begin_index].sid, this_fragmentation->fragment[begin_index].tid,
|
||||||
"MPPP: (START) seq_num:%d frag_index:%d flags:%d is LOST\n",
|
"MPPP: (START) seq_num:%d frag_index:%d flags:%d jitteravg:%d is LOST\n",
|
||||||
this_fragmentation->fragment[begin_index].seq, begin_index, this_fragmentation->fragment[begin_index].flags);
|
this_fragmentation->fragment[begin_index].seq, begin_index,
|
||||||
|
this_fragmentation->fragment[begin_index].flags, this_fragmentation->fragment[begin_index].jitteravg);
|
||||||
this_fragmentation->fragment[begin_index].length = 0;
|
this_fragmentation->fragment[begin_index].length = 0;
|
||||||
this_fragmentation->fragment[begin_index].flags = 0;
|
this_fragmentation->fragment[begin_index].flags = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue