[Netem] changing delay in relation with packet size - patching
netem sources
Stephen Hemminger
shemminger at linux-foundation.org
Mon Jun 11 11:53:53 PDT 2007
On Fri, 08 Jun 2007 11:47:14 +0200
Luca <luca at lodi.linux.it> wrote:
> Hi all, and thanks for help me
>
> Stephen Hemminger wrote:
> > Packets come in the skb data structure. You probably want skb->len the total
> > datasize (includes all the scattered DMA fragments).
>
>
> now I'm working 2.6.20.12 kernel, in particular on
> /usr/src/linux/net/sched/sch_netem.c
>
> I think the code to modify is in the netem_enqueue, in particular this
> part:
>
> 206 if (q->gap == 0 /* not doing reordering */
> 207 || q->counter < q->gap /* inside last reordering gap */
> 208 || q->reorder < get_crandom(&q->reorder_cor)) {
> 209 psched_time_t now;
> 210 psched_tdiff_t delay;
> 211
> 212 delay = tabledist(q->latency, q->jitter,
> 213 &q->delay_cor, q->delay_dist);
> 214
> 215 PSCHED_GET_TIME(now);
> 216
> 217 // delay = delay + skb->len;
> 218 //modified by me :-D
> 219 PSCHED_TADD2(now, delay, cb->time_to_send);
> 220 ++q->counter;
> 221 ret = q->qdisc->enqueue(skb, q->qdisc);
> 222 } else {
>
> I admint I don't have knowledge for do a clean work, but for me is
> important that work and understand how work :-)
> Is that the correct part of code for implement delay in relation with
> pachet size?
You have some obvious units issues. The delay is in that location
is represented in psched clock units (varies depending on kernel
configuration), and the skb->len is in bytes. You will need to
have some rate parameter or constant to convert from length to
time. If you assume a slow network
(1 Mbit/sec) a full size packet (1500 bytes) will come out 12ms.
>
> I tryed to add
>
> delay = delay + skb->len
>
> but dont work so good, because if I add 100 of delay with tc and use
> ping, with normal setting work (I don't know yet is the delay is
> correct), but if I use
>
> ping -s 80 http://www.google.it
>
> I have (packet truncated) in ping response. why this appens?
>
> I want to use a range for example from 0 to 1000 and transform skb->len
> in this range but, which is the usual value or range value of skb->len?
>
> Thank you in advance
> Luca
--
Stephen Hemminger <shemminger at linux-foundation.org>
More information about the Netem
mailing list