netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fixed delay patch for netem
@ 2008-02-24 14:11 Julio Kriger
  2008-02-26  0:54 ` [Netem] " Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Julio Kriger @ 2008-02-24 14:11 UTC (permalink / raw)
  To: netdev, netdev, netem, netem

[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]

Hi!
I have created this patch to add a fixed delay on packet filtered by
netem. Soon I will send the patch to iproute2.
This patch comes from a need I have to delay all packets 50ms, beside
the actual delay setting, like 30ms +- 15 ms. This strike, IMMHO, a
missing point on gap reordering. If I set "gap 5 delay 10ms" every 5th
(10th, 15th, ...) packet to go to be sent immediately and every other
packet to be delayed by 10ms. This  is ok, but I also need a "fixed"
delay of 50ms to be applied to all packets. Since netem can't be
nested with himself (so I can do a fixed delay), I needed this new
feature on netem.
This patch was create with linux kernel version 2.6.24.2.
I hope you like it, and it would be great if it goes shiped with the
next version of the kernel :-))
Regards,
Julio Kriger

-- 
--
>From the moment I picked your book up until I laid it down, I was
convulsed with laughter. Someday I intend reading it.
Groucho Marx
----------------------------
Julio Kriger
mailto:juliokriger@gmail.com

[-- Attachment #2: fixed_delay_patch --]
[-- Type: text/plain, Size: 2386 bytes --]

diff -Naur linux-2.6.24.2-old/include/linux/pkt_sched.h linux-2.6.24.2-new/include/linux/pkt_sched.h
--- linux-2.6.24.2-old/include/linux/pkt_sched.h	2008-02-11 03:51:11.000000000 -0200
+++ linux-2.6.24.2-new/include/linux/pkt_sched.h	2008-02-24 11:48:13.000000000 -0200
@@ -452,6 +452,7 @@
 	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* random packet dup  (0=none ~0=100%) */
 	__u32	jitter;		/* random jitter in latency (us) */
+	__u32	fixed_latency;		/* fixed latency form netem */	
 };
 
 struct tc_netem_corr
diff -Naur linux-2.6.24.2-old/net/sched/sch_netem.c linux-2.6.24.2-new/net/sched/sch_netem.c
--- linux-2.6.24.2-old/net/sched/sch_netem.c	2008-02-11 03:51:11.000000000 -0200
+++ linux-2.6.24.2-new/net/sched/sch_netem.c	2008-02-24 11:47:40.000000000 -0200
@@ -23,7 +23,7 @@
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 
-#define VERSION "1.2"
+#define VERSION "1.2.1"
 
 /*	Network Emulation Queuing algorithm.
 	====================================
@@ -65,6 +65,7 @@
 	u32 duplicate;
 	u32 reorder;
 	u32 corrupt;
+	u32 fixed_latency; /* handle fixed delay */
 
 	struct crndstate {
 		u32 last;
@@ -215,6 +216,13 @@
 		delay = tabledist(q->latency, q->jitter,
 				  &q->delay_cor, q->delay_dist);
 
+		/*
+		 * Add fixed delay
+		 */
+		if(q->fixed_latency > 0) {
+			delay += tabledist(q->fixed_latency, 0, &q->delay_cor, q->delay_dist);
+		}
+
 		now = psched_get_time();
 		cb->time_to_send = now + delay;
 		++q->counter;
@@ -225,6 +233,18 @@
 		 * of the queue.
 		 */
 		cb->time_to_send = psched_get_time();
+
+		/*
+		 * Add fixed delay
+		 */
+		if(q->fixed_latency > 0) {
+			psched_time_t now;
+			psched_tdiff_t fixed_delay;
+			fixed_delay = tabledist(q->fixed_latency, 0, &q->delay_cor, q->delay_dist);
+			now = psched_get_time();
+			cb->time_to_send = now + fixed_delay;
+		}	
+		
 		q->counter = 0;
 		ret = q->qdisc->ops->requeue(skb, q->qdisc);
 	}
@@ -427,6 +447,7 @@
 	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicate = qopt->duplicate;
+	q->fixed_latency = qopt->fixed_latency;
 
 	/* for compatibility with earlier versions.
 	 * if gap is set, need to assume 100% probability
@@ -607,6 +628,7 @@
 	qopt.loss = q->loss;
 	qopt.gap = q->gap;
 	qopt.duplicate = q->duplicate;
+	qopt.fixed_latency = q->fixed_latency;
 	RTA_PUT(skb, TCA_OPTIONS, sizeof(qopt), &qopt);
 
 	cor.delay_corr = q->delay_cor.rho;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Netem] Fixed delay patch for netem
  2008-02-24 14:11 Fixed delay patch for netem Julio Kriger
@ 2008-02-26  0:54 ` Stephen Hemminger
  2008-02-26 11:45   ` Julio Kriger
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2008-02-26  0:54 UTC (permalink / raw)
  To: Julio Kriger; +Cc: netdev, netdev, netem, netem

On Sun, 24 Feb 2008 12:11:16 -0200
"Julio Kriger" <juliokriger@gmail.com> wrote:

> Hi!
> I have created this patch to add a fixed delay on packet filtered by
> netem. Soon I will send the patch to iproute2.
> This patch comes from a need I have to delay all packets 50ms, beside
> the actual delay setting, like 30ms +- 15 ms. 

Why is 50ms + 30m +/- 15ms any different than 80ms +/- 15ms

> This strike, IMMHO, a
> missing point on gap reordering. If I set "gap 5 delay 10ms" every 5th
> (10th, 15th, ...) packet to go to be sent immediately and every other
> packet to be delayed by 10ms. This  is ok, but I also need a "fixed"
> delay of 50ms to be applied to all packets. Since netem can't be
> nested with himself (so I can do a fixed delay), I needed this new
> feature on netem.

The gap stuff is an awkward interface that should/could have been
done better.

> This patch was create with linux kernel version 2.6.24.2.
> I hope you like it, and it would be great if it goes shiped with the
> next version of the kernel :-))
> Regards,
> Julio Kriger

Maybe, but it is getting confusing with all the growth of parameters.
Probably time for a rethink.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Netem] Fixed delay patch for netem
  2008-02-26  0:54 ` [Netem] " Stephen Hemminger
@ 2008-02-26 11:45   ` Julio Kriger
  0 siblings, 0 replies; 3+ messages in thread
From: Julio Kriger @ 2008-02-26 11:45 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, netdev, netem, netem

Hi Stephen,
Answering your question: there is no diffence if (and only if) there
is no gap reordering. If there is gap reordering then packets will get
a delay of 0ms or 80ms +/- 15ms. With the patch I sent,  packets will
get a delay of 50ms or 80ms +/- 15ms.
I have read about other network emulators, like NS-2, and they have
the option of gap reordering.
As I say, I need a fixed delay of 50ms plus all the other usefull
stuff that comes with netem. And netem does not allow be nested with
himself.
Regards,
Julio


On 2/25/08, Stephen Hemminger <shemminger@linux-foundation.org> wrote:
> On Sun, 24 Feb 2008 12:11:16 -0200
> "Julio Kriger" <juliokriger@gmail.com> wrote:
>
> > Hi!
> > I have created this patch to add a fixed delay on packet filtered by
> > netem. Soon I will send the patch to iproute2.
> > This patch comes from a need I have to delay all packets 50ms, beside
> > the actual delay setting, like 30ms +- 15 ms.
>
> Why is 50ms + 30m +/- 15ms any different than 80ms +/- 15ms
>
> > This strike, IMMHO, a
> > missing point on gap reordering. If I set "gap 5 delay 10ms" every 5th
> > (10th, 15th, ...) packet to go to be sent immediately and every other
> > packet to be delayed by 10ms. This  is ok, but I also need a "fixed"
> > delay of 50ms to be applied to all packets. Since netem can't be
> > nested with himself (so I can do a fixed delay), I needed this new
> > feature on netem.
>
> The gap stuff is an awkward interface that should/could have been
> done better.
>
> > This patch was create with linux kernel version 2.6.24.2.
> > I hope you like it, and it would be great if it goes shiped with the
> > next version of the kernel :-))
> > Regards,
> > Julio Kriger
>
> Maybe, but it is getting confusing with all the growth of parameters.
> Probably time for a rethink.
>


-- 
--
>From the moment I picked your book up until I laid it down, I was
convulsed with laughter. Someday I intend reading it.
Groucho Marx
----------------------------
Julio Kriger
mailto:juliokriger@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-26 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-24 14:11 Fixed delay patch for netem Julio Kriger
2008-02-26  0:54 ` [Netem] " Stephen Hemminger
2008-02-26 11:45   ` Julio Kriger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).