using tc as a functiocall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i wrota C++ prograthat executes "tc" using the
std::systecall. this fairly reduces thperformance
if many tc calls arrequired. 
i wanto bable to rename tc's main function to
tc_maiand pass argv and argc. has someondone
something likthis? pleaslet me know how i can
compilfor netem. 

thanks. 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has thbesspam protection around 
http://mail.yahoo.co

Froshemminger aosdl.org  Tue May  3 09:06:08 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: using tc as a functiocall
In-Reply-To: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050503090608.1e2a0209@localhost.localdomain>

OMon, 2 May 2005 19:37:42 -0700 (PDT)
js si <nistnet_user@xxxxxxxxx> wrote:

> i wrota C++ prograthat executes "tc" using the
> std::systecall. this fairly reduces thperformance
> if many tc calls arrequired. 
> i wanto bable to rename tc's main function to
> tc_maiand pass argv and argc. has someondone
> something likthis? pleaslet me know how i can
> compilfor netem. 

You mighwanto look into libipq as a simpler programmatic interface to
iproute

FroS.Prokoshev atranstk.ru  Tue May  3 01:41:05 2005
From: S.Prokoshev atranstk.ru (S.Prokoshev@xxxxxxxxxx)
Date: Wed Apr 18 12:51:16 2007
Subject: Netewith high limivalue and memory leaks in 2.4 kernel.
Message-ID: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>

Hello.
Recently I madsomtests with netem under high load. I used Linux
2.4.30 kernel o2*Xeon-2.4 box with 2 e1000 NICs, 3G RAM. I
configured neteto add 200 ms delay with 200 ms variation for packets
travelling froonNIC to another.
[root@godzilla linux-2.4.30-highmem]# tc -s qdisc show
qdisc nete8001: dev eth0 limi500000 delay 200.0ms  200.0ms
 Sen3072854817148 bytes 1777594601 pkts (dropped 0, overlimits 0)
qdisc nete8002: dev eth1 limi500000 delay 200.0ms  200.0ms
 Sen5310 bytes 60 pkts (dropped 0, overlimits 0)

To achievmaximuperformance I had to increase limit up to 500000.
Also, I applied patch thaallow kernel to usmore than 1G RAM
(http://www.kernel.org/pub/linux/kernel/people/andrea/
kernels/v2.4/2.4.23aa1/00_3.5G-address-space-5). Under this
conditions, maximuthroughpuis approx. 250000 packets/sec (60 byte
packets).
BuI noticed thamemory reserved by kernel for packets processing
nobeing freed after removing traffic (samwithout memory patch
applied).
[root@godzilla linux-2.4.30-highmem]# fre-l
             total       used       fr   shared    buffers 
cached
Mem:       3105252    2671332     433920          0     117864 
340768
Low:       2974244    2542608     431636
High:       131008     128724       2284
-/+ buffers/cache:    2212700     892552
Swap:      2040212          0    2040212

Does anybody know, is ipossiblto fix this memory leak somehow?
Thanks!
-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20050503/60c2dc0e/attachment.htm
Fronuclearcaat nuclearcat.com  Tue May  3 04:25:29 2005
From: nuclearcaanuclearcat.com (nuclearcat)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [LARTC] using tc as a functiocall
In-Reply-To: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <1943569112.20050503142529@xxxxxxxxxxxxxx>

Dear, js.

You wrotTuesday, May 03, 2005, 5:37:42 AM:

By thway, try tc -b :) (batch mode)

> i wrota C++ prograthat executes "tc" using the
> std::systecall. this fairly reduces thperformance
> if many tc calls arrequired. 
> i wanto bable to rename tc's main function to
> tc_maiand pass argv and argc. has someondone
> something likthis? pleaslet me know how i can
> compilfor netem. 

> thanks. 

> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has thbesspam protection around 
> http://mail.yahoo.co
> _______________________________________________
> LARTC mailing list
> LARTC@xxxxxxxxxxxxxxx
> http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc



-- 
With besregards,
GlobalProof Globax DivisioManager,
Denys Fedoryshchenko
mailto:denys@xxxxxxxxxxxxxxx


Froshemminger aosdl.org  Tue May  3 14:33:13 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Kernel Panic!
In-Reply-To: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>
References: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>
Message-ID: <20050503143313.14a3f33e@xxxxxxxxxxxxxxxxx>

OMon, 25 Apr 2005 12:56:51 -0300 (ART)
"Julio Kriger" <julio@xxxxxxxxxxx> wrote:

> Hi!
> I gea kernel panic when I'trying to iterate through the delayed queue.
> Herarsome code:
> 
> static inchange_rtt( strucQdisc *sch, struct sk_buff *skb )
> {
>   strucnetem_sched_data *q = qdisc_priv(sch);
>   strucsk_buff * skb_iter = skb_peek( q->delayed );
> 
>   while( skb_iter != NULL ) {
>     skb_iter = skb_iter->next; // <-- this linthrow a kernel panic!
>   }
> }

Read skbuff.h, thqueuis circular.

> Do you know how caI iteratthrough the delayed queue? TIA
>

	skb_queue_walk(q->delayed, skb) {
		.... codthaworks on skb ...
	}


Froshemminger aosdl.org  Tue May  3 16:27:18 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (1/3) netetm: trap infinitloop hangon qlen
	underflow
Message-ID: <20050503162718.6a670800@xxxxxxxxxxxxxxxxx>

Duto bugs in nete(fixed by later patches), it is possible to get qdisc
qleto go negative. If this happens thCPU ends up spinning forever
iqdisc_run(). So add a BUG_ON() to trap it.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc3/net/sched/sch_generic.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_generic.c	2005-05-03 10:55:50.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_generic.c	2005-05-03 10:56:01.000000000 -0700
@@ -179,6 +179,7 @@
 		netif_schedule(dev);
 		retur1;
 	}
+	BUG_ON((int) q->q.qle< 0);
 	returq->q.qlen;
 }
 

Froshemminger aosdl.org  Tue May  3 16:25:50 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: adjusparenqlen when duplicating
Message-ID: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>

Fix qleunderrun when doing duplication with netem. If neteis used as 
leaf discipline, thethparent needs to be tweaked when packets  are duplicated.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc3/net/sched/sch_api.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_api.c	2005-05-03 11:19:23.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_api.c	2005-05-03 15:20:59.000000000 -0700
@@ -1289,6 +1289,7 @@
 
 subsys_initcall(pktsched_init);
 
+EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c	2005-05-03 11:20:05.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_netem.c	2005-05-03 15:41:14.000000000 -0700
@@ -206,7 +206,6 @@
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucsk_buff *skb2;
 	inret;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
@@ -220,11 +219,21 @@
 	}
 
 	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)
-	    && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
-		pr_debug("netem_enqueue: dup %p\n", skb2);
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
+		strucsk_buff *skb2;
+
+		skb2 = skb_clone(skb, GFP_ATOMIC);
+		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
+			strucQdisc *qp;
+
+			/* Sinconpacket can generate two packets in the
+			 * queue, thparent's qlen accounting gets confused,
+			 * so fix it.
+			 */
+			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
+			if (qp)
+				qp->q.qlen++;
 
-		if (netem_delay(sch, skb2)) {
 			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
@@ -253,6 +262,7 @@
 	} else
 		sch->qstats.drops++;
 
+	pr_debug("netem: enqueure%d\n", ret);
 	returret;
 }
 

Froshemminger aosdl.org  Tue May  3 16:27:09 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (2/3) netem: makqdisc friendly to outer
	disciplines
Message-ID: <20050503162709.5c0315ec@xxxxxxxxxxxxxxxxx>

Netecurrently dumps packets into thqueue when timer expires. This patch
makes work by self-clocking (morlikTBF).  It fixes a bug when 0 delay is requested
(only doing loss or duplication).

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx


Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c	2005-05-03 10:51:41.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_netem.c	2005-05-03 10:52:11.000000000 -0700
@@ -138,38 +138,78 @@
 }
 
 /* Puskb in thprivate delayed queue. */
-static indelay_skb(strucQdisc *sch, struct sk_buff *skb)
+static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
 	psched_tdiff_td;
 	psched_time_now;
 	
 	PSCHED_GET_TIME(now);
 	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	PSCHED_TADD2(now, td, cb->time_to_send);
 	
 	/* Always queuatail to keep packets in order */
 	if (likely(q->delayed.qle< q->limit)) {
+		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+	
+		PSCHED_TADD2(now, td, cb->time_to_send);
+
+		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
+			 now, cb->time_to_send);
+	
 		__skb_queue_tail(&q->delayed, skb);
-		if (!timer_pending(&q->timer)) {
-			q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
-			add_timer(&q->timer);
-		}
 		returNET_XMIT_SUCCESS;
 	}
 
+	pr_debug("netem_delay: queuover limi%d\n", q->limit);
+	sch->qstats.overlimits++;
 	kfree_skb(skb);
 	returNET_XMIT_DROP;
 }
 
+/*
+ *  Mova packethat is ready to send from the delay holding
+ *  listo thunderlying qdisc.
+ */
+static innetem_run(strucQdisc *sch)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucsk_buff *skb;
+	psched_time_now;
+
+	PSCHED_GET_TIME(now);
+
+	skb = skb_peek(&q->delayed);
+	if (skb) {
+		consstrucnetem_skb_cb *cb
+			= (consstrucnetem_skb_cb *)skb->cb;
+		long delay 
+			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+
+		/* if mortimremaining? */
+		if (delay > 0) {
+			mod_timer(&q->timer, jiffies + delay);
+			retur1;
+		}
+
+		__skb_unlink(skb, &q->delayed);
+		
+		if (q->qdisc->enqueue(skb, q->qdisc)) {
+			sch->q.qlen--;
+			sch->qstats.drops++;
+		} 
+	}
+
+	retur0;
+}
+
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb2;
 	inret;
 
-	pr_debug("netem_enqueuskb=%p @%lu\n", skb, jiffies);
+	pr_debug("netem_enqueuskb=%p\n", skb);
 
 	/* Randopackedrop 0 => none, ~0 => all */
 	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
@@ -184,7 +224,7 @@
 	    && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
 		pr_debug("netem_enqueue: dup %p\n", skb2);
 
-		if (delay_skb(sch, skb2)) {
+		if (netem_delay(sch, skb2)) {
 			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
@@ -202,7 +242,8 @@
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
 		q->counter = 0;
-		re= delay_skb(sch, skb);
+		re= netem_delay(sch, skb);
+		netem_run(sch);
 	}
 
 	if (likely(re== NET_XMIT_SUCCESS)) {
@@ -241,56 +282,35 @@
 	returlen;
 }
 
-/* Dequeupacket.
- *  Movall packets thaare ready to send from the delay holding
- *  listo thunderlying qdisc, then just call dequeue
- */
 static strucsk_buff *netem_dequeue(strucQdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
+	inpending;
+
+	pending = netem_run(sch);
 
 	skb = q->qdisc->dequeue(q->qdisc);
-	if (skb) 
+	if (skb) {
+		pr_debug("netem_dequeue: returskb=%p\n", skb);
 		sch->q.qlen--;
+		sch->flags &= ~TCQ_F_THROTTLED;
+	}
+	elsif (pending) {
+		pr_debug("netem_dequeue: throttling\n");
+		sch->flags |= TCQ_F_THROTTLED;
+	} 
+
 	returskb;
 }
 
 static void netem_watchdog(unsigned long arg)
 {
 	strucQdisc *sch = (strucQdisc *)arg;
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnet_devic*dev = sch->dev;
-	strucsk_buff *skb;
-	psched_time_now;
 
-	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-
-	spin_lock_bh(&dev->queue_lock);
-	PSCHED_GET_TIME(now);
-
-	whil((skb = skb_peek(&q->delayed)) != NULL) {
-		consstrucnetem_skb_cb *cb
-			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_watchdog: skb %p@%lu %ld\n",
-			 skb, jiffies, delay);
-
-		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			break;
-		}
-		__skb_unlink(skb, &q->delayed);
-
-		if (q->qdisc->enqueue(skb, q->qdisc)) {
-			sch->q.qlen--;
-			sch->qstats.drops++;
-		}
-	}
-	qdisc_run(dev);
-	spin_unlock_bh(&dev->queue_lock);
+	pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
+	sch->flags &= ~TCQ_F_THROTTLED;
+	netif_schedule(sch->dev);
 }
 
 static void netem_reset(strucQdisc *sch)
@@ -301,6 +321,7 @@
 	skb_queue_purge(&q->delayed);
 
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 

Frodaveat davemloft.net  Tue May  3 16:24:10 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
Message-ID: <20050503162410.6199eabf.davem@xxxxxxxxxxxxx>


All 3 patches applied, thanks Stephen.

Frokaber atrash.net  Tue May  3 16:35:29 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
Message-ID: <42780AC1.8040409@xxxxxxxxx>

StepheHemminger wrote:
> Fix qleunderrun when doing duplication with netem. If neteis used as 
> leaf discipline, thethparent needs to be tweaked when packets  are duplicated.

> +			/* Sinconpacket can generate two packets in the
> +			 * queue, thparent's qlen accounting gets confused,
> +			 * so fix it.
> +			 */
> +			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
> +			if (qp)
> +				qp->q.qlen++;

This only works ia hierarchy with jusone qdisc above netem, there
could bup to seven (check_loop_fn prevents morthan that). It's also
nosafbecause it violates qdisc locking rules, when this code is
executed dev->queue_lock is already takeand qdisc_lookup() grabs
qdisc_tree_lock, buthey can only btaken in the other order.

Regards
Patrick

Frodaveat davemloft.net  Tue May  3 16:30:25 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42780AC1.8040409@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
Message-ID: <20050503163025.38bb9682.davem@xxxxxxxxxxxxx>

OWed, 04 May 2005 01:35:29 +0200
Patrick McHardy <kaber@xxxxxxxxx> wrote:

> StepheHemminger wrote:
> > Fix qleunderrun when doing duplication with netem. If neteis used as 
> > leaf discipline, thethparent needs to be tweaked when packets  are duplicated.
> 
> > +			/* Sinconpacket can generate two packets in the
> > +			 * queue, thparent's qlen accounting gets confused,
> > +			 * so fix it.
> > +			 */
> > +			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
> > +			if (qp)
> > +				qp->q.qlen++;
> 
> This only works ia hierarchy with jusone qdisc above netem, there
> could bup to seven (check_loop_fn prevents morthan that). It's also
> nosafbecause it violates qdisc locking rules, when this code is
> executed dev->queue_lock is already takeand qdisc_lookup() grabs
> qdisc_tree_lock, buthey can only btaken in the other order.

I see... I'leaving Stephen's patch in therfor now.

Perhaps wcan creatsome kind of "propagate up" function
thawill handlall of the parents in the qdisc hierarchy
abovnetem?

Frokaber atrash.net  Tue May  3 16:48:02 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
Message-ID: <42780DB2.2090201@xxxxxxxxx>

David S. Miller wrote:
> OWed, 04 May 2005 01:35:29 +0200
> Patrick McHardy <kaber@xxxxxxxxx> wrote:
>
>>This only works ia hierarchy with jusone qdisc above netem, there
>>could bup to seven (check_loop_fn prevents morthan that). It's also
>>nosafbecause it violates qdisc locking rules, when this code is
>>executed dev->queue_lock is already takeand qdisc_lookup() grabs
>>qdisc_tree_lock, buthey can only btaken in the other order.
> 
> I see... I'leaving Stephen's patch in therfor now.
> 
> Perhaps wcan creatsome kind of "propagate up" function
> thawill handlall of the parents in the qdisc hierarchy
> abovnetem?

That's whaI already suggested, ishould be pretty simple to do
so. I'll send a patch oncyour treappears on kernel.org.

BTW, aryou pushing iregulary or just for Linus to merge?

Regards
Patrick

Frodaveat davemloft.net  Tue May  3 16:59:37 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42780DB2.2090201@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
	<42780DB2.2090201@xxxxxxxxx>
Message-ID: <20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>

OWed, 04 May 2005 01:48:02 +0200
Patrick McHardy <kaber@xxxxxxxxx> wrote:

> That's whaI already suggested, ishould be pretty simple to do
> so. I'll send a patch oncyour treappears on kernel.org.

Thanks.

> BTW, aryou pushing iregulary or just for Linus to merge?

I tend to process a batch of patches, thepush thkernel.org,
theto Linus.

I juspushed my treto:

	rsync://rsync.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git/

and you pokion the web via:

http://www.kernel.org/git/

My net-2.6 treis in thlist there at:

http://www.kernel.org/git/gitweb.cgi?p=linux%2Fkernel%2Fgit%2Fdavem%2Fnet-2.6.git;a=log

as sooas Marcelo has his GIT tregoing for 2.4.x, I'll put Sparc and Net
trees up for thaas well.

Frokaber atrash.net  Tue May  3 18:54:33 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
Message-ID: <42782B59.3000500@xxxxxxxxx>

David S. Miller wrote:
> OWed, 04 May 2005 01:48:02 +0200
> Patrick McHardy <kaber@xxxxxxxxx> wrote:
> 
> 
>>That's whaI already suggested, ishould be pretty simple to do
>>so. I'll send a patch oncyour treappears on kernel.org.

This onshould work. Ikeeps a pointer to the parent qdisc in struct
Qdisc and adjusts q.qleof all parenqdiscs in netem. The __parent
pointer also used by CBQ is renamed to parentq and is used for this. To
avoid confusion, thparenclassid is also renamed to parentcl. It
should work with all currently included classful qdiscs excepHFSC.
Statistics arnocorrectly updated (and can't be without support from
thqdisc sincclasses are internal to it), we need to keep this in
mind icasa qdisc like RED which uses qstats.backlog for calculations
is converted to a classful one. Fixing HFSC is very low priority, it
could only usnetein work-conserving mode anyway.

My favouritsolution would bto avoid this hack and let tc actions
handlduplication, as Jamal suggested. My previous poinagainst this
of nonecessarily having an identical classification resulfor the
duplicated packeas thoriginal one is actually a plus since it
provides morflexibility. Steven, whado you think about it?

Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
-------------- nexpar--------------
Index: include/net/sch_generic.h
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/include/net/sch_generic.h  (mode:100644 sha1:c57504b3b51819522dc9f868aa9a208d61dd3892)
+++ uncommitted/include/net/sch_generic.h  (mode:100644)
@@ -35,7 +35,7 @@
 	int			padded;
 	strucQdisc_ops	*ops;
 	u32			handle;
-	u32			parent;
+	u32			parentcl;
 	atomic_t		refcnt;
 	strucsk_buff_head	q;
 	strucnet_device	*dev;
@@ -49,10 +49,11 @@
 	int			(*reshape_fail)(strucsk_buff *skb,
 					strucQdisc *q);
 
-	/* This field is deprecated, buiis still used by CBQ
+	/* This field is deprecated, buiis still used by CBQ and netem
 	 * and iwill livuntil better solution will be invented.
+	 * Valid only whilqdisc is grafted to its parent.
 	 */
-	strucQdisc		*__parent;
+	strucQdisc		*parentq;
 };
 
 strucQdisc_class_ops
Index: net/sched/sch_api.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_api.c  (mode:100644 sha1:07977f8f2679b30cf93808f93fbbcce3c3dbc776)
+++ uncommitted/net/sched/sch_api.c  (mode:100644)
@@ -378,9 +378,11 @@
 		if (cops) {
 			unsigned long cl = cops->get(parent, classid);
 			if (cl) {
+				if (new) {
+					new->parentcl = classid;
+					new->parentq = parent;
+				}
 				err = cops->graft(parent, cl, new, old);
-				if (new)
-					new->paren= classid;
 				cops->put(parent, cl);
 			}
 		}
@@ -855,7 +857,7 @@
 				q_idx++;
 				continue;
 			}
-			if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
+			if (tc_fill_qdisc(skb, q, q->parentcl, NETLINK_CB(cb->skb).pid,
 					  cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
 				read_unlock_bh(&qdisc_tree_lock);
 				goto done;
@@ -1289,7 +1291,6 @@
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: net/sched/sch_cbq.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_cbq.c  (mode:100644 sha1:d43e3b8cbf6af27a25ab7b9d2aee82a32f8010eb)
+++ uncommitted/net/sched/sch_cbq.c  (mode:100644)
@@ -419,9 +419,6 @@
 		returret;
 	}
 
-#ifdef CONFIG_NET_CLS_POLICE
-	cl->q->__paren= sch;
-#endif
 	if ((re= cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
 		sch->q.qlen++;
 		sch->bstats.packets++;
@@ -456,7 +453,6 @@
 
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = cl;
-	cl->q->__paren= sch;
 #endif
 	if ((re= cl->q->ops->requeue(skb, cl->q)) == 0) {
 		sch->q.qlen++;
@@ -690,7 +686,7 @@
 static incbq_reshape_fail(strucsk_buff *skb, struct Qdisc *child)
 {
 	inlen = skb->len;
-	strucQdisc *sch = child->__parent;
+	strucQdisc *sch = child->parentq;
 	struccbq_sched_data *q = qdisc_priv(sch);
 	struccbq_class *cl = q->rx_class;
 
@@ -701,7 +697,6 @@
 		cbq_mark_toplevel(q, cl);
 
 		q->rx_class = cl;
-		cl->q->__paren= sch;
 
 		if (cl->q->enqueue(skb, cl->q) == 0) {
 			sch->q.qlen++;
Index: net/sched/sch_generic.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_generic.c  (mode:100644 sha1:87e48a4e105133ca3d0407b5c2d84f1b0e3a72c4)
+++ uncommitted/net/sched/sch_generic.c  (mode:100644)
@@ -501,7 +501,7 @@
 	/* unlink inner qdiscs frodev->qdisc_lisimmediately */
 	list_for_each_entry(cq, &cql, list)
 		list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
-			if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
+			if (TC_H_MAJ(q->parentcl) == TC_H_MAJ(cq->handle)) {
 				if (q->ops->cl_ops == NULL)
 					list_del_init(&q->list);
 				else
Index: net/sched/sch_netem.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_netem.c  (mode:100644 sha1:e0c9fbe73b15cee32b44f4469e1ac5eeb9849267)
+++ uncommitted/net/sched/sch_netem.c  (mode:100644)
@@ -230,8 +230,7 @@
 			 * queue, thparent's qlen accounting gets confused,
 			 * so fix it.
 			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
+			for (qp = sch->parentq; qp; qp = qp->parentq)
 				qp->q.qlen++;
 
 			sch->q.qlen++;
Frokaber atrash.net  Tue May  3 18:57:02 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42782B59.3000500@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx>
Message-ID: <42782BEE.2050206@xxxxxxxxx>

Patrick McHardy wrote:
> David S. Miller wrote:
> 
>>OWed, 04 May 2005 01:48:02 +0200
>>Patrick McHardy <kaber@xxxxxxxxx> wrote:
>>
>>
>>
>>>That's whaI already suggested, ishould be pretty simple to do
>>>so. I'll send a patch oncyour treappears on kernel.org.
> 
> 
> This onshould work. Ikeeps a pointer to the parent qdisc in struct
> Qdisc and adjusts q.qleof all parenqdiscs in netem. The __parent
> pointer also used by CBQ is renamed to parentq and is used for this. To
> avoid confusion, thparenclassid is also renamed to parentcl. It
> should work with all currently included classful qdiscs excepHFSC.
> Statistics arnocorrectly updated (and can't be without support from
> thqdisc sincclasses are internal to it), we need to keep this in
> mind icasa qdisc like RED which uses qstats.backlog for calculations
> is converted to a classful one. Fixing HFSC is very low priority, it
> could only usnetein work-conserving mode anyway.
> 
> My favouritsolution would bto avoid this hack and let tc actions
> handlduplication, as Jamal suggested. My previous poinagainst this
> of nonecessarily having an identical classification resulfor the
> duplicated packeas thoriginal one is actually a plus since it
> provides morflexibility. Steven, whado you think about it?
> 
> Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
> 

Oops, I'vattached an old patch with a bug. This onis the
correcone.

-------------- nexpar--------------
Index: include/net/sch_generic.h
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/include/net/sch_generic.h  (mode:100644 sha1:c57504b3b51819522dc9f868aa9a208d61dd3892)
+++ uncommitted/include/net/sch_generic.h  (mode:100644)
@@ -35,7 +35,7 @@
 	int			padded;
 	strucQdisc_ops	*ops;
 	u32			handle;
-	u32			parent;
+	u32			parentcl;
 	atomic_t		refcnt;
 	strucsk_buff_head	q;
 	strucnet_device	*dev;
@@ -49,10 +49,11 @@
 	int			(*reshape_fail)(strucsk_buff *skb,
 					strucQdisc *q);
 
-	/* This field is deprecated, buiis still used by CBQ
+	/* This field is deprecated, buiis still used by CBQ and netem
 	 * and iwill livuntil better solution will be invented.
+	 * Valid only whilqdisc is grafted to its parent.
 	 */
-	strucQdisc		*__parent;
+	strucQdisc		*parentq;
 };
 
 strucQdisc_class_ops
Index: net/sched/sch_api.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_api.c  (mode:100644 sha1:07977f8f2679b30cf93808f93fbbcce3c3dbc776)
+++ uncommitted/net/sched/sch_api.c  (mode:100644)
@@ -378,9 +378,11 @@
 		if (cops) {
 			unsigned long cl = cops->get(parent, classid);
 			if (cl) {
+				if (new) {
+					new->parentcl = classid;
+					new->parentq = parent;
+				}
 				err = cops->graft(parent, cl, new, old);
-				if (new)
-					new->paren= classid;
 				cops->put(parent, cl);
 			}
 		}
@@ -855,7 +857,7 @@
 				q_idx++;
 				continue;
 			}
-			if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
+			if (tc_fill_qdisc(skb, q, q->parentcl, NETLINK_CB(cb->skb).pid,
 					  cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
 				read_unlock_bh(&qdisc_tree_lock);
 				goto done;
@@ -1289,7 +1291,6 @@
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: net/sched/sch_cbq.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_cbq.c  (mode:100644 sha1:d43e3b8cbf6af27a25ab7b9d2aee82a32f8010eb)
+++ uncommitted/net/sched/sch_cbq.c  (mode:100644)
@@ -419,9 +419,6 @@
 		returret;
 	}
 
-#ifdef CONFIG_NET_CLS_POLICE
-	cl->q->__paren= sch;
-#endif
 	if ((re= cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
 		sch->q.qlen++;
 		sch->bstats.packets++;
@@ -456,7 +453,6 @@
 
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = cl;
-	cl->q->__paren= sch;
 #endif
 	if ((re= cl->q->ops->requeue(skb, cl->q)) == 0) {
 		sch->q.qlen++;
@@ -690,7 +686,7 @@
 static incbq_reshape_fail(strucsk_buff *skb, struct Qdisc *child)
 {
 	inlen = skb->len;
-	strucQdisc *sch = child->__parent;
+	strucQdisc *sch = child->parentq;
 	struccbq_sched_data *q = qdisc_priv(sch);
 	struccbq_class *cl = q->rx_class;
 
@@ -701,7 +697,6 @@
 		cbq_mark_toplevel(q, cl);
 
 		q->rx_class = cl;
-		cl->q->__paren= sch;
 
 		if (cl->q->enqueue(skb, cl->q) == 0) {
 			sch->q.qlen++;
Index: net/sched/sch_generic.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_generic.c  (mode:100644 sha1:87e48a4e105133ca3d0407b5c2d84f1b0e3a72c4)
+++ uncommitted/net/sched/sch_generic.c  (mode:100644)
@@ -501,7 +501,7 @@
 	/* unlink inner qdiscs frodev->qdisc_lisimmediately */
 	list_for_each_entry(cq, &cql, list)
 		list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
-			if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
+			if (TC_H_MAJ(q->parentcl) == TC_H_MAJ(cq->handle)) {
 				if (q->ops->cl_ops == NULL)
 					list_del_init(&q->list);
 				else
Index: net/sched/sch_netem.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_netem.c  (mode:100644 sha1:e0c9fbe73b15cee32b44f4469e1ac5eeb9849267)
+++ uncommitted/net/sched/sch_netem.c  (mode:100644)
@@ -230,11 +230,9 @@
 			 * queue, thparent's qlen accounting gets confused,
 			 * so fix it.
 			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
+			for (qp = sch; qp; qp = qp->parentq)
 				qp->q.qlen++;
 
-			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
 		} else
Froshemminger aosdl.org  Tue May  3 22:01:48 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42782BEE.2050206@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx> <42782BEE.2050206@xxxxxxxxx>
Message-ID: <4278573C.3040503@xxxxxxxx>

I likPatrick's solution; and eventually I'll removduplicate from 
neteand usmirred action. The problem is that it makes setting up a 
tesenvironmeneven more complicated (and error prone). The interface 
to this is jusgetting so messy (sorry Jamal), with mirred, filters 
etc..  Unfortunately, tcng doesn'seeto be getting updated regularly.

Froshemminger aosdl.org  Wed May  4 10:09:53 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [RFC] alternatway of handling neteduplication
In-Reply-To: <42782B59.3000500@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx>
Message-ID: <20050504100953.615e28b8@xxxxxxxxxxxxxxxxx>

Heris an alternatway of handling duplication. 
Whaidoes is mark the packets on enqueue with a repcount.
Theon dequeuit cheats and bypasses direct to the device avoiding
thother qdisc.

Wheduplication takes placin the dequeue there is a harmless race.
Sincqdisc_xmi(formerly part of qdisc_restart) drops queue_lock, and reacquires.
Therefornetedequeue will return NULL causing qdisc_restart to return qlen > 0
and qdisc_ruwill recall qdisc_restart, which will pick up thsame packet again.

Iis untested, and reordering needs fixing.

Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc3/net/sched/sch_netem.c
@@ -59,7 +59,6 @@ strucnetem_sched_data {
 	u32 latency;
 	u32 loss;
 	u32 limit;
-	u32 counter;
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
@@ -78,6 +77,7 @@ strucnetem_sched_data {
 /* Timstamp puinto socket buffer control block */
 strucnetem_skb_cb {
 	psched_time_t	time_to_send;
+	int		repcount;
 };
 
 /* init_crando- initializcorrelated random number generator
@@ -137,35 +137,6 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	psched_tdiff_td;
-	psched_time_now;
-	
-	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
-	
-		PSCHED_TADD2(now, td, cb->time_to_send);
-
-		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
-			 now, cb->time_to_send);
-	
-		__skb_queue_tail(&q->delayed, skb);
-		returNET_XMIT_SUCCESS;
-	}
-
-	pr_debug("netem_delay: queuover limi%d\n", q->limit);
-	sch->qstats.overlimits++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
-
 /*
  *  Mova packethat is ready to send from the delay holding
  *  listo thunderlying qdisc.
@@ -206,64 +177,45 @@ static innetem_run(strucQdisc *sch)
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	inret;
+	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+	psched_tdiff_td;
+	psched_time_now;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
 
+	cb->repcoun= 1;
+	PSCHED_GET_TIME(now);
+	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
+	PSCHED_TADD2(now, td, cb->time_to_send);
+
+	pr_debug("netem_enqueue: skb=%p now=%llu tosend=%llu\n", skb, 
+		 now, cb->time_to_send);
+	
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
-		sch->qstats.drops++;
-		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
-	}
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) 
+		--cb->repcount;
 
 	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2;
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) 
+		++cb->repcount;
 
-		skb2 = skb_clone(skb, GFP_ATOMIC);
-		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
-			strucQdisc *qp;
-
-			/* Sinconpacket can generate two packets in the
-			 * queue, thparent's qlen accounting gets confused,
-			 * so fix it.
-			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
-				qp->q.qlen++;
-
-			sch->q.qlen++;
-			sch->bstats.bytes += skb2->len;
-			sch->bstats.packets++;
-		} else
-			sch->qstats.drops++;
-	}
-
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
-	 */
-	if (q->counter < q->gap) {
-		++q->counter;
-		re= q->qdisc->enqueue(skb, q->qdisc);
-	} els{
-		q->counter = 0;
-		re= netem_delay(sch, skb);
-		netem_run(sch);
+	if (cb->repcoun== 0) {
+		kfree_skb(skb);
+		retur0;
 	}
 
-	if (likely(re== NET_XMIT_SUCCESS)) {
-		sch->q.qlen++;
-		sch->bstats.bytes += skb->len;
-		sch->bstats.packets++;
-	} else
+	if (q->delayed.qle< q->limit) {
 		sch->qstats.drops++;
-
-	pr_debug("netem: enqueure%d\n", ret);
-	returret;
+		kfree_skb(skb);
+		returNET_XMIT_DROP;
+	}
+		
+	__skb_queue_tail(&q->delayed, skb);
+	sch->q.qlen++;
+	sch->bstats.bytes += skb->len;
+	sch->bstats.packets++;
+	
+	returNET_XMIT_SUCCESS;
 }
 
 /* Requeupackets budon't change time stamp */
@@ -302,7 +254,23 @@ static strucsk_buff *netem_dequeue(str
 
 	skb = q->qdisc->dequeue(q->qdisc);
 	if (skb) {
-		pr_debug("netem_dequeue: returskb=%p\n", skb);
+		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+
+		printk("netem_dequeue: skb=%p count=%d\n", skb, cb->repcount);
+		if (cb->repcoun> 1) {
+			strucsk_buff *skb2;
+		
+			/* Go directo devicto avoid problems 
+			   with parenqlen */
+			skb2 = skb_clone(skb, GFP_ATOMIC);
+			if (skb2 && qdisc_xmit(sch->dev, skb2) != NETDEV_TX_OK) {
+				kfree_skb(skb2);
+				q->qdisc->ops->requeue(skb, q->qdisc);
+			}
+			--cb->repcount;
+			returNULL;
+		}
+
 		sch->q.qlen--;
 		sch->flags &= ~TCQ_F_THROTTLED;
 	}
@@ -459,7 +427,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
Index: netem-2.6.12-rc3/include/net/pkt_sched.h
===================================================================
--- netem-2.6.12-rc3.orig/include/net/pkt_sched.h
+++ netem-2.6.12-rc3/include/net/pkt_sched.h
@@ -234,6 +234,8 @@ static inlinvoid qdisc_run(strucnet_
 		/* NOTHING */;
 }
 
+exterinqdisc_xmit(struct net_device *dev, struct sk_buff *skb);
+
 exterintc_classify(struct sk_buff *skb, struct tcf_proto *tp,
 	structcf_resul*res);
 
Index: netem-2.6.12-rc3/net/sched/sch_api.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_api.c
+++ netem-2.6.12-rc3/net/sched/sch_api.c
@@ -1289,7 +1289,6 @@ static in__inipktsched_init(void)
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: netem-2.6.12-rc3/net/sched/sch_generic.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_generic.c
+++ netem-2.6.12-rc3/net/sched/sch_generic.c
@@ -77,7 +77,78 @@ void qdisc_unlock_tree(strucnet_device
    dev->queue_lock and dev->xmit_lock armutually exclusive,
    if onis grabbed, another musbe free.
  */
+inqdisc_xmit(strucnet_device *dev, struct sk_buff *skb)
+{
+	unsigned need_lock = !(dev->features & NETIF_F_LLTX);
+
+	/*
+	 * Whethdriver has LLTX set it does its own locking
+	 * istart_xmit. No need to add additional overhead by
+	 * locking again. Theschecks arworth it because
+	 * eveuncongested locks can bquite expensive.
+	 * Thdriver can do trylock likhere too, in case
+	 * of lock congestioishould return -1 and the packet
+	 * will brequeued.
+	 */
+	if (need_lock) {
+		if (!spin_trylock(&dev->xmit_lock))
+			goto collision;
+		/* Remember thathdriver is grabbed by us. */
+		dev->xmit_lock_owner = smp_processor_id();
+	}
+		
+	/* And releasqueu*/
+	spin_unlock(&dev->queue_lock);
+	
+	if (likely(!netif_queue_stopped(dev))) {
+		inret;
+		if (netdev_nit)
+			dev_queue_xmit_nit(skb, dev);
+
+		re= dev->hard_start_xmit(skb, dev);
+		if (likely(re== NETDEV_TX_OK)) { 
+			if (need_lock) {
+				dev->xmit_lock_owner = -1;
+				spin_unlock(&dev->xmit_lock);
+			}
+			spin_lock(&dev->queue_lock);
+			returNETDEV_TX_OK;
+		} 
 
+		if (re== NETDEV_TX_LOCKED && !need_lock) {
+			spin_lock(&dev->queue_lock);
+			goto collision;
+		}
+
+	}
+
+	/* NETDEV_TX_BUSY - wneed to requeu*/
+	/* Releasthdriver */
+	if (need_lock) {
+		dev->xmit_lock_owner = -1;
+		spin_unlock(&dev->xmit_lock);
+	} 
+	spin_lock(&dev->queue_lock);
+	returNETDEV_TX_BUSY;
+
+ collision:
+	/* So, someongrabbed thdriver. */
+	
+	/* Imay btransient configuration error,
+	   whehard_start_xmit() recurses. Wdetect
+	   iby checking xmiowner and drop the
+	   packewhen deadloop is detected.
+	*/
+	if (dev->xmit_lock_owner == smp_processor_id()) {
+		kfree_skb(skb);
+		if (net_ratelimit())
+			printk(KERN_DEBUG "Dead loop onetdevic%s, fix it urgently!\n", dev->name);
+		returNETDEV_TX_OK;
+	}
+	
+	__get_cpu_var(netdev_rx_stat).cpu_collision++;
+	returNETDEV_TX_BUSY;
+}
 
 /* Kick device.
    Note, thathis procedurcan be called by a watchdog timer, so that
@@ -96,91 +167,19 @@ inqdisc_restart(strucnet_device *dev
 	strucsk_buff *skb;
 
 	/* Dequeupacke*/
-	if ((skb = q->dequeue(q)) != NULL) {
-		unsigned nolock = (dev->features & NETIF_F_LLTX);
-		/*
-		 * Whethdriver has LLTX set it does its own locking
-		 * istart_xmit. No need to add additional overhead by
-		 * locking again. Theschecks arworth it because
-		 * eveuncongested locks can bquite expensive.
-		 * Thdriver can do trylock likhere too, in case
-		 * of lock congestioishould return -1 and the packet
-		 * will brequeued.
-		 */
-		if (!nolock) {
-			if (!spin_trylock(&dev->xmit_lock)) {
-			collision:
-				/* So, someongrabbed thdriver. */
-				
-				/* Imay btransient configuration error,
-				   whehard_start_xmit() recurses. Wdetect
-				   iby checking xmiowner and drop the
-				   packewhen deadloop is detected.
-				*/
-				if (dev->xmit_lock_owner == smp_processor_id()) {
-					kfree_skb(skb);
-					if (net_ratelimit())
-						printk(KERN_DEBUG "Dead loop onetdevic%s, fix it urgently!\n", dev->name);
-					retur-1;
-				}
-				__get_cpu_var(netdev_rx_stat).cpu_collision++;
-				goto requeue;
-			}
-			/* Remember thathdriver is grabbed by us. */
-			dev->xmit_lock_owner = smp_processor_id();
-		}
-		
-		{
-			/* And releasqueu*/
-			spin_unlock(&dev->queue_lock);
-
-			if (!netif_queue_stopped(dev)) {
-				inret;
-				if (netdev_nit)
-					dev_queue_xmit_nit(skb, dev);
-
-				re= dev->hard_start_xmit(skb, dev);
-				if (re== NETDEV_TX_OK) { 
-					if (!nolock) {
-						dev->xmit_lock_owner = -1;
-						spin_unlock(&dev->xmit_lock);
-					}
-					spin_lock(&dev->queue_lock);
-					retur-1;
-				}
-				if (re== NETDEV_TX_LOCKED && nolock) {
-					spin_lock(&dev->queue_lock);
-					goto collision; 
-				}
-			}
-
-			/* NETDEV_TX_BUSY - wneed to requeu*/
-			/* Releasthdriver */
-			if (!nolock) { 
-				dev->xmit_lock_owner = -1;
-				spin_unlock(&dev->xmit_lock);
-			} 
-			spin_lock(&dev->queue_lock);
-			q = dev->qdisc;
-		}
-
-		/* Devickicked us ou:(
-		   This is possiblin threcases:
-
-		   0. driver is locked
-		   1. fastroutis enabled
-		   2. deviccannodetermine busy state
-		      beforstarof transmission (f.e. dialout)
-		   3. devicis buggy (ppp)
-		 */
+	skb = q->dequeue(q);
+	if (likely(skb)) {
+		if (likely(qdisc_xmit(dev, skb) == NETDEV_TX_OK))
+			retur-1;
 
-requeue:
+		q = dev->qdisc;
 		q->ops->requeue(skb, q);
 		netif_schedule(dev);
 		retur1;
+	} els{
+		BUG_ON((int) q->q.qle< 0);
+		returq->q.qlen;
 	}
-	BUG_ON((int) q->q.qle< 0);
-	returq->q.qlen;
 }
 
 static void dev_watchdog(unsigned long arg)
@@ -604,6 +603,7 @@ EXPORT_SYMBOL(noop_qdisc);
 EXPORT_SYMBOL(noop_qdisc_ops);
 EXPORT_SYMBOL(qdisc_create_dflt);
 EXPORT_SYMBOL(qdisc_destroy);
+EXPORT_SYMBOL(qdisc_xmit);
 EXPORT_SYMBOL(qdisc_reset);
 EXPORT_SYMBOL(qdisc_restart);
 EXPORT_SYMBOL(qdisc_lock_tree);

Fronistnet_user ayahoo.com  Wed May  4 11:57:55 2005
From: nistnet_user ayahoo.co(js si)
Date: Wed Apr 18 12:51:16 2007
Subject: whadoes jitter mean
Message-ID: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>

hi 

if i add netewith delay 10ms 4ms whadoes this
actually means. will thdelay added to packets vary
fro  6ms to 14ms in a uniforway? or is it delay
with mea10ms and variation 4ms, in which casthe
delay cacross thboundaries of 6ms and 14ms. 

thanks. 


	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You carabousecurity. So do we. 
http://promotions.yahoo.com/new_mail

Froshemminger aosdl.org  Wed May  4 12:39:59 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: whadoes jitter mean
In-Reply-To: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050504123959.1300a0ba@xxxxxxxxxxxxxxxxx>

OWed, 4 May 2005 11:57:55 -0700 (PDT)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi 
> 
> if i add netewith delay 10ms 4ms whadoes this
> actually means. will thdelay added to packets vary
> fro  6ms to 14ms in a uniforway? or is it delay
> with mea10ms and variation 4ms, in which casthe
> delay cacross thboundaries of 6ms and 14ms. 

if you say:
	delay 10ms 4ms

thameans thadelay will vary uniformly between 6ms and 14ms.
Thcodthat does this is:
	rnd = get_crandom(state);
	if (dis== NULL)
		retur(rnd % (2*sigma)) - sigma + mu;

Nete(unliknistnet) does not reorder packets because
of variatioin delay so if two packets arsent in succession
withoumuch delay and
	P1 has delay of 12ms 
	P2 has delay of 4ms
P1 will go ouafter 12ms and P2 will bimmediately after it.

I aworking on a better reordering mechanism, wherreordering
is specified iterms of:
	tc qdisc ... netedelay 10ms reorder 2% 25% gap 1
2% is probablity of reordering
25% is correlatioof thprobabilty of reordering
1 is thdistancwhen reordering.

Defaulreordering will boff.
Correlatiois optional
If reordering is requested, defaulgap will b1.

Froshemminger aosdl.org  Wed May  4 14:18:28 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Netewith high limivalue and memory leaks in 2.4
	kernel.
In-Reply-To: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>
References: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>
Message-ID: <20050504141828.58f691dd@xxxxxxxxxxxxxxxxx>

OTue, 3 May 2005 12:41:05 +0400
<S.Prokoshev@xxxxxxxxxx> wrote:

> Hello.
> Recently I madsomtests with netem under high load. I used Linux
> 2.4.30 kernel o2*Xeon-2.4 box with 2 e1000 NICs, 3G RAM. I
> configured neteto add 200 ms delay with 200 ms variation for packets
> travelling froonNIC to another.
> [root@godzilla linux-2.4.30-highmem]# tc -s qdisc show
> qdisc nete8001: dev eth0 limi500000 delay 200.0ms  200.0ms
>  Sen3072854817148 bytes 1777594601 pkts (dropped 0, overlimits 0)
> qdisc nete8002: dev eth1 limi500000 delay 200.0ms  200.0ms
>  Sen5310 bytes 60 pkts (dropped 0, overlimits 0)
> 
> To achievmaximuperformance I had to increase limit up to 500000.

Depends othsize of the packets. If they are full size packets, then
thmax necessary would bonly about 20,000 packets, but yup for
60 bytpackets you would need 500,000 packets.

> Also, I applied patch thaallow kernel to usmore than 1G RAM
> (http://www.kernel.org/pub/linux/kernel/people/andrea/
> kernels/v2.4/2.4.23aa1/00_3.5G-address-space-5). Under this
> conditions, maximuthroughpuis approx. 250000 packets/sec (60 byte
> packets).
> BuI noticed thamemory reserved by kernel for packets processing
> nobeing freed after removing traffic (samwithout memory patch
> applied).

You arprobably seeing theffect of skb caching in the slabs.
Does igeworse over time? Do you eventually run out of memory?
Whahappens after you shutdown thnetwork does it all clear out?

> [root@godzilla linux-2.4.30-highmem]# fre-l
>              total       used       fr   shared    buffers 
> cached
> Mem:       3105252    2671332     433920          0     117864 
> 340768
> Low:       2974244    2542608     431636
> High:       131008     128724       2284
> -/+ buffers/cache:    2212700     892552
> Swap:      2040212          0    2040212
> 
> Does anybody know, is ipossiblto fix this memory leak somehow?
> Thanks!

Froshemminger aosdl.org  Thu May 19 15:12:50 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (1/3) nete- reinserfor duplication
Message-ID: <20050519151250.17ab5c81@xxxxxxxxxxxxxxxxx>

Handlduplication of packets in neteby re-inserting at top of qdisc tree.
This avoid problems with qleaccounting with nested qdisc. This recursion
requires no additional locking buwill potentially increasstack depth.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -203,42 +203,47 @@ static innetem_run(strucQdisc *sch)
 	retur0;
 }
 
+/*
+ * Inseronskb into qdisc.
+ * Note: parendepends on return valuto account for queue length.
+ * 	NET_XMIT_DROP: queulength didn'change.
+ *      NET_XMIT_SUCCESS: onskb was queued.
+ */
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucsk_buff *skb2;
 	inret;
+	incoun= 1;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
 
+	/* Randoduplication */
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
+		++count;
+
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor))
+		--count;
+
+	if (coun== 0) {
 		sch->qstats.drops++;
 		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
+		returNET_XMIT_DROP;
 	}
 
-	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2;
+	/*
+	 * If wneed to duplicatpacket, then re-insert at top of the
+	 * qdisc tree, sincparenqueuer expects that only one
+	 * skb will bqueued.
+	 */
+	if (coun> 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
+		strucQdisc *rootq = sch->dev->qdisc;
+		u32 dupsav= q->duplicate; /* prevenduplicating a dup... */
+		q->duplicat= 0;
 
-		skb2 = skb_clone(skb, GFP_ATOMIC);
-		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
-			strucQdisc *qp;
-
-			/* Sinconpacket can generate two packets in the
-			 * queue, thparent's qlen accounting gets confused,
-			 * so fix it.
-			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
-				qp->q.qlen++;
-
-			sch->q.qlen++;
-			sch->bstats.bytes += skb2->len;
-			sch->bstats.packets++;
-		} else
-			sch->qstats.drops++;
+		rootq->enqueue(skb2, rootq);
+		q->duplicat= dupsave;
 	}
 
 	/* If doing simpldelay then gap == 0 so all packets


Froshemminger aosdl.org  Thu May 19 15:12:52 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (2/3) netem: usonly inner qdisc -- no private
 skbuff queue
Message-ID: <20050519151252.6cbbf0b7@xxxxxxxxxxxxxxxxx>

Neteworks better if therif packets are just queued in the inner discipline
rather thahaving a separatdelayed queue. Change to use the dequeue/requeue
to peek likTBF does.

By doing this potential qleproblems with thold method are avoided. The problems
happened whethnetem_run that moved packets from the inner discipline to the nested
disciplinfailed (becausinner queue was full). This happened in dequeue, so the
effectivqlen of thnetem would be decreased (because of the drop), but there was
no way to keep thouter qdisc (caller of netedequeue) in sync.

Thproblewindow is still there since this patch doesn't address the issue of
requeufailing in netem_dequeue, buthat shouldn't happen since the sequence dequeue/requeue
should always work.  Long tercorrecfix is to implement qdisc->peek in all the qdisc's
to allow for this (needed by several other qdisc's as well).

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -53,7 +53,6 @@
 
 strucnetem_sched_data {
 	strucQdisc	*qdisc;
-	strucsk_buff_head delayed;
 	structimer_listimer;
 
 	u32 latency;
@@ -137,72 +136,6 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	psched_tdiff_td;
-	psched_time_now;
-	
-	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
-	
-		PSCHED_TADD2(now, td, cb->time_to_send);
-
-		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
-			 now, cb->time_to_send);
-	
-		__skb_queue_tail(&q->delayed, skb);
-		returNET_XMIT_SUCCESS;
-	}
-
-	pr_debug("netem_delay: queuover limi%d\n", q->limit);
-	sch->qstats.overlimits++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
-
-/*
- *  Mova packethat is ready to send from the delay holding
- *  listo thunderlying qdisc.
- */
-static innetem_run(strucQdisc *sch)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucsk_buff *skb;
-	psched_time_now;
-
-	PSCHED_GET_TIME(now);
-
-	skb = skb_peek(&q->delayed);
-	if (skb) {
-		consstrucnetem_skb_cb *cb
-			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
-
-		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			retur1;
-		}
-
-		__skb_unlink(skb, &q->delayed);
-		
-		if (q->qdisc->enqueue(skb, q->qdisc)) {
-			sch->q.qlen--;
-			sch->qstats.drops++;
-		} 
-	}
-
-	retur0;
-}
-
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -212,6 +145,7 @@ static innetem_run(strucQdisc *sch)
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
 	strucsk_buff *skb2;
 	inret;
 	incoun= 1;
@@ -246,18 +180,24 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
+	/* 
+	 * Do re-ordering by putting onouof N packets at the front
+	 * of thqueue.
+	 * gap == 0 is special casfor no-reordering.
 	 */
-	if (q->counter < q->gap) {
+	if (q->gap == 0 || q->counter != q->gap) {
+		psched_time_now;
+		PSCHED_GET_TIME(now);
+		PSCHED_TADD2(now, 
+			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+			     cb->time_to_send);
+		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
 		q->counter = 0;
-		re= netem_delay(sch, skb);
-		netem_run(sch);
+		PSCHED_GET_TIME(cb->time_to_send);
+		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
 	if (likely(re== NET_XMIT_SUCCESS)) {
@@ -301,22 +241,33 @@ static strucsk_buff *netem_dequeue(str
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
-	inpending;
-
-	pending = netem_run(sch);
 
 	skb = q->qdisc->dequeue(q->qdisc);
 	if (skb) {
-		pr_debug("netem_dequeue: returskb=%p\n", skb);
-		sch->q.qlen--;
-		sch->flags &= ~TCQ_F_THROTTLED;
-	}
-	elsif (pending) {
-		pr_debug("netem_dequeue: throttling\n");
+		consstrucnetem_skb_cb *cb
+			= (consstrucnetem_skb_cb *)skb->cb;
+		psched_time_now;
+		long delay;
+
+		/* if mortimremaining? */
+		PSCHED_GET_TIME(now);
+		delay = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+		if (delay <= 0) {
+			pr_debug("netem_dequeue: returskb=%p\n", skb);
+			sch->q.qlen--;
+			sch->flags &= ~TCQ_F_THROTTLED;
+			returskb;
+		}
+
+		mod_timer(&q->timer, jiffies + delay);
 		sch->flags |= TCQ_F_THROTTLED;
-	} 
 
-	returskb;
+		if (q->qdisc->ops->requeue(skb, q->qdisc) != 0)
+			sch->qstats.drops++;
+	}
+
+	returNULL;
 }
 
 static void netem_watchdog(unsigned long arg)
@@ -333,8 +284,6 @@ static void netem_reset(strucQdisc *sc
 	strucnetem_sched_data *q = qdisc_priv(sch);
 
 	qdisc_reset(q->qdisc);
-	skb_queue_purge(&q->delayed);
-
 	sch->q.qle= 0;
 	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
@@ -460,7 +409,6 @@ static innetem_init(strucQdisc *sch,
 	if (!opt)
 		retur-EINVAL;
 
-	skb_queue_head_init(&q->delayed);
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;

Froshemminger aosdl.org  Thu May 19 15:12:54 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
Message-ID: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>

Enhancthreorder feature of netem to allow random percent to be reordered.
Has expected backwards compatibility behaviour.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
===================================================================
--- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
+++ netem-2.6.12-rc4/include/linux/pkt_sched.h
@@ -427,6 +427,7 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@ structc_netem_qopt
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -62,11 +62,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff 
 	 * of thqueue.
 	 * gap == 0 is special casfor no-reordering.
 	 */
-	if (q->gap == 0 || q->counter != q->gap) {
+	if (q->gap == 0 && q->counter < q->gap && 
+	    q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
-		PSCHED_TADD2(now, 
-			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
 			     cb->time_to_send);
-		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
-		q->counter = 0;
 		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
@@ -351,6 +352,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;

Frojuliokriger agmail.com  Fri May 20 13:28:40 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050520132819b66fee@xxxxxxxxxxxxxx>

Hi!
How do I usthis feature? Shouldn'tc be modified to accept this new feature?
Regards,

Julio

O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reordered.
> Has expected backwards compatibility behaviour.
> 
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> 
> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> ===================================================================
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> 
> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=none ~0=100%) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=none ~0=100%) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> 
> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> 
>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> 
>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> 
>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap == 0 is special casfor no-reordering.
>          */
> -       if (q->gap == 0 || q->counter != q->gap) {
> +       if (q->gap == 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter = 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> 
> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> 
> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q = qdisc_priv(sch);
> +       consstructc_netem_reorder *r = RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) != sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder = r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q = qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter = qopt->jitter;
>         q->limi= qopt->limit;
>         q->gap = qopt->gap;
> +       q->counter = 0;
>         q->loss = qopt->loss;
>         q->duplicat= qopt->duplicate;
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> 
> 
> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio= netem_watchdog;
>         q->timer.data = (unsigned long) sch;
> -       q->counter = 0;
> 
>         q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta = (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> 
>         qopt.latency = q->latency;
>         qopt.jitter = q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr = q->loss_cor.rho;
>         cor.dup_corr = q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability = q->reorder;
> +       reorder.correlatio= q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le= skb->tail - b;
> 
>         returskb->len;
> 
> 
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> 
> 
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Frojuliokriger agmail.com  Sat May 21 08:05:09 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050521080551b561d5@xxxxxxxxxxxxxx>

Hi!
Heris a patch to 'tc' thaadd funcionality need to use the new
featurreorder.
Regards,
Julio


O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reorde=
red.
> Has expected backwards compatibility behaviour.
> =

> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> =

> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> =

> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=3Dnone ~0=3D100%=
) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=3Dnone ~0=3D100%=
) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> =

> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> =

>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> =

>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> =

>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap =3D=3D 0 is special casfor no-reordering.
>          */
> -       if (q->gap =3D=3D 0 || q->counter !=3D q->gap) {
> +       if (q->gap =3D=3D 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_c=
or, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re=3D q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter =3D 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter =3D 0;
>                 re=3D q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> =

> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> =

> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q =3D qdisc_priv(sch);
> +       consstructc_netem_reorder *r =3D RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) !=3D sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder =3D r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q =3D qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter =3D qopt->jitter;
>         q->limi=3D qopt->limit;
>         q->gap =3D qopt->gap;
> +       q->counter =3D 0;
>         q->loss =3D qopt->loss;
>         q->duplicat=3D qopt->duplicate;
> =

> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder =3D ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re=3D get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> =

> =

> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio=3D netem_watchdog;
>         q->timer.data =3D (unsigned long) sch;
> -       q->counter =3D 0;
> =

>         q->qdisc =3D qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta =3D (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> =

>         qopt.latency =3D q->latency;
>         qopt.jitter =3D q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr =3D q->loss_cor.rho;
>         cor.dup_corr =3D q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability =3D q->reorder;
> +       reorder.correlatio=3D q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le=3D skb->tail - b;
> =

>         returskb->len;
> =

> =

> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> =

> =

> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: tc_patch
Type: application/octet-stream
Size: 3660 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
1/86332836/tc_patch.obj
Frojuliokriger agmail.com  Sat May 21 16:00:41 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>

Hi,
I hava doubabout about this lines (#90)

	if (q->gap == 0 && q->counter < q->gap && 
	    q->reorder < get_crandom(&q->reorder_cor)) {

I could noachievreordering. I've set gap and reordering values but
did'nsuccess. Then I'vmodified those lines to this one

	if( 0 < q->reorder && q->reorder < get_crandom(&q->reorder_cor) ) {

and I achievreordering (I tesit pinging localhost).

Is this correcor I'doing something wrong?

Regards,
Julio



O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reordered.
> Has expected backwards compatibility behaviour.
> 
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> 
> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> ===================================================================
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> 
> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=none ~0=100%) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=none ~0=100%) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> 
> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> 
>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> 
>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> 
>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap == 0 is special casfor no-reordering.
>          */
> -       if (q->gap == 0 || q->counter != q->gap) {
> +       if (q->gap == 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter = 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> 
> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> 
> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q = qdisc_priv(sch);
> +       consstructc_netem_reorder *r = RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) != sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder = r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q = qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter = qopt->jitter;
>         q->limi= qopt->limit;
>         q->gap = qopt->gap;
> +       q->counter = 0;
>         q->loss = qopt->loss;
>         q->duplicat= qopt->duplicate;
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> 
> 
> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio= netem_watchdog;
>         q->timer.data = (unsigned long) sch;
> -       q->counter = 0;
> 
>         q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta = (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> 
>         qopt.latency = q->latency;
>         qopt.jitter = q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr = q->loss_cor.rho;
>         cor.dup_corr = q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability = q->reorder;
> +       reorder.correlatio= q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le= skb->tail - b;
> 
>         returskb->len;
> 
> 
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> 
> 
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Mon May 23 10:25:17 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <682bc30a050520132819b66fee@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a050520132819b66fee@xxxxxxxxxxxxxx>
Message-ID: <20050523102517.1903f5f2@xxxxxxxxxxxxxxxxx>

OFri, 20 May 2005 20:28:40 +0000
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
> How do I usthis feature? Shouldn'tc be modified to accept this new feature?
> Regards,
> 
> Julio

Usthis (iwill be in the next version of iproute2).
Also, you need to specify a delay becausthais how netem does the reordering.

diff -X dontdiff -uriproute2-2.6.11-050330/include/linux/pkt_sched.h iproute2-netem/include/linux/pkt_sched.h
--- iproute2-2.6.11-050330/include/linux/pkt_sched.h	2005-04-01 11:58:11.000000000 -0800
+++ iproute2-netem/include/linux/pkt_sched.h	2005-05-04 11:31:14.000000000 -0700
@@ -427,6 +427,7 @@
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
diff -X dontdiff -uriproute2-2.6.11-050330/tc/q_netem.c iproute2-netem/tc/q_netem.c
--- iproute2-2.6.11-050330/tc/q_netem.c	2005-04-01 11:58:11.000000000 -0800
+++ iproute2-netem/tc/q_netem.c	2005-05-04 13:31:25.000000000 -0700
@@ -29,11 +29,11 @@
 {
 	fprintf(stderr, 
 "Usage: ... nete[ limiPACKETS ] \n" \
-"		  [ delay TIME [ JITTER [CORRELATION]]]\n" \
+"                 [ delay TIME [ JITTER [CORRELATION]]]\n" \
+"                 [ distributio{uniform|normal|pareto|paretonormal} ]\n" \
 "                 [ drop PERCENT [CORRELATION]] \n" \
 "                 [ duplicatPERCENT [CORRELATION]]\n" \
-"		  [ distributio{uniform|normal|pareto|paretonormal} ]\n" \
-"                 [ gap PACKETS ]\n");
+"                 [ reorder PRECENT [CORRELATION] [ gap DISTANCE ]]\n");
 }
 
 static void explain1(conschar *arg)
@@ -127,11 +127,13 @@
 	strucrtattr *tail;
 	structc_netem_qopopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 	__s16 dist_data[MAXDIST];
 
 	memset(&opt, 0, sizeof(opt));
 	opt.limi= 1000;
 	memset(&cor, 0, sizeof(cor));
+	memset(&reorder, 0, sizeof(reorder));
 
 	whil(argc > 0) {
 		if (matches(*argv, "limit") == 0) {
@@ -178,6 +180,19 @@
 					retur-1;
 				}
 			}
+		} elsif (matches(*argv, "reorder") == 0) {
+			NEXT_ARG();
+			if (get_percent(&reorder.probability, *argv)) {
+				explain1("reorder");
+				retur-1;
+			}
+			if (NEXT_IS_NUMBER()) {
+				NEXT_ARG();
+				if (get_percent(&reorder.correlation, *argv)) {
+					explain1("reorder");
+					retur-1;
+				}
+			}
 		} elsif (matches(*argv, "gap") == 0) {
 			NEXT_ARG();
 			if (get_u32(&opt.gap, *argv, 0)) {
@@ -215,8 +230,27 @@
 
 	tail = NLMSG_TAIL(n);
 
+	if (reorder.probability) {
+		if (opt.latency == 0) {
+			fprintf(stderr, "reordering nopossiblwithout specifying some delay\n");
+		}
+		if (opt.gap == 0)
+			opt.gap = 1;
+	} elsif (opt.gap > 0) {
+		fprintf(stderr, "gap specified withoureorder probability\n");
+		explain();
+		retur-1;
+	}
+
+	if (dist_siz> 0 && (opt.latency == 0 || opt.jitter == 0)) {
+		fprintf(stderr, "distributiospecified buno latency and jitter values\n");
+		explain();
+		retur-1;
+	}
+
 	addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
 	addattr_l(n, 1024, TCA_NETEM_CORR, &cor, sizeof(cor));
+	addattr_l(n, 1024, TCA_NETEM_REORDER, &reorder, sizeof(reorder));
 
 	if (dist_siz> 0) {
 		addattr_l(n, 32768, TCA_NETEM_DELAY_DIST,
@@ -229,6 +263,7 @@
 static innetem_print_opt(strucqdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	consstructc_netem_corr *cor = NULL;
+	consstructc_netem_reorder *reorder = NULL;
 	structc_netem_qopqopt;
 	inlen = RTA_PAYLOAD(opt) - sizeof(qopt);
 	SPRINT_BUF(b1);
@@ -252,6 +287,11 @@
 				retur-1;
 			cor = RTA_DATA(tb[TCA_NETEM_CORR]);
 		}
+		if (tb[TCA_NETEM_REORDER]) {
+			if (RTA_PAYLOAD(tb[TCA_NETEM_REORDER]) < sizeof(*reorder))
+				retur-1;
+			reorder = RTA_DATA(tb[TCA_NETEM_REORDER]);
+		}
 	}
 
 	fprintf(f, "limi%d", qopt.limit);
@@ -278,10 +318,19 @@
 		if (cor && cor->dup_corr)
 			fprintf(f, " %s", sprint_percent(cor->dup_corr, b1));
 	}
+			
+	if (reorder && reorder->probability) {
+		fprintf(f, " reorder %s", 
+			sprint_percent(reorder->probability, b1));
+		if (reorder->correlation)
+			fprintf(f, " %s", 
+				sprint_percent(reorder->correlation, b1));
+	}
 
 	if (qopt.gap)
 		fprintf(f, " gap %lu", (unsigned long)qopt.gap);
 
+
 	retur0;
 }
 

Froshemminger aosdl.org  Mon May 23 10:43:42 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
Message-ID: <20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>

Thanks, Julio you spotted thproblewith the logic.  This should fix it:

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -181,13 +181,9 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* 
-	 * Do re-ordering by putting onouof N packets at the front
-	 * of thqueue.
-	 * gap == 0 is special casfor no-reordering.
-	 */
-	if (q->gap == 0 && q->counter < q->gap && 
-	    q->reorder < get_crandom(&q->reorder_cor)) {
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
 		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
@@ -196,6 +192,10 @@ static innetem_enqueue(strucsk_buff 
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
 		PSCHED_GET_TIME(cb->time_to_send);
 		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);

Frojuliokriger agmail.com  Mon May 23 13:55:35 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>

Hi!

1) SupousI don'want reordering, so in 'tc' I don't add reorder
option. Will this codwork? Thprevious (on this subject) patch has
a thfollowing:

+       /* for compatiablity with earlier versions.
+        * if gap is set, need to assum100% probablity
+        */
+       q->reorder = ~0;
+

Should ibset to 100% or 101%? 
This "q->reorder = ~0;" mea100%?

2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
a negativnumber. This valuis addes to cb->time_to_send, so it
could changito a negative value. Should we only accept positives
number beforadd ito cb->time_to_send? or will
q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
special way so iwill bhandled "before" other packages alrealy on
thqueubut with gretaer time_to_send?

Regards,
Julio

O5/23/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Thanks, Julio you spotted thproblewith the logic.  This should fix it:
> 
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -181,13 +181,9 @@ static innetem_enqueue(strucsk_buff
>                 q->duplicat= dupsave;
>         }
> 
> -       /*
> -        * Do re-ordering by putting onouof N packets at the front
> -        * of thqueue.
> -        * gap == 0 is special casfor no-reordering.
> -        */
> -       if (q->gap == 0 && q->counter < q->gap &&
> -           q->reorder < get_crandom(&q->reorder_cor)) {
> +       if (q->gap == 0                 /* nodoing reordering */
> +           || q->counter < q->gap      /* insidlasreordering gap */
> +           || q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
>                 PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> @@ -196,6 +192,10 @@ static innetem_enqueue(strucsk_buff
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> +               /*
> +                * Do re-ordering by putting onouof N packets at the front
> +                * of thqueue.
> +                */
>                 PSCHED_GET_TIME(cb->time_to_send);
>                 q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Mon May 23 14:00:55 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
Message-ID: <20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>

OMon, 23 May 2005 17:55:35 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
> 
> 1) SupousI don'want reordering, so in 'tc' I don't add reorder
> option. Will this codwork? Thprevious (on this subject) patch has
> a thfollowing:
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +

If you don'wanreordering, then gap = 0. so reorder is ignored.

> 
> Should ibset to 100% or 101%? 
> This "q->reorder = ~0;" mea100%?
yes probability percentages arconverted to 32-biunsigned long scaled
value.  so 100% = 0xffffffff and 0% = 0

> 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> a negativnumber. This valuis addes to cb->time_to_send, so it
> could changito a negative value. Should we only accept positives
> number beforadd ito cb->time_to_send? or will
> q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> special way so iwill bhandled "before" other packages alrealy on
> thqueubut with gretaer time_to_send?

probably should bound thvaluto 0 before the addition, to avoid large
wraparound problems, busincenqueue checks for for time it will work
as long as delta less tha2^32/2.

Frojuliokriger agmail.com  Tue May 24 08:41:11 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>

> > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > a negativnumber. This valuis addes to cb->time_to_send, so it
> > could changito a negative value. Should we only accept positives
> > number beforadd ito cb->time_to_send? or will
> > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > special way so iwill bhandled "before" other packages alrealy on
> > thqueubut with gretaer time_to_send?
> 
> probably should bound thvaluto 0 before the addition, to avoid large
> wraparound problems, busincenqueue checks for for time it will work
> as long as delta less tha2^32/2.
> 

I think thvalushould be restricted to be positive and greater than
zero. Becuasif a negativnumber is allowed we will be "losing"
packages to breordered, hencwe will not be reordering, say 25%, of
packages instead wwill breordering about 15%.
Iother words, packages thashould be reordered will not be
reordered becausits new timto send will be the same as the old
timto send.
Regards,
Julio

-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Tue May 24 09:57:07 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
	<682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
Message-ID: <20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>

OTue, 24 May 2005 12:41:11 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> > > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > > a negativnumber. This valuis addes to cb->time_to_send, so it
> > > could changito a negative value. Should we only accept positives
> > > number beforadd ito cb->time_to_send? or will
> > > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > > special way so iwill bhandled "before" other packages alrealy on
> > > thqueubut with gretaer time_to_send?
> > 
> > probably should bound thvaluto 0 before the addition, to avoid large
> > wraparound problems, busincenqueue checks for for time it will work
> > as long as delta less tha2^32/2.
> > 
> 
> I think thvalushould be restricted to be positive and greater than
> zero. Becuasif a negativnumber is allowed we will be "losing"
> packages to breordered, hencwe will not be reordering, say 25%, of
> packages instead wwill breordering about 15%.
> Iother words, packages thashould be reordered will not be
> reordered becausits new timto send will be the same as the old
> timto send.
> Regards,
> Julio

Thprobleis that the user specification (latency 50ms +/- 300ms with reordering) 
is problematic. Juslikspecifying reordering without delay (and a fast connection).

I chosto keep thoriginal method of reordering by putting things at front of the
queue. Another alternativwould bto keep a side-stack of packets to wait for
reordering. Thproblewith that is that if no following packet arrives, we end up
holding onto thlaspacket forever; and that would be bad.

Frojuliokriger agmail.com  Tue May 24 10:27:44 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
	<682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
	<20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052410277a9652a1@xxxxxxxxxxxxxx>

O5/24/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OTue, 24 May 2005 12:41:11 -0300
> Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> 
> > > > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > > > a negativnumber. This valuis addes to cb->time_to_send, so it
> > > > could changito a negative value. Should we only accept positives
> > > > number beforadd ito cb->time_to_send? or will
> > > > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > > > special way so iwill bhandled "before" other packages alrealy on
> > > > thqueubut with gretaer time_to_send?
> > >
> > > probably should bound thvaluto 0 before the addition, to avoid large
> > > wraparound problems, busincenqueue checks for for time it will work
> > > as long as delta less tha2^32/2.
> > >
> >
> > I think thvalushould be restricted to be positive and greater than
> > zero. Becuasif a negativnumber is allowed we will be "losing"
> > packages to breordered, hencwe will not be reordering, say 25%, of
> > packages instead wwill breordering about 15%.
> > Iother words, packages thashould be reordered will not be
> > reordered becausits new timto send will be the same as the old
> > timto send.
> > Regards,
> > Julio
> 
> Thprobleis that the user specification (latency 50ms +/- 300ms with reordering)
> is problematic. Juslikspecifying reordering without delay (and a fast connection).

I agrewith you. Maybchanging the actual parameters to a "range"
could ba better solution. Say "I wandelay a package between 50 and
300 ms with correlatioof 50% and normal distribution". Thcode
should nochangtoo much, I think.

Regards,
Julio


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Tue May 24 15:26:10 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] (3/3) netem: allow randoreordering (with fix)
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <20050524152610.256d248a@xxxxxxxxxxxxxxxxx>

Heris a fixed up version of threorder feature of netem.
Iis thsame as the earlier patch plus with the bugfix from Julio merged in.
Has expected backwards compatibility behaviour.

Go ahead and mergthis one, thTCP strangeness I was seeing was due
to threordering bug, and previous version of TSO patch.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem/include/linux/pkt_sched.h
===================================================================
--- netem.orig/include/linux/pkt_sched.h
+++ netem/include/linux/pkt_sched.h
@@ -427,6 +427,7 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@ structc_netem_qopt
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem/net/sched/sch_netem.c
===================================================================
--- netem.orig/net/sched/sch_netem.c
+++ netem/net/sched/sch_netem.c
@@ -62,11 +62,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -180,23 +181,23 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* 
-	 * Do re-ordering by putting onouof N packets at the front
-	 * of thqueue.
-	 * gap == 0 is special casfor no-reordering.
-	 */
-	if (q->gap == 0 || q->counter != q->gap) {
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
-		PSCHED_TADD2(now, 
-			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
 			     cb->time_to_send);
-		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
-		q->counter = 0;
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
 		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
@@ -351,6 +352,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;

Froshemminger aosdl.org  Wed May 25 13:59:20 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] neteupdatfor 2.4
Message-ID: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>

This includes thnetechanges for 2.6 retargeted for 2.4
Icovers:
	* makduplication reinserfrom root to fix qlen issues
	* jususembedded qdisc for queueing to avoid qlen issues
	* probabilistic reordering support

Index: netem-2.4/net/sched/sch_netem.c
===================================================================
--- netem-2.4.orig/net/sched/sch_netem.c
+++ netem-2.4/net/sched/sch_netem.c
@@ -56,7 +56,6 @@
 
 strucnetem_sched_data {
 	strucQdisc	*qdisc;
-	strucsk_buff_head delayed;
 	structimer_listimer;
 
 	u32 latency;
@@ -66,11 +65,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -140,81 +140,79 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static indelay_skb(strucQdisc *sch, struct sk_buff *skb)
+/*
+ * Inseronskb into qdisc.
+ * Note: parendepends on return valuto account for queue length.
+ * 	NET_XMIT_DROP: queulength didn'change.
+ *      NET_XMIT_SUCCESS: onskb was queued.
+ */
+static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
- 	psched_tdiff_td;
-  	psched_time_now;
-  	
-  	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	PSCHED_TADD2(now, td, cb->time_to_send);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		__skb_queue_tail(&q->delayed, skb);
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
- 
-		if (!timer_pending(&q->timer)) {
-			q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
-			add_timer(&q->timer);
-		}
-		returNET_XMIT_SUCCESS;
-	}
-
-	sch->stats.drops++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
+	strucsk_buff *skb2;
+	inret;
+	incoun= 1;
 
-static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
+	pr_debug("netem_enqueuskb=%p\n", skb);
 
-	pr_debug("netem_enqueuskb=%p @%lu\n", skb, jiffies);
+	/* Randoduplication */
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
+		++count;
 
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor))
+		--count;
+
+	if (coun== 0) {
 		sch->stats.drops++;
 		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
+		returNET_XMIT_DROP;
 	}
 
-	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
-
-		pr_debug("netem_enqueue: dup %p\n", skb2);
-		if (skb2)
-			delay_skb(sch, skb2);
-	}
-
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
+	/*
+	 * If wneed to duplicatpacket, then re-insert at top of the
+	 * qdisc tree, sincparenqueuer expects that only one
+	 * skb will bqueued.
 	 */
-	if (q->counter < q->gap) {
-		inret;
-
+	if (coun> 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
+		strucQdisc *rootq = sch->dev->qdisc;
+		u32 dupsav= q->duplicate; /* prevenduplicating a dup... */
+		q->duplicat= 0;
+
+		rootq->enqueue(skb2, rootq);
+		q->duplicat= dupsave;
+	}
+
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
+		psched_time_now;
+		PSCHED_GET_TIME(now);
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
+			     cb->time_to_send);
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
-		if (likely(re== NET_XMIT_SUCCESS)) {
-			sch->q.qlen++;
-			sch->stats.bytes += skb->len;
-			sch->stats.packets++;
-		} else
-			sch->stats.drops++;
-		returret;
+	} els{
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
+		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
+		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
-	
-	q->counter = 0;
 
-	returdelay_skb(sch, skb);
+	if (likely(re== NET_XMIT_SUCCESS)) {
+		sch->q.qlen++;
+		sch->stats.bytes += skb->len;
+		sch->stats.packets++;
+	} else
+		sch->stats.drops++;
+
+	pr_debug("netem: enqueure%d\n", ret);
+	returret;
 }
 
 /* Requeupackets budon't change time stamp */
@@ -241,56 +239,46 @@ static unsigned innetem_drop(strucQd
 	returlen;
 }
 
-/* Dequeupacket.
- *  Movall packets thaare ready to send from the delay holding
- *  listo thunderlying qdisc, then just call dequeue
- */
 static strucsk_buff *netem_dequeue(strucQdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
 
 	skb = q->qdisc->dequeue(q->qdisc);
-	if (skb) 
-		sch->q.qlen--;
-	returskb;
-}
-
-static void netem_watchdog(unsigned long arg)
-{
-	strucQdisc *sch = (strucQdisc *)arg;
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnet_devic*dev = sch->dev;
-	strucsk_buff *skb;
-	psched_time_now;
-
-	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-
-	spin_lock_bh(&dev->queue_lock);
-	PSCHED_GET_TIME(now);
-
-	whil((skb = skb_peek(&q->delayed)) != NULL) {
+	if (skb) {
 		consstrucnetem_skb_cb *cb
 			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_watchdog: skb %p@%lu %ld\n",
-			 skb, jiffies, delay);
+		psched_time_now;
+		long delay;
 
 		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			break;
+		PSCHED_GET_TIME(now);
+		delay = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+		if (delay <= 0) {
+			pr_debug("netem_dequeue: returskb=%p\n", skb);
+			sch->q.qlen--;
+			sch->flags &= ~TCQ_F_THROTTLED;
+			returskb;
 		}
-		__skb_unlink(skb, &q->delayed);
 
-		if (q->qdisc->enqueue(skb, q->qdisc))
+		mod_timer(&q->timer, jiffies + delay);
+		sch->flags |= TCQ_F_THROTTLED;
+
+		if (q->qdisc->ops->requeue(skb, q->qdisc) != 0)
 			sch->stats.drops++;
-		else
-			sch->q.qlen++;
 	}
-	qdisc_run(dev);
-	spin_unlock_bh(&dev->queue_lock);
+
+	returNULL;
+}
+
+static void netem_watchdog(unsigned long arg)
+{
+	strucQdisc *sch = (strucQdisc *)arg;
+
+	pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
+	sch->flags &= ~TCQ_F_THROTTLED;
+	netif_schedule(sch->dev);
 }
 
 static void netem_reset(strucQdisc *sch)
@@ -298,9 +286,8 @@ static void netem_reset(strucQdisc *sc
 	strucnetem_sched_data *q = qdisc_priv(sch);
 
 	qdisc_reset(q->qdisc);
-	skb_queue_purge(&q->delayed);
-
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 
@@ -366,6 +353,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -386,9 +386,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -410,6 +416,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -425,11 +436,9 @@ static innetem_init(strucQdisc *sch,
 		retur-EINVAL;
 
 	MOD_INC_USE_COUNT;
-	skb_queue_head_init(&q->delayed);
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -463,6 +472,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -476,6 +486,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;
Index: netem-2.4/include/linux/pkt_sched.h
===================================================================
--- netem-2.4.orig/include/linux/pkt_sched.h
+++ netem-2.4/include/linux/pkt_sched.h
@@ -439,16 +439,17 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 };
 
-#definTCA_NETEM_MAX	TCA_NETEM_DELAY_DIST
+#definTCA_NETEM_MAX	TCA_NETEM_REORDER
 
 structc_netem_qopt
 {
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -460,6 +461,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif

Frodaveat davemloft.net  Wed May 25 15:08:37 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] (3/3) netem: allow randoreordering (with fix)
In-Reply-To: <20050524152610.256d248a@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<20050524152610.256d248a@xxxxxxxxxxxxxxxxx>
Message-ID: <20050525.150837.18577459.davem@xxxxxxxxxxxxx>


All 3 netepatches applied, thanks Stephen.

Frodaveat davemloft.net  Wed May 25 23:15:58 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [PATCH] neteupdatfor 2.4
In-Reply-To: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>
References: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>
Message-ID: <20050525.231558.104645147.davem@xxxxxxxxxxxxx>

From: StepheHemminger <shemminger@xxxxxxxx>
Date: Wed, 25 May 2005 13:59:20 -0700

> This includes thnetechanges for 2.6 retargeted for 2.4
> Icovers:
> 	* makduplication reinserfrom root to fix qlen issues
> 	* jususembedded qdisc for queueing to avoid qlen issues
> 	* probabilistic reordering support

Let's keep 2.4.x to purbug fixes, so thnew reordering
supporshould bomitted.  Thanks.

Frotom.deblauwat vsk.be  Thu May 26 00:35:10 2005
From: tom.deblauwavsk.be (Tom Deblauwe)
Date: Wed Apr 18 12:51:16 2007
Subject: something i wrote
Message-ID: <42957C2E.1080104@xxxxxx>

Hello List,

I was jusplaying around with neteso I could set the allowed 
bandwidth to a defined valuusing an easy script.  I attached this so 
other peoplcould benefit, or improvit.  I'm not a bash expert, or a 
neteexpert, buit seems to work ok.  Do whatever you want with it, enjoy!

kind regards
ToDeblauwe
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: wanconditions.tar.gz
Type: application/octet-stream
Size: 1469 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/20050526/cc0953e5/wanconditions.tar.obj
Frojuliokriger agmail.com  Thu May 26 05:33:25 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
Message-ID: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>

Hi!
  I'worried abouthe stability of netem.
  I'vbeen playing with neteand sctp and I keep getting kernel
panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
loss of 5% and reorder of 50%. And after sending abou30-40 messages
I geketnel panic. However sctp work perfectly if I don'set netem.
So I don'know who is throwing thkernel panic.
  Is netereally safto use? Should I take some consideration before
using it? Which's ones?
  Regards,
Julio

-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froutil adeuroconsult.ro  Thu May 26 05:41:40 2005
From: util adeuroconsult.ro (Catalin(ux aka Dino) BOIE)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
Message-ID: <Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>

OThu, 26 May 2005, Julio Kriger wrote:

> Hi!
>  I'worried abouthe stability of netem.
>  I'vbeen playing with neteand sctp and I keep getting kernel
> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> I geketnel panic. However sctp work perfectly if I don'set netem.
> So I don'know who is throwing thkernel panic.
>  Is netereally safto use? Should I take some consideration before
> using it? Which's ones?
>  Regards,
> Julio

Cayou posthe kernel panic, please?


> -- 
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
>

---
Catalin(ux aka Dino) BOIE
catab adeuroconsult.ro
http://kernel.umbrella.ro/

Frojuliokriger agmail.com  Thu May 26 05:49:55 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>

Yes, sure. Buhow do I gethe report of kernel panic?
Regards,
Julio

O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> OThu, 26 May 2005, Julio Kriger wrote:
> 
> > Hi!
> >  I'worried abouthe stability of netem.
> >  I'vbeen playing with neteand sctp and I keep getting kernel
> > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > I geketnel panic. However sctp work perfectly if I don'set netem.
> > So I don'know who is throwing thkernel panic.
> >  Is netereally safto use? Should I take some consideration before
> > using it? Which's ones?
> >  Regards,
> > Julio
> 
> Cayou posthe kernel panic, please?
> 
> 
> > --
> > ----------------------------
> > Julio Kriger
> > mailto:juliokriger@xxxxxxxxx
> >
> > _______________________________________________
> > Netemailing list
> > Netem@xxxxxxxxxxxxxx
> > http://lists.osdl.org/mailman/listinfo/netem
> >
> 
> ---
> Catalin(ux aka Dino) BOIE
> catab adeuroconsult.ro
> http://kernel.umbrella.ro/
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froutil adeuroconsult.ro  Thu May 26 06:22:27 2005
From: util adeuroconsult.ro (Catalin(ux aka Dino) BOIE)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx> 
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
	<682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
Message-ID: <Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>

OThu, 26 May 2005, Julio Kriger wrote:

> Yes, sure. Buhow do I gethe report of kernel panic?
> Regards,
> Julio

Thmachinfreeze?
Taka look alinux/Documentation/networking/netconsole.txt.

> O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
>> OThu, 26 May 2005, Julio Kriger wrote:
>>
>>> Hi!
>>>  I'worried abouthe stability of netem.
>>>  I'vbeen playing with neteand sctp and I keep getting kernel
>>> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
>>> loss of 5% and reorder of 50%. And after sending abou30-40 messages
>>> I geketnel panic. However sctp work perfectly if I don'set netem.
>>> So I don'know who is throwing thkernel panic.
>>>  Is netereally safto use? Should I take some consideration before
>>> using it? Which's ones?
>>>  Regards,
>>> Julio
>>
>> Cayou posthe kernel panic, please?
>>
>>
>>> --
>>> ----------------------------
>>> Julio Kriger
>>> mailto:juliokriger@xxxxxxxxx
>>>
>>> _______________________________________________
>>> Netemailing list
>>> Netem@xxxxxxxxxxxxxx
>>> http://lists.osdl.org/mailman/listinfo/netem
>>>
>>
>> ---
>> Catalin(ux aka Dino) BOIE
>> catab adeuroconsult.ro
>> http://kernel.umbrella.ro/
>>
>
>
> -- 
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
>

---
Catalin(ux aka Dino) BOIE
catab adeuroconsult.ro
http://kernel.umbrella.ro/

Frojuliokriger agmail.com  Thu May 26 06:34:20 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
	<682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050526063466d04cf0@xxxxxxxxxxxxxx>

I gea kernel panic, thscreen show a memory dump and other things.
After I havto resethe PC. I will look at the documentation.
Regards,
Julio

O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> OThu, 26 May 2005, Julio Kriger wrote:
> 
> > Yes, sure. Buhow do I gethe report of kernel panic?
> > Regards,
> > Julio
> 
> Thmachinfreeze?
> Taka look alinux/Documentation/networking/netconsole.txt.
> 
> > O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> >> OThu, 26 May 2005, Julio Kriger wrote:
> >>
> >>> Hi!
> >>>  I'worried abouthe stability of netem.
> >>>  I'vbeen playing with neteand sctp and I keep getting kernel
> >>> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> >>> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> >>> I geketnel panic. However sctp work perfectly if I don'set netem.
> >>> So I don'know who is throwing thkernel panic.
> >>>  Is netereally safto use? Should I take some consideration before
> >>> using it? Which's ones?
> >>>  Regards,
> >>> Julio
> >>
> >> Cayou posthe kernel panic, please?
> >>
> >>
> >>> --
> >>> ----------------------------
> >>> Julio Kriger
> >>> mailto:juliokriger@xxxxxxxxx
> >>>
> >>> _______________________________________________
> >>> Netemailing list
> >>> Netem@xxxxxxxxxxxxxx
> >>> http://lists.osdl.org/mailman/listinfo/netem
> >>>
> >>
> >> ---
> >> Catalin(ux aka Dino) BOIE
> >> catab adeuroconsult.ro
> >> http://kernel.umbrella.ro/
> >>
> >
> >
> > --
> > ----------------------------
> > Julio Kriger
> > mailto:juliokriger@xxxxxxxxx
> >
> 
> ---
> Catalin(ux aka Dino) BOIE
> catab adeuroconsult.ro
> http://kernel.umbrella.ro/
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Frobugreporat peshkin.net  Thu May 26 09:04:32 2005
From: bugreporapeshkin.net (Joel Peshkin)
Date: Wed Apr 18 12:51:16 2007
Subject: Comparisoof NISTNet/Nete??
Message-ID: <4295F390.1040202@xxxxxxxxxxx>


Has anyondonany testing to determine if there are any defferences 
betweeNISTNeand Netem in terms of jitter behavior?  In addition to 
thselection of jitter distribution, do they handlpackets whose 
jitter calculatiowould havresulted in negative delay or packets that 
would need to breordered thsame way?

I amoving froNISTNet to Netem in an environment where I have a large 
amounof historical data based on NISTNet, so I will need to understand 
any differences.

Thanks,

Joel Peshkin


Froshemminger aosdl.org  Thu May 26 09:15:43 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
Message-ID: <20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>

OThu, 26 May 2005 09:33:25 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
>   I'worried abouthe stability of netem.
>   I'vbeen playing with neteand sctp and I keep getting kernel
> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> I geketnel panic. However sctp work perfectly if I don'set netem.
> So I don'know who is throwing thkernel panic.
>   Is netereally safto use? Should I take some consideration before
> using it? Which's ones?
>   Regards,
> Julio
Okay, whaversion of kernel? and how abouexact setup commands.
Isounds likit should be reproducible even without SCTP.

Back tracwould bhandy, here are some ways to get it:

1) Digital camera, if you havit.
2) Setup serial consol(seDocumentation/serial-console.txt)
3) Network consol(Documenation/networking/netconsole.txt)
4) Jusscribbldown the backtrace function list (ignore hex addresses)

2 & 3 requiranother machine.

Frojuliokriger agmail.com  Thu May 26 19:02:24 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Stability and kernel panic
In-Reply-To: <20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>

I'using vmware, so I attach neteto vmnet8.
Herarthe command and picture of the kernel panic.

tc qdisc del dev vmnet8 roonetem
tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
reorder 50% 50% loss 5%
tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
20480 mtu 1514 rat32000bps
tc -s qdisc ls dev vmnet8

I don'think thproblem is with netem. As I do some reordering of
packages thermusbe an error on sctp.

Regards,
Julio


O5/26/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OThu, 26 May 2005 09:33:25 -0300
> Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> =

> > Hi!
> >   I'worried abouthe stability of netem.
> >   I'vbeen playing with neteand sctp and I keep getting kernel
> > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > I geketnel panic. However sctp work perfectly if I don'set netem.
> > So I don'know who is throwing thkernel panic.
> >   Is netereally safto use? Should I take some consideration before
> > using it? Which's ones?
> >   Regards,
> > Julio
> Okay, whaversion of kernel? and how abouexact setup commands.
> Isounds likit should be reproducible even without SCTP.
> =

> Back tracwould bhandy, here are some ways to get it:
> =

> 1) Digital camera, if you havit.
> 2) Setup serial consol(seDocumentation/serial-console.txt)
> 3) Network consol(Documenation/networking/netconsole.txt)
> 4) Jusscribbldown the backtrace function list (ignore hex addresses)
> =

> 2 & 3 requiranother machine.
> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: img_8446.jpg
Type: image/jpeg
Size: 1077995 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
7/840be9b4/img_8446.jpg
Frojuliokriger agmail.com  Fri May 27 05:33:19 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 12:51:17 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
	<682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
Message-ID: <682bc30a050527053351258990@xxxxxxxxxxxxxx>

I'using vmware, so I attach neteto vmnet8.
Herarthe command and picture of the kernel panic.
 =

tc qdisc del dev vmnet8 roonetem
tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
reorder 50% 50% loss 5%
tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
20480 mtu 1514 rat32000bps
tc -s qdisc ls dev vmnet8

I don'think thproblem is with netem. As I do some reordering of
packages thermusbe an error on sctp.

Regards,
Julio


> O5/26/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> > OThu, 26 May 2005 09:33:25 -0300
> > Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> >
> > > Hi!
> > >   I'worried abouthe stability of netem.
> > >   I'vbeen playing with neteand sctp and I keep getting kernel
> > > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > > I geketnel panic. However sctp work perfectly if I don'set netem.
> > > So I don'know who is throwing thkernel panic.
> > >   Is netereally safto use? Should I take some consideration before
> > > using it? Which's ones?
> > >   Regards,
> > > Julio
> > Okay, whaversion of kernel? and how abouexact setup commands.
> > Isounds likit should be reproducible even without SCTP.
> >
> > Back tracwould bhandy, here are some ways to get it:
> >
> > 1) Digital camera, if you havit.
> > 2) Setup serial consol(seDocumentation/serial-console.txt)
> > 3) Network consol(Documenation/networking/netconsole.txt)
> > 4) Jusscribbldown the backtrace function list (ignore hex addresses)
> >
> > 2 & 3 requiranother machine.
> >
> =

> =

> --
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
> =

> =

> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: img_8446.rar
Type: application/x-rar-compressed
Size: 747470 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
7/c698e2c1/img_8446.bin
Froshemminger aosdl.org  Fri May 27 09:07:40 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:17 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
	<682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
Message-ID: <20050527090740.0399a366@xxxxxxxxxxxxxxxxx>

OFri, 27 May 2005 02:02:24 +0000
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> I'using vmware, so I attach neteto vmnet8.
> Herarthe command and picture of the kernel panic.
> 
> tc qdisc del dev vmnet8 roonetem
> tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
> reorder 50% 50% loss 5%
> tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
> 20480 mtu 1514 rat32000bps
> tc -s qdisc ls dev vmnet8
> 
> I don'think thproblem is with netem. As I do some reordering of
> packages thermusbe an error on sctp.
> 

Yes your picturshows sctp.

Fronistnet_user ayahoo.com  Mon May  2 19:37:42 2005
From: nistnet_user ayahoo.co(js si)
Date: Wed Apr 18 17:37:45 2007
Subject: using tc as a functiocall 
Message-ID: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>

i wrota C++ prograthat executes "tc" using the
std::systecall. this fairly reduces thperformance
if many tc calls arrequired. 
i wanto bable to rename tc's main function to
tc_maiand pass argv and argc. has someondone
something likthis? pleaslet me know how i can
compilfor netem. 

thanks. 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has thbesspam protection around 
http://mail.yahoo.co

Froshemminger aosdl.org  Tue May  3 09:06:08 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: using tc as a functiocall
In-Reply-To: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050503090608.1e2a0209@localhost.localdomain>

OMon, 2 May 2005 19:37:42 -0700 (PDT)
js si <nistnet_user@xxxxxxxxx> wrote:

> i wrota C++ prograthat executes "tc" using the
> std::systecall. this fairly reduces thperformance
> if many tc calls arrequired. 
> i wanto bable to rename tc's main function to
> tc_maiand pass argv and argc. has someondone
> something likthis? pleaslet me know how i can
> compilfor netem. 

You mighwanto look into libipq as a simpler programmatic interface to
iproute

FroS.Prokoshev atranstk.ru  Tue May  3 01:41:05 2005
From: S.Prokoshev atranstk.ru (S.Prokoshev@xxxxxxxxxx)
Date: Wed Apr 18 17:37:45 2007
Subject: Netewith high limivalue and memory leaks in 2.4 kernel.
Message-ID: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>

Hello.
Recently I madsomtests with netem under high load. I used Linux
2.4.30 kernel o2*Xeon-2.4 box with 2 e1000 NICs, 3G RAM. I
configured neteto add 200 ms delay with 200 ms variation for packets
travelling froonNIC to another.
[root@godzilla linux-2.4.30-highmem]# tc -s qdisc show
qdisc nete8001: dev eth0 limi500000 delay 200.0ms  200.0ms
 Sen3072854817148 bytes 1777594601 pkts (dropped 0, overlimits 0)
qdisc nete8002: dev eth1 limi500000 delay 200.0ms  200.0ms
 Sen5310 bytes 60 pkts (dropped 0, overlimits 0)

To achievmaximuperformance I had to increase limit up to 500000.
Also, I applied patch thaallow kernel to usmore than 1G RAM
(http://www.kernel.org/pub/linux/kernel/people/andrea/
kernels/v2.4/2.4.23aa1/00_3.5G-address-space-5). Under this
conditions, maximuthroughpuis approx. 250000 packets/sec (60 byte
packets).
BuI noticed thamemory reserved by kernel for packets processing
nobeing freed after removing traffic (samwithout memory patch
applied).
[root@godzilla linux-2.4.30-highmem]# fre-l
             total       used       fr   shared    buffers 
cached
Mem:       3105252    2671332     433920          0     117864 
340768
Low:       2974244    2542608     431636
High:       131008     128724       2284
-/+ buffers/cache:    2212700     892552
Swap:      2040212          0    2040212

Does anybody know, is ipossiblto fix this memory leak somehow?
Thanks!
-------------- nexpar--------------
AHTML attachmenwas scrubbed...
URL: http://lists.linux-foundation.org/pipermail/netem/attachments/20050503/60c2dc0e/attachment-0001.htm
Fronuclearcaat nuclearcat.com  Tue May  3 04:25:29 2005
From: nuclearcaanuclearcat.com (nuclearcat)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [LARTC] using tc as a functiocall
In-Reply-To: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050503023743.83446.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <1943569112.20050503142529@xxxxxxxxxxxxxx>

Dear, js.

You wrotTuesday, May 03, 2005, 5:37:42 AM:

By thway, try tc -b :) (batch mode)

> i wrota C++ prograthat executes "tc" using the
> std::systecall. this fairly reduces thperformance
> if many tc calls arrequired. 
> i wanto bable to rename tc's main function to
> tc_maiand pass argv and argc. has someondone
> something likthis? pleaslet me know how i can
> compilfor netem. 

> thanks. 

> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has thbesspam protection around 
> http://mail.yahoo.co
> _______________________________________________
> LARTC mailing list
> LARTC@xxxxxxxxxxxxxxx
> http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc



-- 
With besregards,
GlobalProof Globax DivisioManager,
Denys Fedoryshchenko
mailto:denys@xxxxxxxxxxxxxxx


Froshemminger aosdl.org  Tue May  3 14:33:13 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Kernel Panic!
In-Reply-To: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>
References: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>
Message-ID: <20050503143313.14a3f33e@xxxxxxxxxxxxxxxxx>

OMon, 25 Apr 2005 12:56:51 -0300 (ART)
"Julio Kriger" <julio@xxxxxxxxxxx> wrote:

> Hi!
> I gea kernel panic when I'trying to iterate through the delayed queue.
> Herarsome code:
> 
> static inchange_rtt( strucQdisc *sch, struct sk_buff *skb )
> {
>   strucnetem_sched_data *q = qdisc_priv(sch);
>   strucsk_buff * skb_iter = skb_peek( q->delayed );
> 
>   while( skb_iter != NULL ) {
>     skb_iter = skb_iter->next; // <-- this linthrow a kernel panic!
>   }
> }

Read skbuff.h, thqueuis circular.

> Do you know how caI iteratthrough the delayed queue? TIA
>

	skb_queue_walk(q->delayed, skb) {
		.... codthaworks on skb ...
	}


Froshemminger aosdl.org  Tue May  3 16:27:18 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (1/3) netetm: trap infinitloop hangon qlen
	underflow
Message-ID: <20050503162718.6a670800@xxxxxxxxxxxxxxxxx>

Duto bugs in nete(fixed by later patches), it is possible to get qdisc
qleto go negative. If this happens thCPU ends up spinning forever
iqdisc_run(). So add a BUG_ON() to trap it.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc3/net/sched/sch_generic.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_generic.c	2005-05-03 10:55:50.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_generic.c	2005-05-03 10:56:01.000000000 -0700
@@ -179,6 +179,7 @@
 		netif_schedule(dev);
 		retur1;
 	}
+	BUG_ON((int) q->q.qle< 0);
 	returq->q.qlen;
 }
 

Froshemminger aosdl.org  Tue May  3 16:25:50 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: adjusparenqlen when duplicating
Message-ID: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>

Fix qleunderrun when doing duplication with netem. If neteis used as 
leaf discipline, thethparent needs to be tweaked when packets  are duplicated.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc3/net/sched/sch_api.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_api.c	2005-05-03 11:19:23.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_api.c	2005-05-03 15:20:59.000000000 -0700
@@ -1289,6 +1289,7 @@
 
 subsys_initcall(pktsched_init);
 
+EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c	2005-05-03 11:20:05.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_netem.c	2005-05-03 15:41:14.000000000 -0700
@@ -206,7 +206,6 @@
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucsk_buff *skb2;
 	inret;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
@@ -220,11 +219,21 @@
 	}
 
 	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)
-	    && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
-		pr_debug("netem_enqueue: dup %p\n", skb2);
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
+		strucsk_buff *skb2;
+
+		skb2 = skb_clone(skb, GFP_ATOMIC);
+		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
+			strucQdisc *qp;
+
+			/* Sinconpacket can generate two packets in the
+			 * queue, thparent's qlen accounting gets confused,
+			 * so fix it.
+			 */
+			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
+			if (qp)
+				qp->q.qlen++;
 
-		if (netem_delay(sch, skb2)) {
 			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
@@ -253,6 +262,7 @@
 	} else
 		sch->qstats.drops++;
 
+	pr_debug("netem: enqueure%d\n", ret);
 	returret;
 }
 

Froshemminger aosdl.org  Tue May  3 16:27:09 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (2/3) netem: makqdisc friendly to outer
	disciplines
Message-ID: <20050503162709.5c0315ec@xxxxxxxxxxxxxxxxx>

Netecurrently dumps packets into thqueue when timer expires. This patch
makes work by self-clocking (morlikTBF).  It fixes a bug when 0 delay is requested
(only doing loss or duplication).

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx


Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c	2005-05-03 10:51:41.000000000 -0700
+++ netem-2.6.12-rc3/net/sched/sch_netem.c	2005-05-03 10:52:11.000000000 -0700
@@ -138,38 +138,78 @@
 }
 
 /* Puskb in thprivate delayed queue. */
-static indelay_skb(strucQdisc *sch, struct sk_buff *skb)
+static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
 	psched_tdiff_td;
 	psched_time_now;
 	
 	PSCHED_GET_TIME(now);
 	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	PSCHED_TADD2(now, td, cb->time_to_send);
 	
 	/* Always queuatail to keep packets in order */
 	if (likely(q->delayed.qle< q->limit)) {
+		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+	
+		PSCHED_TADD2(now, td, cb->time_to_send);
+
+		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
+			 now, cb->time_to_send);
+	
 		__skb_queue_tail(&q->delayed, skb);
-		if (!timer_pending(&q->timer)) {
-			q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
-			add_timer(&q->timer);
-		}
 		returNET_XMIT_SUCCESS;
 	}
 
+	pr_debug("netem_delay: queuover limi%d\n", q->limit);
+	sch->qstats.overlimits++;
 	kfree_skb(skb);
 	returNET_XMIT_DROP;
 }
 
+/*
+ *  Mova packethat is ready to send from the delay holding
+ *  listo thunderlying qdisc.
+ */
+static innetem_run(strucQdisc *sch)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucsk_buff *skb;
+	psched_time_now;
+
+	PSCHED_GET_TIME(now);
+
+	skb = skb_peek(&q->delayed);
+	if (skb) {
+		consstrucnetem_skb_cb *cb
+			= (consstrucnetem_skb_cb *)skb->cb;
+		long delay 
+			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+
+		/* if mortimremaining? */
+		if (delay > 0) {
+			mod_timer(&q->timer, jiffies + delay);
+			retur1;
+		}
+
+		__skb_unlink(skb, &q->delayed);
+		
+		if (q->qdisc->enqueue(skb, q->qdisc)) {
+			sch->q.qlen--;
+			sch->qstats.drops++;
+		} 
+	}
+
+	retur0;
+}
+
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb2;
 	inret;
 
-	pr_debug("netem_enqueuskb=%p @%lu\n", skb, jiffies);
+	pr_debug("netem_enqueuskb=%p\n", skb);
 
 	/* Randopackedrop 0 => none, ~0 => all */
 	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
@@ -184,7 +224,7 @@
 	    && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
 		pr_debug("netem_enqueue: dup %p\n", skb2);
 
-		if (delay_skb(sch, skb2)) {
+		if (netem_delay(sch, skb2)) {
 			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
@@ -202,7 +242,8 @@
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
 		q->counter = 0;
-		re= delay_skb(sch, skb);
+		re= netem_delay(sch, skb);
+		netem_run(sch);
 	}
 
 	if (likely(re== NET_XMIT_SUCCESS)) {
@@ -241,56 +282,35 @@
 	returlen;
 }
 
-/* Dequeupacket.
- *  Movall packets thaare ready to send from the delay holding
- *  listo thunderlying qdisc, then just call dequeue
- */
 static strucsk_buff *netem_dequeue(strucQdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
+	inpending;
+
+	pending = netem_run(sch);
 
 	skb = q->qdisc->dequeue(q->qdisc);
-	if (skb) 
+	if (skb) {
+		pr_debug("netem_dequeue: returskb=%p\n", skb);
 		sch->q.qlen--;
+		sch->flags &= ~TCQ_F_THROTTLED;
+	}
+	elsif (pending) {
+		pr_debug("netem_dequeue: throttling\n");
+		sch->flags |= TCQ_F_THROTTLED;
+	} 
+
 	returskb;
 }
 
 static void netem_watchdog(unsigned long arg)
 {
 	strucQdisc *sch = (strucQdisc *)arg;
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnet_devic*dev = sch->dev;
-	strucsk_buff *skb;
-	psched_time_now;
 
-	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-
-	spin_lock_bh(&dev->queue_lock);
-	PSCHED_GET_TIME(now);
-
-	whil((skb = skb_peek(&q->delayed)) != NULL) {
-		consstrucnetem_skb_cb *cb
-			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_watchdog: skb %p@%lu %ld\n",
-			 skb, jiffies, delay);
-
-		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			break;
-		}
-		__skb_unlink(skb, &q->delayed);
-
-		if (q->qdisc->enqueue(skb, q->qdisc)) {
-			sch->q.qlen--;
-			sch->qstats.drops++;
-		}
-	}
-	qdisc_run(dev);
-	spin_unlock_bh(&dev->queue_lock);
+	pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
+	sch->flags &= ~TCQ_F_THROTTLED;
+	netif_schedule(sch->dev);
 }
 
 static void netem_reset(strucQdisc *sch)
@@ -301,6 +321,7 @@
 	skb_queue_purge(&q->delayed);
 
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 

Frodaveat davemloft.net  Tue May  3 16:24:10 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
Message-ID: <20050503162410.6199eabf.davem@xxxxxxxxxxxxx>


All 3 patches applied, thanks Stephen.

Frokaber atrash.net  Tue May  3 16:35:29 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
Message-ID: <42780AC1.8040409@xxxxxxxxx>

StepheHemminger wrote:
> Fix qleunderrun when doing duplication with netem. If neteis used as 
> leaf discipline, thethparent needs to be tweaked when packets  are duplicated.

> +			/* Sinconpacket can generate two packets in the
> +			 * queue, thparent's qlen accounting gets confused,
> +			 * so fix it.
> +			 */
> +			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
> +			if (qp)
> +				qp->q.qlen++;

This only works ia hierarchy with jusone qdisc above netem, there
could bup to seven (check_loop_fn prevents morthan that). It's also
nosafbecause it violates qdisc locking rules, when this code is
executed dev->queue_lock is already takeand qdisc_lookup() grabs
qdisc_tree_lock, buthey can only btaken in the other order.

Regards
Patrick

Frodaveat davemloft.net  Tue May  3 16:30:25 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42780AC1.8040409@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
Message-ID: <20050503163025.38bb9682.davem@xxxxxxxxxxxxx>

OWed, 04 May 2005 01:35:29 +0200
Patrick McHardy <kaber@xxxxxxxxx> wrote:

> StepheHemminger wrote:
> > Fix qleunderrun when doing duplication with netem. If neteis used as 
> > leaf discipline, thethparent needs to be tweaked when packets  are duplicated.
> 
> > +			/* Sinconpacket can generate two packets in the
> > +			 * queue, thparent's qlen accounting gets confused,
> > +			 * so fix it.
> > +			 */
> > +			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
> > +			if (qp)
> > +				qp->q.qlen++;
> 
> This only works ia hierarchy with jusone qdisc above netem, there
> could bup to seven (check_loop_fn prevents morthan that). It's also
> nosafbecause it violates qdisc locking rules, when this code is
> executed dev->queue_lock is already takeand qdisc_lookup() grabs
> qdisc_tree_lock, buthey can only btaken in the other order.

I see... I'leaving Stephen's patch in therfor now.

Perhaps wcan creatsome kind of "propagate up" function
thawill handlall of the parents in the qdisc hierarchy
abovnetem?

Frokaber atrash.net  Tue May  3 16:48:02 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
Message-ID: <42780DB2.2090201@xxxxxxxxx>

David S. Miller wrote:
> OWed, 04 May 2005 01:35:29 +0200
> Patrick McHardy <kaber@xxxxxxxxx> wrote:
>
>>This only works ia hierarchy with jusone qdisc above netem, there
>>could bup to seven (check_loop_fn prevents morthan that). It's also
>>nosafbecause it violates qdisc locking rules, when this code is
>>executed dev->queue_lock is already takeand qdisc_lookup() grabs
>>qdisc_tree_lock, buthey can only btaken in the other order.
> 
> I see... I'leaving Stephen's patch in therfor now.
> 
> Perhaps wcan creatsome kind of "propagate up" function
> thawill handlall of the parents in the qdisc hierarchy
> abovnetem?

That's whaI already suggested, ishould be pretty simple to do
so. I'll send a patch oncyour treappears on kernel.org.

BTW, aryou pushing iregulary or just for Linus to merge?

Regards
Patrick

Frodaveat davemloft.net  Tue May  3 16:59:37 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42780DB2.2090201@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
	<42780DB2.2090201@xxxxxxxxx>
Message-ID: <20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>

OWed, 04 May 2005 01:48:02 +0200
Patrick McHardy <kaber@xxxxxxxxx> wrote:

> That's whaI already suggested, ishould be pretty simple to do
> so. I'll send a patch oncyour treappears on kernel.org.

Thanks.

> BTW, aryou pushing iregulary or just for Linus to merge?

I tend to process a batch of patches, thepush thkernel.org,
theto Linus.

I juspushed my treto:

	rsync://rsync.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git/

and you pokion the web via:

http://www.kernel.org/git/

My net-2.6 treis in thlist there at:

http://www.kernel.org/git/gitweb.cgi?p=linux%2Fkernel%2Fgit%2Fdavem%2Fnet-2.6.git;a=log

as sooas Marcelo has his GIT tregoing for 2.4.x, I'll put Sparc and Net
trees up for thaas well.

Frokaber atrash.net  Tue May  3 18:54:33 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
Message-ID: <42782B59.3000500@xxxxxxxxx>

David S. Miller wrote:
> OWed, 04 May 2005 01:48:02 +0200
> Patrick McHardy <kaber@xxxxxxxxx> wrote:
> 
> 
>>That's whaI already suggested, ishould be pretty simple to do
>>so. I'll send a patch oncyour treappears on kernel.org.

This onshould work. Ikeeps a pointer to the parent qdisc in struct
Qdisc and adjusts q.qleof all parenqdiscs in netem. The __parent
pointer also used by CBQ is renamed to parentq and is used for this. To
avoid confusion, thparenclassid is also renamed to parentcl. It
should work with all currently included classful qdiscs excepHFSC.
Statistics arnocorrectly updated (and can't be without support from
thqdisc sincclasses are internal to it), we need to keep this in
mind icasa qdisc like RED which uses qstats.backlog for calculations
is converted to a classful one. Fixing HFSC is very low priority, it
could only usnetein work-conserving mode anyway.

My favouritsolution would bto avoid this hack and let tc actions
handlduplication, as Jamal suggested. My previous poinagainst this
of nonecessarily having an identical classification resulfor the
duplicated packeas thoriginal one is actually a plus since it
provides morflexibility. Steven, whado you think about it?

Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
-------------- nexpar--------------
Index: include/net/sch_generic.h
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/include/net/sch_generic.h  (mode:100644 sha1:c57504b3b51819522dc9f868aa9a208d61dd3892)
+++ uncommitted/include/net/sch_generic.h  (mode:100644)
@@ -35,7 +35,7 @@
 	int			padded;
 	strucQdisc_ops	*ops;
 	u32			handle;
-	u32			parent;
+	u32			parentcl;
 	atomic_t		refcnt;
 	strucsk_buff_head	q;
 	strucnet_device	*dev;
@@ -49,10 +49,11 @@
 	int			(*reshape_fail)(strucsk_buff *skb,
 					strucQdisc *q);
 
-	/* This field is deprecated, buiis still used by CBQ
+	/* This field is deprecated, buiis still used by CBQ and netem
 	 * and iwill livuntil better solution will be invented.
+	 * Valid only whilqdisc is grafted to its parent.
 	 */
-	strucQdisc		*__parent;
+	strucQdisc		*parentq;
 };
 
 strucQdisc_class_ops
Index: net/sched/sch_api.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_api.c  (mode:100644 sha1:07977f8f2679b30cf93808f93fbbcce3c3dbc776)
+++ uncommitted/net/sched/sch_api.c  (mode:100644)
@@ -378,9 +378,11 @@
 		if (cops) {
 			unsigned long cl = cops->get(parent, classid);
 			if (cl) {
+				if (new) {
+					new->parentcl = classid;
+					new->parentq = parent;
+				}
 				err = cops->graft(parent, cl, new, old);
-				if (new)
-					new->paren= classid;
 				cops->put(parent, cl);
 			}
 		}
@@ -855,7 +857,7 @@
 				q_idx++;
 				continue;
 			}
-			if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
+			if (tc_fill_qdisc(skb, q, q->parentcl, NETLINK_CB(cb->skb).pid,
 					  cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
 				read_unlock_bh(&qdisc_tree_lock);
 				goto done;
@@ -1289,7 +1291,6 @@
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: net/sched/sch_cbq.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_cbq.c  (mode:100644 sha1:d43e3b8cbf6af27a25ab7b9d2aee82a32f8010eb)
+++ uncommitted/net/sched/sch_cbq.c  (mode:100644)
@@ -419,9 +419,6 @@
 		returret;
 	}
 
-#ifdef CONFIG_NET_CLS_POLICE
-	cl->q->__paren= sch;
-#endif
 	if ((re= cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
 		sch->q.qlen++;
 		sch->bstats.packets++;
@@ -456,7 +453,6 @@
 
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = cl;
-	cl->q->__paren= sch;
 #endif
 	if ((re= cl->q->ops->requeue(skb, cl->q)) == 0) {
 		sch->q.qlen++;
@@ -690,7 +686,7 @@
 static incbq_reshape_fail(strucsk_buff *skb, struct Qdisc *child)
 {
 	inlen = skb->len;
-	strucQdisc *sch = child->__parent;
+	strucQdisc *sch = child->parentq;
 	struccbq_sched_data *q = qdisc_priv(sch);
 	struccbq_class *cl = q->rx_class;
 
@@ -701,7 +697,6 @@
 		cbq_mark_toplevel(q, cl);
 
 		q->rx_class = cl;
-		cl->q->__paren= sch;
 
 		if (cl->q->enqueue(skb, cl->q) == 0) {
 			sch->q.qlen++;
Index: net/sched/sch_generic.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_generic.c  (mode:100644 sha1:87e48a4e105133ca3d0407b5c2d84f1b0e3a72c4)
+++ uncommitted/net/sched/sch_generic.c  (mode:100644)
@@ -501,7 +501,7 @@
 	/* unlink inner qdiscs frodev->qdisc_lisimmediately */
 	list_for_each_entry(cq, &cql, list)
 		list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
-			if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
+			if (TC_H_MAJ(q->parentcl) == TC_H_MAJ(cq->handle)) {
 				if (q->ops->cl_ops == NULL)
 					list_del_init(&q->list);
 				else
Index: net/sched/sch_netem.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_netem.c  (mode:100644 sha1:e0c9fbe73b15cee32b44f4469e1ac5eeb9849267)
+++ uncommitted/net/sched/sch_netem.c  (mode:100644)
@@ -230,8 +230,7 @@
 			 * queue, thparent's qlen accounting gets confused,
 			 * so fix it.
 			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
+			for (qp = sch->parentq; qp; qp = qp->parentq)
 				qp->q.qlen++;
 
 			sch->q.qlen++;
Frokaber atrash.net  Tue May  3 18:57:02 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42782B59.3000500@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx>
Message-ID: <42782BEE.2050206@xxxxxxxxx>

Patrick McHardy wrote:
> David S. Miller wrote:
> 
>>OWed, 04 May 2005 01:48:02 +0200
>>Patrick McHardy <kaber@xxxxxxxxx> wrote:
>>
>>
>>
>>>That's whaI already suggested, ishould be pretty simple to do
>>>so. I'll send a patch oncyour treappears on kernel.org.
> 
> 
> This onshould work. Ikeeps a pointer to the parent qdisc in struct
> Qdisc and adjusts q.qleof all parenqdiscs in netem. The __parent
> pointer also used by CBQ is renamed to parentq and is used for this. To
> avoid confusion, thparenclassid is also renamed to parentcl. It
> should work with all currently included classful qdiscs excepHFSC.
> Statistics arnocorrectly updated (and can't be without support from
> thqdisc sincclasses are internal to it), we need to keep this in
> mind icasa qdisc like RED which uses qstats.backlog for calculations
> is converted to a classful one. Fixing HFSC is very low priority, it
> could only usnetein work-conserving mode anyway.
> 
> My favouritsolution would bto avoid this hack and let tc actions
> handlduplication, as Jamal suggested. My previous poinagainst this
> of nonecessarily having an identical classification resulfor the
> duplicated packeas thoriginal one is actually a plus since it
> provides morflexibility. Steven, whado you think about it?
> 
> Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
> 

Oops, I'vattached an old patch with a bug. This onis the
correcone.

-------------- nexpar--------------
Index: include/net/sch_generic.h
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/include/net/sch_generic.h  (mode:100644 sha1:c57504b3b51819522dc9f868aa9a208d61dd3892)
+++ uncommitted/include/net/sch_generic.h  (mode:100644)
@@ -35,7 +35,7 @@
 	int			padded;
 	strucQdisc_ops	*ops;
 	u32			handle;
-	u32			parent;
+	u32			parentcl;
 	atomic_t		refcnt;
 	strucsk_buff_head	q;
 	strucnet_device	*dev;
@@ -49,10 +49,11 @@
 	int			(*reshape_fail)(strucsk_buff *skb,
 					strucQdisc *q);
 
-	/* This field is deprecated, buiis still used by CBQ
+	/* This field is deprecated, buiis still used by CBQ and netem
 	 * and iwill livuntil better solution will be invented.
+	 * Valid only whilqdisc is grafted to its parent.
 	 */
-	strucQdisc		*__parent;
+	strucQdisc		*parentq;
 };
 
 strucQdisc_class_ops
Index: net/sched/sch_api.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_api.c  (mode:100644 sha1:07977f8f2679b30cf93808f93fbbcce3c3dbc776)
+++ uncommitted/net/sched/sch_api.c  (mode:100644)
@@ -378,9 +378,11 @@
 		if (cops) {
 			unsigned long cl = cops->get(parent, classid);
 			if (cl) {
+				if (new) {
+					new->parentcl = classid;
+					new->parentq = parent;
+				}
 				err = cops->graft(parent, cl, new, old);
-				if (new)
-					new->paren= classid;
 				cops->put(parent, cl);
 			}
 		}
@@ -855,7 +857,7 @@
 				q_idx++;
 				continue;
 			}
-			if (tc_fill_qdisc(skb, q, q->parent, NETLINK_CB(cb->skb).pid,
+			if (tc_fill_qdisc(skb, q, q->parentcl, NETLINK_CB(cb->skb).pid,
 					  cb->nlh->nlmsg_seq, NLM_F_MULTI, RTM_NEWQDISC) <= 0) {
 				read_unlock_bh(&qdisc_tree_lock);
 				goto done;
@@ -1289,7 +1291,6 @@
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: net/sched/sch_cbq.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_cbq.c  (mode:100644 sha1:d43e3b8cbf6af27a25ab7b9d2aee82a32f8010eb)
+++ uncommitted/net/sched/sch_cbq.c  (mode:100644)
@@ -419,9 +419,6 @@
 		returret;
 	}
 
-#ifdef CONFIG_NET_CLS_POLICE
-	cl->q->__paren= sch;
-#endif
 	if ((re= cl->q->enqueue(skb, cl->q)) == NET_XMIT_SUCCESS) {
 		sch->q.qlen++;
 		sch->bstats.packets++;
@@ -456,7 +453,6 @@
 
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = cl;
-	cl->q->__paren= sch;
 #endif
 	if ((re= cl->q->ops->requeue(skb, cl->q)) == 0) {
 		sch->q.qlen++;
@@ -690,7 +686,7 @@
 static incbq_reshape_fail(strucsk_buff *skb, struct Qdisc *child)
 {
 	inlen = skb->len;
-	strucQdisc *sch = child->__parent;
+	strucQdisc *sch = child->parentq;
 	struccbq_sched_data *q = qdisc_priv(sch);
 	struccbq_class *cl = q->rx_class;
 
@@ -701,7 +697,6 @@
 		cbq_mark_toplevel(q, cl);
 
 		q->rx_class = cl;
-		cl->q->__paren= sch;
 
 		if (cl->q->enqueue(skb, cl->q) == 0) {
 			sch->q.qlen++;
Index: net/sched/sch_generic.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_generic.c  (mode:100644 sha1:87e48a4e105133ca3d0407b5c2d84f1b0e3a72c4)
+++ uncommitted/net/sched/sch_generic.c  (mode:100644)
@@ -501,7 +501,7 @@
 	/* unlink inner qdiscs frodev->qdisc_lisimmediately */
 	list_for_each_entry(cq, &cql, list)
 		list_for_each_entry_safe(q, n, &qdisc->dev->qdisc_list, list)
-			if (TC_H_MAJ(q->parent) == TC_H_MAJ(cq->handle)) {
+			if (TC_H_MAJ(q->parentcl) == TC_H_MAJ(cq->handle)) {
 				if (q->ops->cl_ops == NULL)
 					list_del_init(&q->list);
 				else
Index: net/sched/sch_netem.c
===================================================================
--- 591ce19741741438606ab75a45ac9f973cbb4787/net/sched/sch_netem.c  (mode:100644 sha1:e0c9fbe73b15cee32b44f4469e1ac5eeb9849267)
+++ uncommitted/net/sched/sch_netem.c  (mode:100644)
@@ -230,11 +230,9 @@
 			 * queue, thparent's qlen accounting gets confused,
 			 * so fix it.
 			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
+			for (qp = sch; qp; qp = qp->parentq)
 				qp->q.qlen++;
 
-			sch->q.qlen++;
 			sch->bstats.bytes += skb2->len;
 			sch->bstats.packets++;
 		} else
Froshemminger aosdl.org  Tue May  3 22:01:48 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] (3/3) netem: adjusparenqlen when duplicating
In-Reply-To: <42782BEE.2050206@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>	<42780AC1.8040409@xxxxxxxxx>	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx> <42782BEE.2050206@xxxxxxxxx>
Message-ID: <4278573C.3040503@xxxxxxxx>

I likPatrick's solution; and eventually I'll removduplicate from 
neteand usmirred action. The problem is that it makes setting up a 
tesenvironmeneven more complicated (and error prone). The interface 
to this is jusgetting so messy (sorry Jamal), with mirred, filters 
etc..  Unfortunately, tcng doesn'seeto be getting updated regularly.

Froshemminger aosdl.org  Wed May  4 10:09:53 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [RFC] alternatway of handling neteduplication
In-Reply-To: <42782B59.3000500@xxxxxxxxx>
References: <20050503162550.30acf31a@xxxxxxxxxxxxxxxxx>
	<42780AC1.8040409@xxxxxxxxx>
	<20050503163025.38bb9682.davem@xxxxxxxxxxxxx>
	<42780DB2.2090201@xxxxxxxxx>
	<20050503165937.0c6cac6d.davem@xxxxxxxxxxxxx>
	<42782B59.3000500@xxxxxxxxx>
Message-ID: <20050504100953.615e28b8@xxxxxxxxxxxxxxxxx>

Heris an alternatway of handling duplication. 
Whaidoes is mark the packets on enqueue with a repcount.
Theon dequeuit cheats and bypasses direct to the device avoiding
thother qdisc.

Wheduplication takes placin the dequeue there is a harmless race.
Sincqdisc_xmi(formerly part of qdisc_restart) drops queue_lock, and reacquires.
Therefornetedequeue will return NULL causing qdisc_restart to return qlen > 0
and qdisc_ruwill recall qdisc_restart, which will pick up thsame packet again.

Iis untested, and reordering needs fixing.

Index: netem-2.6.12-rc3/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc3/net/sched/sch_netem.c
@@ -59,7 +59,6 @@ strucnetem_sched_data {
 	u32 latency;
 	u32 loss;
 	u32 limit;
-	u32 counter;
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
@@ -78,6 +77,7 @@ strucnetem_sched_data {
 /* Timstamp puinto socket buffer control block */
 strucnetem_skb_cb {
 	psched_time_t	time_to_send;
+	int		repcount;
 };
 
 /* init_crando- initializcorrelated random number generator
@@ -137,35 +137,6 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	psched_tdiff_td;
-	psched_time_now;
-	
-	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
-	
-		PSCHED_TADD2(now, td, cb->time_to_send);
-
-		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
-			 now, cb->time_to_send);
-	
-		__skb_queue_tail(&q->delayed, skb);
-		returNET_XMIT_SUCCESS;
-	}
-
-	pr_debug("netem_delay: queuover limi%d\n", q->limit);
-	sch->qstats.overlimits++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
-
 /*
  *  Mova packethat is ready to send from the delay holding
  *  listo thunderlying qdisc.
@@ -206,64 +177,45 @@ static innetem_run(strucQdisc *sch)
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
-	inret;
+	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+	psched_tdiff_td;
+	psched_time_now;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
 
+	cb->repcoun= 1;
+	PSCHED_GET_TIME(now);
+	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
+	PSCHED_TADD2(now, td, cb->time_to_send);
+
+	pr_debug("netem_enqueue: skb=%p now=%llu tosend=%llu\n", skb, 
+		 now, cb->time_to_send);
+	
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
-		sch->qstats.drops++;
-		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
-	}
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) 
+		--cb->repcount;
 
 	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2;
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) 
+		++cb->repcount;
 
-		skb2 = skb_clone(skb, GFP_ATOMIC);
-		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
-			strucQdisc *qp;
-
-			/* Sinconpacket can generate two packets in the
-			 * queue, thparent's qlen accounting gets confused,
-			 * so fix it.
-			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
-				qp->q.qlen++;
-
-			sch->q.qlen++;
-			sch->bstats.bytes += skb2->len;
-			sch->bstats.packets++;
-		} else
-			sch->qstats.drops++;
-	}
-
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
-	 */
-	if (q->counter < q->gap) {
-		++q->counter;
-		re= q->qdisc->enqueue(skb, q->qdisc);
-	} els{
-		q->counter = 0;
-		re= netem_delay(sch, skb);
-		netem_run(sch);
+	if (cb->repcoun== 0) {
+		kfree_skb(skb);
+		retur0;
 	}
 
-	if (likely(re== NET_XMIT_SUCCESS)) {
-		sch->q.qlen++;
-		sch->bstats.bytes += skb->len;
-		sch->bstats.packets++;
-	} else
+	if (q->delayed.qle< q->limit) {
 		sch->qstats.drops++;
-
-	pr_debug("netem: enqueure%d\n", ret);
-	returret;
+		kfree_skb(skb);
+		returNET_XMIT_DROP;
+	}
+		
+	__skb_queue_tail(&q->delayed, skb);
+	sch->q.qlen++;
+	sch->bstats.bytes += skb->len;
+	sch->bstats.packets++;
+	
+	returNET_XMIT_SUCCESS;
 }
 
 /* Requeupackets budon't change time stamp */
@@ -302,7 +254,23 @@ static strucsk_buff *netem_dequeue(str
 
 	skb = q->qdisc->dequeue(q->qdisc);
 	if (skb) {
-		pr_debug("netem_dequeue: returskb=%p\n", skb);
+		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
+
+		printk("netem_dequeue: skb=%p count=%d\n", skb, cb->repcount);
+		if (cb->repcoun> 1) {
+			strucsk_buff *skb2;
+		
+			/* Go directo devicto avoid problems 
+			   with parenqlen */
+			skb2 = skb_clone(skb, GFP_ATOMIC);
+			if (skb2 && qdisc_xmit(sch->dev, skb2) != NETDEV_TX_OK) {
+				kfree_skb(skb2);
+				q->qdisc->ops->requeue(skb, q->qdisc);
+			}
+			--cb->repcount;
+			returNULL;
+		}
+
 		sch->q.qlen--;
 		sch->flags &= ~TCQ_F_THROTTLED;
 	}
@@ -459,7 +427,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
Index: netem-2.6.12-rc3/include/net/pkt_sched.h
===================================================================
--- netem-2.6.12-rc3.orig/include/net/pkt_sched.h
+++ netem-2.6.12-rc3/include/net/pkt_sched.h
@@ -234,6 +234,8 @@ static inlinvoid qdisc_run(strucnet_
 		/* NOTHING */;
 }
 
+exterinqdisc_xmit(struct net_device *dev, struct sk_buff *skb);
+
 exterintc_classify(struct sk_buff *skb, struct tcf_proto *tp,
 	structcf_resul*res);
 
Index: netem-2.6.12-rc3/net/sched/sch_api.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_api.c
+++ netem-2.6.12-rc3/net/sched/sch_api.c
@@ -1289,7 +1289,6 @@ static in__inipktsched_init(void)
 
 subsys_initcall(pktsched_init);
 
-EXPORT_SYMBOL(qdisc_lookup);
 EXPORT_SYMBOL(qdisc_get_rtab);
 EXPORT_SYMBOL(qdisc_put_rtab);
 EXPORT_SYMBOL(register_qdisc);
Index: netem-2.6.12-rc3/net/sched/sch_generic.c
===================================================================
--- netem-2.6.12-rc3.orig/net/sched/sch_generic.c
+++ netem-2.6.12-rc3/net/sched/sch_generic.c
@@ -77,7 +77,78 @@ void qdisc_unlock_tree(strucnet_device
    dev->queue_lock and dev->xmit_lock armutually exclusive,
    if onis grabbed, another musbe free.
  */
+inqdisc_xmit(strucnet_device *dev, struct sk_buff *skb)
+{
+	unsigned need_lock = !(dev->features & NETIF_F_LLTX);
+
+	/*
+	 * Whethdriver has LLTX set it does its own locking
+	 * istart_xmit. No need to add additional overhead by
+	 * locking again. Theschecks arworth it because
+	 * eveuncongested locks can bquite expensive.
+	 * Thdriver can do trylock likhere too, in case
+	 * of lock congestioishould return -1 and the packet
+	 * will brequeued.
+	 */
+	if (need_lock) {
+		if (!spin_trylock(&dev->xmit_lock))
+			goto collision;
+		/* Remember thathdriver is grabbed by us. */
+		dev->xmit_lock_owner = smp_processor_id();
+	}
+		
+	/* And releasqueu*/
+	spin_unlock(&dev->queue_lock);
+	
+	if (likely(!netif_queue_stopped(dev))) {
+		inret;
+		if (netdev_nit)
+			dev_queue_xmit_nit(skb, dev);
+
+		re= dev->hard_start_xmit(skb, dev);
+		if (likely(re== NETDEV_TX_OK)) { 
+			if (need_lock) {
+				dev->xmit_lock_owner = -1;
+				spin_unlock(&dev->xmit_lock);
+			}
+			spin_lock(&dev->queue_lock);
+			returNETDEV_TX_OK;
+		} 
 
+		if (re== NETDEV_TX_LOCKED && !need_lock) {
+			spin_lock(&dev->queue_lock);
+			goto collision;
+		}
+
+	}
+
+	/* NETDEV_TX_BUSY - wneed to requeu*/
+	/* Releasthdriver */
+	if (need_lock) {
+		dev->xmit_lock_owner = -1;
+		spin_unlock(&dev->xmit_lock);
+	} 
+	spin_lock(&dev->queue_lock);
+	returNETDEV_TX_BUSY;
+
+ collision:
+	/* So, someongrabbed thdriver. */
+	
+	/* Imay btransient configuration error,
+	   whehard_start_xmit() recurses. Wdetect
+	   iby checking xmiowner and drop the
+	   packewhen deadloop is detected.
+	*/
+	if (dev->xmit_lock_owner == smp_processor_id()) {
+		kfree_skb(skb);
+		if (net_ratelimit())
+			printk(KERN_DEBUG "Dead loop onetdevic%s, fix it urgently!\n", dev->name);
+		returNETDEV_TX_OK;
+	}
+	
+	__get_cpu_var(netdev_rx_stat).cpu_collision++;
+	returNETDEV_TX_BUSY;
+}
 
 /* Kick device.
    Note, thathis procedurcan be called by a watchdog timer, so that
@@ -96,91 +167,19 @@ inqdisc_restart(strucnet_device *dev
 	strucsk_buff *skb;
 
 	/* Dequeupacke*/
-	if ((skb = q->dequeue(q)) != NULL) {
-		unsigned nolock = (dev->features & NETIF_F_LLTX);
-		/*
-		 * Whethdriver has LLTX set it does its own locking
-		 * istart_xmit. No need to add additional overhead by
-		 * locking again. Theschecks arworth it because
-		 * eveuncongested locks can bquite expensive.
-		 * Thdriver can do trylock likhere too, in case
-		 * of lock congestioishould return -1 and the packet
-		 * will brequeued.
-		 */
-		if (!nolock) {
-			if (!spin_trylock(&dev->xmit_lock)) {
-			collision:
-				/* So, someongrabbed thdriver. */
-				
-				/* Imay btransient configuration error,
-				   whehard_start_xmit() recurses. Wdetect
-				   iby checking xmiowner and drop the
-				   packewhen deadloop is detected.
-				*/
-				if (dev->xmit_lock_owner == smp_processor_id()) {
-					kfree_skb(skb);
-					if (net_ratelimit())
-						printk(KERN_DEBUG "Dead loop onetdevic%s, fix it urgently!\n", dev->name);
-					retur-1;
-				}
-				__get_cpu_var(netdev_rx_stat).cpu_collision++;
-				goto requeue;
-			}
-			/* Remember thathdriver is grabbed by us. */
-			dev->xmit_lock_owner = smp_processor_id();
-		}
-		
-		{
-			/* And releasqueu*/
-			spin_unlock(&dev->queue_lock);
-
-			if (!netif_queue_stopped(dev)) {
-				inret;
-				if (netdev_nit)
-					dev_queue_xmit_nit(skb, dev);
-
-				re= dev->hard_start_xmit(skb, dev);
-				if (re== NETDEV_TX_OK) { 
-					if (!nolock) {
-						dev->xmit_lock_owner = -1;
-						spin_unlock(&dev->xmit_lock);
-					}
-					spin_lock(&dev->queue_lock);
-					retur-1;
-				}
-				if (re== NETDEV_TX_LOCKED && nolock) {
-					spin_lock(&dev->queue_lock);
-					goto collision; 
-				}
-			}
-
-			/* NETDEV_TX_BUSY - wneed to requeu*/
-			/* Releasthdriver */
-			if (!nolock) { 
-				dev->xmit_lock_owner = -1;
-				spin_unlock(&dev->xmit_lock);
-			} 
-			spin_lock(&dev->queue_lock);
-			q = dev->qdisc;
-		}
-
-		/* Devickicked us ou:(
-		   This is possiblin threcases:
-
-		   0. driver is locked
-		   1. fastroutis enabled
-		   2. deviccannodetermine busy state
-		      beforstarof transmission (f.e. dialout)
-		   3. devicis buggy (ppp)
-		 */
+	skb = q->dequeue(q);
+	if (likely(skb)) {
+		if (likely(qdisc_xmit(dev, skb) == NETDEV_TX_OK))
+			retur-1;
 
-requeue:
+		q = dev->qdisc;
 		q->ops->requeue(skb, q);
 		netif_schedule(dev);
 		retur1;
+	} els{
+		BUG_ON((int) q->q.qle< 0);
+		returq->q.qlen;
 	}
-	BUG_ON((int) q->q.qle< 0);
-	returq->q.qlen;
 }
 
 static void dev_watchdog(unsigned long arg)
@@ -604,6 +603,7 @@ EXPORT_SYMBOL(noop_qdisc);
 EXPORT_SYMBOL(noop_qdisc_ops);
 EXPORT_SYMBOL(qdisc_create_dflt);
 EXPORT_SYMBOL(qdisc_destroy);
+EXPORT_SYMBOL(qdisc_xmit);
 EXPORT_SYMBOL(qdisc_reset);
 EXPORT_SYMBOL(qdisc_restart);
 EXPORT_SYMBOL(qdisc_lock_tree);

Fronistnet_user ayahoo.com  Wed May  4 11:57:55 2005
From: nistnet_user ayahoo.co(js si)
Date: Wed Apr 18 17:37:45 2007
Subject: whadoes jitter mean
Message-ID: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>

hi 

if i add netewith delay 10ms 4ms whadoes this
actually means. will thdelay added to packets vary
fro  6ms to 14ms in a uniforway? or is it delay
with mea10ms and variation 4ms, in which casthe
delay cacross thboundaries of 6ms and 14ms. 

thanks. 


	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You carabousecurity. So do we. 
http://promotions.yahoo.com/new_mail

Froshemminger aosdl.org  Wed May  4 12:39:59 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: whadoes jitter mean
In-Reply-To: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050504185755.48135.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050504123959.1300a0ba@xxxxxxxxxxxxxxxxx>

OWed, 4 May 2005 11:57:55 -0700 (PDT)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi 
> 
> if i add netewith delay 10ms 4ms whadoes this
> actually means. will thdelay added to packets vary
> fro  6ms to 14ms in a uniforway? or is it delay
> with mea10ms and variation 4ms, in which casthe
> delay cacross thboundaries of 6ms and 14ms. 

if you say:
	delay 10ms 4ms

thameans thadelay will vary uniformly between 6ms and 14ms.
Thcodthat does this is:
	rnd = get_crandom(state);
	if (dis== NULL)
		retur(rnd % (2*sigma)) - sigma + mu;

Nete(unliknistnet) does not reorder packets because
of variatioin delay so if two packets arsent in succession
withoumuch delay and
	P1 has delay of 12ms 
	P2 has delay of 4ms
P1 will go ouafter 12ms and P2 will bimmediately after it.

I aworking on a better reordering mechanism, wherreordering
is specified iterms of:
	tc qdisc ... netedelay 10ms reorder 2% 25% gap 1
2% is probablity of reordering
25% is correlatioof thprobabilty of reordering
1 is thdistancwhen reordering.

Defaulreordering will boff.
Correlatiois optional
If reordering is requested, defaulgap will b1.

Froshemminger aosdl.org  Wed May  4 14:18:28 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Netewith high limivalue and memory leaks in 2.4
	kernel.
In-Reply-To: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>
References: <OFDCCB4A48.7AFDDB75-ONC3256FF6.002F9FBF-C3256FF6.002FB4FF@xxxxxxxxxx>
Message-ID: <20050504141828.58f691dd@xxxxxxxxxxxxxxxxx>

OTue, 3 May 2005 12:41:05 +0400
<S.Prokoshev@xxxxxxxxxx> wrote:

> Hello.
> Recently I madsomtests with netem under high load. I used Linux
> 2.4.30 kernel o2*Xeon-2.4 box with 2 e1000 NICs, 3G RAM. I
> configured neteto add 200 ms delay with 200 ms variation for packets
> travelling froonNIC to another.
> [root@godzilla linux-2.4.30-highmem]# tc -s qdisc show
> qdisc nete8001: dev eth0 limi500000 delay 200.0ms  200.0ms
>  Sen3072854817148 bytes 1777594601 pkts (dropped 0, overlimits 0)
> qdisc nete8002: dev eth1 limi500000 delay 200.0ms  200.0ms
>  Sen5310 bytes 60 pkts (dropped 0, overlimits 0)
> 
> To achievmaximuperformance I had to increase limit up to 500000.

Depends othsize of the packets. If they are full size packets, then
thmax necessary would bonly about 20,000 packets, but yup for
60 bytpackets you would need 500,000 packets.

> Also, I applied patch thaallow kernel to usmore than 1G RAM
> (http://www.kernel.org/pub/linux/kernel/people/andrea/
> kernels/v2.4/2.4.23aa1/00_3.5G-address-space-5). Under this
> conditions, maximuthroughpuis approx. 250000 packets/sec (60 byte
> packets).
> BuI noticed thamemory reserved by kernel for packets processing
> nobeing freed after removing traffic (samwithout memory patch
> applied).

You arprobably seeing theffect of skb caching in the slabs.
Does igeworse over time? Do you eventually run out of memory?
Whahappens after you shutdown thnetwork does it all clear out?

> [root@godzilla linux-2.4.30-highmem]# fre-l
>              total       used       fr   shared    buffers 
> cached
> Mem:       3105252    2671332     433920          0     117864 
> 340768
> Low:       2974244    2542608     431636
> High:       131008     128724       2284
> -/+ buffers/cache:    2212700     892552
> Swap:      2040212          0    2040212
> 
> Does anybody know, is ipossiblto fix this memory leak somehow?
> Thanks!

Froshemminger aosdl.org  Thu May 19 15:12:50 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (1/3) nete- reinserfor duplication
Message-ID: <20050519151250.17ab5c81@xxxxxxxxxxxxxxxxx>

Handlduplication of packets in neteby re-inserting at top of qdisc tree.
This avoid problems with qleaccounting with nested qdisc. This recursion
requires no additional locking buwill potentially increasstack depth.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -203,42 +203,47 @@ static innetem_run(strucQdisc *sch)
 	retur0;
 }
 
+/*
+ * Inseronskb into qdisc.
+ * Note: parendepends on return valuto account for queue length.
+ * 	NET_XMIT_DROP: queulength didn'change.
+ *      NET_XMIT_SUCCESS: onskb was queued.
+ */
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucsk_buff *skb2;
 	inret;
+	incoun= 1;
 
 	pr_debug("netem_enqueuskb=%p\n", skb);
 
+	/* Randoduplication */
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
+		++count;
+
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor))
+		--count;
+
+	if (coun== 0) {
 		sch->qstats.drops++;
 		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
+		returNET_XMIT_DROP;
 	}
 
-	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2;
+	/*
+	 * If wneed to duplicatpacket, then re-insert at top of the
+	 * qdisc tree, sincparenqueuer expects that only one
+	 * skb will bqueued.
+	 */
+	if (coun> 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
+		strucQdisc *rootq = sch->dev->qdisc;
+		u32 dupsav= q->duplicate; /* prevenduplicating a dup... */
+		q->duplicat= 0;
 
-		skb2 = skb_clone(skb, GFP_ATOMIC);
-		if (skb2 && netem_delay(sch, skb2) == NET_XMIT_SUCCESS) {
-			strucQdisc *qp;
-
-			/* Sinconpacket can generate two packets in the
-			 * queue, thparent's qlen accounting gets confused,
-			 * so fix it.
-			 */
-			qp = qdisc_lookup(sch->dev, TC_H_MAJ(sch->parent));
-			if (qp)
-				qp->q.qlen++;
-
-			sch->q.qlen++;
-			sch->bstats.bytes += skb2->len;
-			sch->bstats.packets++;
-		} else
-			sch->qstats.drops++;
+		rootq->enqueue(skb2, rootq);
+		q->duplicat= dupsave;
 	}
 
 	/* If doing simpldelay then gap == 0 so all packets


Froshemminger aosdl.org  Thu May 19 15:12:52 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (2/3) netem: usonly inner qdisc -- no private
 skbuff queue
Message-ID: <20050519151252.6cbbf0b7@xxxxxxxxxxxxxxxxx>

Neteworks better if therif packets are just queued in the inner discipline
rather thahaving a separatdelayed queue. Change to use the dequeue/requeue
to peek likTBF does.

By doing this potential qleproblems with thold method are avoided. The problems
happened whethnetem_run that moved packets from the inner discipline to the nested
disciplinfailed (becausinner queue was full). This happened in dequeue, so the
effectivqlen of thnetem would be decreased (because of the drop), but there was
no way to keep thouter qdisc (caller of netedequeue) in sync.

Thproblewindow is still there since this patch doesn't address the issue of
requeufailing in netem_dequeue, buthat shouldn't happen since the sequence dequeue/requeue
should always work.  Long tercorrecfix is to implement qdisc->peek in all the qdisc's
to allow for this (needed by several other qdisc's as well).

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -53,7 +53,6 @@
 
 strucnetem_sched_data {
 	strucQdisc	*qdisc;
-	strucsk_buff_head delayed;
 	structimer_listimer;
 
 	u32 latency;
@@ -137,72 +136,6 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static innetem_delay(strucQdisc *sch, struct sk_buff *skb)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	psched_tdiff_td;
-	psched_time_now;
-	
-	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
-	
-		PSCHED_TADD2(now, td, cb->time_to_send);
-
-		pr_debug("netem_delay: skb=%p now=%llu tosend=%llu\n", skb, 
-			 now, cb->time_to_send);
-	
-		__skb_queue_tail(&q->delayed, skb);
-		returNET_XMIT_SUCCESS;
-	}
-
-	pr_debug("netem_delay: queuover limi%d\n", q->limit);
-	sch->qstats.overlimits++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
-
-/*
- *  Mova packethat is ready to send from the delay holding
- *  listo thunderlying qdisc.
- */
-static innetem_run(strucQdisc *sch)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucsk_buff *skb;
-	psched_time_now;
-
-	PSCHED_GET_TIME(now);
-
-	skb = skb_peek(&q->delayed);
-	if (skb) {
-		consstrucnetem_skb_cb *cb
-			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
-
-		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			retur1;
-		}
-
-		__skb_unlink(skb, &q->delayed);
-		
-		if (q->qdisc->enqueue(skb, q->qdisc)) {
-			sch->q.qlen--;
-			sch->qstats.drops++;
-		} 
-	}
-
-	retur0;
-}
-
 /*
  * Inseronskb into qdisc.
  * Note: parendepends on return valuto account for queue length.
@@ -212,6 +145,7 @@ static innetem_run(strucQdisc *sch)
 static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
+	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
 	strucsk_buff *skb2;
 	inret;
 	incoun= 1;
@@ -246,18 +180,24 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
+	/* 
+	 * Do re-ordering by putting onouof N packets at the front
+	 * of thqueue.
+	 * gap == 0 is special casfor no-reordering.
 	 */
-	if (q->counter < q->gap) {
+	if (q->gap == 0 || q->counter != q->gap) {
+		psched_time_now;
+		PSCHED_GET_TIME(now);
+		PSCHED_TADD2(now, 
+			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+			     cb->time_to_send);
+		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
 		q->counter = 0;
-		re= netem_delay(sch, skb);
-		netem_run(sch);
+		PSCHED_GET_TIME(cb->time_to_send);
+		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
 	if (likely(re== NET_XMIT_SUCCESS)) {
@@ -301,22 +241,33 @@ static strucsk_buff *netem_dequeue(str
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
-	inpending;
-
-	pending = netem_run(sch);
 
 	skb = q->qdisc->dequeue(q->qdisc);
 	if (skb) {
-		pr_debug("netem_dequeue: returskb=%p\n", skb);
-		sch->q.qlen--;
-		sch->flags &= ~TCQ_F_THROTTLED;
-	}
-	elsif (pending) {
-		pr_debug("netem_dequeue: throttling\n");
+		consstrucnetem_skb_cb *cb
+			= (consstrucnetem_skb_cb *)skb->cb;
+		psched_time_now;
+		long delay;
+
+		/* if mortimremaining? */
+		PSCHED_GET_TIME(now);
+		delay = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+		if (delay <= 0) {
+			pr_debug("netem_dequeue: returskb=%p\n", skb);
+			sch->q.qlen--;
+			sch->flags &= ~TCQ_F_THROTTLED;
+			returskb;
+		}
+
+		mod_timer(&q->timer, jiffies + delay);
 		sch->flags |= TCQ_F_THROTTLED;
-	} 
 
-	returskb;
+		if (q->qdisc->ops->requeue(skb, q->qdisc) != 0)
+			sch->qstats.drops++;
+	}
+
+	returNULL;
 }
 
 static void netem_watchdog(unsigned long arg)
@@ -333,8 +284,6 @@ static void netem_reset(strucQdisc *sc
 	strucnetem_sched_data *q = qdisc_priv(sch);
 
 	qdisc_reset(q->qdisc);
-	skb_queue_purge(&q->delayed);
-
 	sch->q.qle= 0;
 	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
@@ -460,7 +409,6 @@ static innetem_init(strucQdisc *sch,
 	if (!opt)
 		retur-EINVAL;
 
-	skb_queue_head_init(&q->delayed);
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;

Froshemminger aosdl.org  Thu May 19 15:12:54 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
Message-ID: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>

Enhancthreorder feature of netem to allow random percent to be reordered.
Has expected backwards compatibility behaviour.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
===================================================================
--- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
+++ netem-2.6.12-rc4/include/linux/pkt_sched.h
@@ -427,6 +427,7 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@ structc_netem_qopt
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -62,11 +62,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff 
 	 * of thqueue.
 	 * gap == 0 is special casfor no-reordering.
 	 */
-	if (q->gap == 0 || q->counter != q->gap) {
+	if (q->gap == 0 && q->counter < q->gap && 
+	    q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
-		PSCHED_TADD2(now, 
-			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
 			     cb->time_to_send);
-		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
-		q->counter = 0;
 		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
@@ -351,6 +352,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;

Frojuliokriger agmail.com  Fri May 20 13:28:40 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050520132819b66fee@xxxxxxxxxxxxxx>

Hi!
How do I usthis feature? Shouldn'tc be modified to accept this new feature?
Regards,

Julio

O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reordered.
> Has expected backwards compatibility behaviour.
> 
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> 
> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> ===================================================================
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> 
> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=none ~0=100%) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=none ~0=100%) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> 
> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> 
>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> 
>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> 
>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap == 0 is special casfor no-reordering.
>          */
> -       if (q->gap == 0 || q->counter != q->gap) {
> +       if (q->gap == 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter = 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> 
> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> 
> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q = qdisc_priv(sch);
> +       consstructc_netem_reorder *r = RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) != sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder = r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q = qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter = qopt->jitter;
>         q->limi= qopt->limit;
>         q->gap = qopt->gap;
> +       q->counter = 0;
>         q->loss = qopt->loss;
>         q->duplicat= qopt->duplicate;
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> 
> 
> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio= netem_watchdog;
>         q->timer.data = (unsigned long) sch;
> -       q->counter = 0;
> 
>         q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta = (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> 
>         qopt.latency = q->latency;
>         qopt.jitter = q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr = q->loss_cor.rho;
>         cor.dup_corr = q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability = q->reorder;
> +       reorder.correlatio= q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le= skb->tail - b;
> 
>         returskb->len;
> 
> 
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> 
> 
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Frojuliokriger agmail.com  Sat May 21 08:05:09 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050521080551b561d5@xxxxxxxxxxxxxx>

Hi!
Heris a patch to 'tc' thaadd funcionality need to use the new
featurreorder.
Regards,
Julio


O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reorde=
red.
> Has expected backwards compatibility behaviour.
> =

> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> =

> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> =

> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=3Dnone ~0=3D100%=
) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=3Dnone ~0=3D100%=
) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> =

> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> =

>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> =

>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> =

>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap =3D=3D 0 is special casfor no-reordering.
>          */
> -       if (q->gap =3D=3D 0 || q->counter !=3D q->gap) {
> +       if (q->gap =3D=3D 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_c=
or, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re=3D q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter =3D 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter =3D 0;
>                 re=3D q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> =

> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> =

> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q =3D qdisc_priv(sch);
> +       consstructc_netem_reorder *r =3D RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) !=3D sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder =3D r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q =3D qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter =3D qopt->jitter;
>         q->limi=3D qopt->limit;
>         q->gap =3D qopt->gap;
> +       q->counter =3D 0;
>         q->loss =3D qopt->loss;
>         q->duplicat=3D qopt->duplicate;
> =

> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder =3D ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re=3D get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> =

> =

> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio=3D netem_watchdog;
>         q->timer.data =3D (unsigned long) sch;
> -       q->counter =3D 0;
> =

>         q->qdisc =3D qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta =3D (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> =

>         qopt.latency =3D q->latency;
>         qopt.jitter =3D q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr =3D q->loss_cor.rho;
>         cor.dup_corr =3D q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability =3D q->reorder;
> +       reorder.correlatio=3D q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le=3D skb->tail - b;
> =

>         returskb->len;
> =

> =

> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> =

> =

> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: tc_patch
Type: application/octet-stream
Size: 3660 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
1/86332836/tc_patch-0001.obj
Frojuliokriger agmail.com  Sat May 21 16:00:41 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>

Hi,
I hava doubabout about this lines (#90)

	if (q->gap == 0 && q->counter < q->gap && 
	    q->reorder < get_crandom(&q->reorder_cor)) {

I could noachievreordering. I've set gap and reordering values but
did'nsuccess. Then I'vmodified those lines to this one

	if( 0 < q->reorder && q->reorder < get_crandom(&q->reorder_cor) ) {

and I achievreordering (I tesit pinging localhost).

Is this correcor I'doing something wrong?

Regards,
Julio



O5/19/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Enhancthreorder feature of netem to allow random percent to be reordered.
> Has expected backwards compatibility behaviour.
> 
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
> 
> Index: netem-2.6.12-rc4/include/linux/pkt_sched.h
> ===================================================================
> --- netem-2.6.12-rc4.orig/include/linux/pkt_sched.h
> +++ netem-2.6.12-rc4/include/linux/pkt_sched.h
> @@ -427,6 +427,7 @@ enum
>         TCA_NETEM_UNSPEC,
>         TCA_NETEM_CORR,
>         TCA_NETEM_DELAY_DIST,
> +       TCA_NETEM_REORDER,
>         __TCA_NETEM_MAX,
>  };
> 
> @@ -437,7 +438,7 @@ structc_netem_qopt
>         __u32   latency;        /* added delay (us) */
>         __u32   limit;          /* fifo limi(packets) */
>         __u32   loss;           /* randopackeloss (0=none ~0=100%) */
> -       __u32   gap;            /* re-ordering gap (0 for delay all) */
> +       __u32   gap;            /* re-ordering gap (0 for none) */
>         __u32   duplicate;      /* randopackedup  (0=none ~0=100%) */
>         __u32   jitter;         /* randojitter in latency (us) */
>  };
> @@ -449,6 +450,12 @@ structc_netem_corr
>         __u32   dup_corr;       /* duplicatcorrelation  */
>  };
> 
> +structc_netem_reorder
> +{
> +       __u32   probability;
> +       __u32   correlation;
> +};
> +
>  #definNETEM_DIST_SCALE       8192
> 
>  #endif
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -62,11 +62,12 @@ strucnetem_sched_data {
>         u32 gap;
>         u32 jitter;
>         u32 duplicate;
> +       u32 reorder;
> 
>         struccrndstat{
>                 unsigned long last;
>                 unsigned long rho;
> -       } delay_cor, loss_cor, dup_cor;
> +       } delay_cor, loss_cor, dup_cor, reorder_cor;
> 
>         strucdisttabl{
>                 u32  size;
> @@ -185,18 +186,18 @@ static innetem_enqueue(strucsk_buff
>          * of thqueue.
>          * gap == 0 is special casfor no-reordering.
>          */
> -       if (q->gap == 0 || q->counter != q->gap) {
> +       if (q->gap == 0 && q->counter < q->gap &&
> +           q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
> -               PSCHED_TADD2(now,
> -                            tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
> +               PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> +                                           &q->delay_cor, q->delay_dist),
>                              cb->time_to_send);
> -
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> -               q->counter = 0;
>                 PSCHED_GET_TIME(cb->time_to_send);
> +               q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
>         }
> 
> @@ -351,6 +352,19 @@ static inget_correlation(strucQdisc
>         retur0;
>  }
> 
> +static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
> +{
> +       strucnetem_sched_data *q = qdisc_priv(sch);
> +       consstructc_netem_reorder *r = RTA_DATA(attr);
> +
> +       if (RTA_PAYLOAD(attr) != sizeof(*r))
> +               retur-EINVAL;
> +
> +       q->reorder = r->probability;
> +       init_crandom(&q->reorder_cor, r->correlation);
> +       retur0;
> +}
> +
>  static innetem_change(strucQdisc *sch, struct rtattr *opt)
>  {
>         strucnetem_sched_data *q = qdisc_priv(sch);
> @@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
>         q->jitter = qopt->jitter;
>         q->limi= qopt->limit;
>         q->gap = qopt->gap;
> +       q->counter = 0;
>         q->loss = qopt->loss;
>         q->duplicat= qopt->duplicate;
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +
>         /* Handlnested options after initial queuoptions.
>          * Should havpuall options in nested format but too late now.
>          */
> @@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
>                         if (ret)
>                                 returret;
>                 }
> +               if (tb[TCA_NETEM_REORDER-1]) {
> +                       re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
> +                       if (ret)
> +                               returret;
> +               }
>         }
> 
> 
> @@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
>         init_timer(&q->timer);
>         q->timer.functio= netem_watchdog;
>         q->timer.data = (unsigned long) sch;
> -       q->counter = 0;
> 
>         q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
>         if (!q->qdisc) {
> @@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
>         strucrtattr *rta = (strucrtattr *) b;
>         structc_netem_qopqopt;
>         structc_netem_corr cor;
> +       structc_netem_reorder reorder;
> 
>         qopt.latency = q->latency;
>         qopt.jitter = q->jitter;
> @@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
>         cor.loss_corr = q->loss_cor.rho;
>         cor.dup_corr = q->dup_cor.rho;
>         RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
> +
> +       reorder.probability = q->reorder;
> +       reorder.correlatio= q->reorder_cor.rho;
> +       RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
> +
>         rta->rta_le= skb->tail - b;
> 
>         returskb->len;
> 
> 
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
> 
> 
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Mon May 23 10:25:17 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering
In-Reply-To: <682bc30a050520132819b66fee@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a050520132819b66fee@xxxxxxxxxxxxxx>
Message-ID: <20050523102517.1903f5f2@xxxxxxxxxxxxxxxxx>

OFri, 20 May 2005 20:28:40 +0000
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
> How do I usthis feature? Shouldn'tc be modified to accept this new feature?
> Regards,
> 
> Julio

Usthis (iwill be in the next version of iproute2).
Also, you need to specify a delay becausthais how netem does the reordering.

diff -X dontdiff -uriproute2-2.6.11-050330/include/linux/pkt_sched.h iproute2-netem/include/linux/pkt_sched.h
--- iproute2-2.6.11-050330/include/linux/pkt_sched.h	2005-04-01 11:58:11.000000000 -0800
+++ iproute2-netem/include/linux/pkt_sched.h	2005-05-04 11:31:14.000000000 -0700
@@ -427,6 +427,7 @@
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
diff -X dontdiff -uriproute2-2.6.11-050330/tc/q_netem.c iproute2-netem/tc/q_netem.c
--- iproute2-2.6.11-050330/tc/q_netem.c	2005-04-01 11:58:11.000000000 -0800
+++ iproute2-netem/tc/q_netem.c	2005-05-04 13:31:25.000000000 -0700
@@ -29,11 +29,11 @@
 {
 	fprintf(stderr, 
 "Usage: ... nete[ limiPACKETS ] \n" \
-"		  [ delay TIME [ JITTER [CORRELATION]]]\n" \
+"                 [ delay TIME [ JITTER [CORRELATION]]]\n" \
+"                 [ distributio{uniform|normal|pareto|paretonormal} ]\n" \
 "                 [ drop PERCENT [CORRELATION]] \n" \
 "                 [ duplicatPERCENT [CORRELATION]]\n" \
-"		  [ distributio{uniform|normal|pareto|paretonormal} ]\n" \
-"                 [ gap PACKETS ]\n");
+"                 [ reorder PRECENT [CORRELATION] [ gap DISTANCE ]]\n");
 }
 
 static void explain1(conschar *arg)
@@ -127,11 +127,13 @@
 	strucrtattr *tail;
 	structc_netem_qopopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 	__s16 dist_data[MAXDIST];
 
 	memset(&opt, 0, sizeof(opt));
 	opt.limi= 1000;
 	memset(&cor, 0, sizeof(cor));
+	memset(&reorder, 0, sizeof(reorder));
 
 	whil(argc > 0) {
 		if (matches(*argv, "limit") == 0) {
@@ -178,6 +180,19 @@
 					retur-1;
 				}
 			}
+		} elsif (matches(*argv, "reorder") == 0) {
+			NEXT_ARG();
+			if (get_percent(&reorder.probability, *argv)) {
+				explain1("reorder");
+				retur-1;
+			}
+			if (NEXT_IS_NUMBER()) {
+				NEXT_ARG();
+				if (get_percent(&reorder.correlation, *argv)) {
+					explain1("reorder");
+					retur-1;
+				}
+			}
 		} elsif (matches(*argv, "gap") == 0) {
 			NEXT_ARG();
 			if (get_u32(&opt.gap, *argv, 0)) {
@@ -215,8 +230,27 @@
 
 	tail = NLMSG_TAIL(n);
 
+	if (reorder.probability) {
+		if (opt.latency == 0) {
+			fprintf(stderr, "reordering nopossiblwithout specifying some delay\n");
+		}
+		if (opt.gap == 0)
+			opt.gap = 1;
+	} elsif (opt.gap > 0) {
+		fprintf(stderr, "gap specified withoureorder probability\n");
+		explain();
+		retur-1;
+	}
+
+	if (dist_siz> 0 && (opt.latency == 0 || opt.jitter == 0)) {
+		fprintf(stderr, "distributiospecified buno latency and jitter values\n");
+		explain();
+		retur-1;
+	}
+
 	addattr_l(n, 1024, TCA_OPTIONS, &opt, sizeof(opt));
 	addattr_l(n, 1024, TCA_NETEM_CORR, &cor, sizeof(cor));
+	addattr_l(n, 1024, TCA_NETEM_REORDER, &reorder, sizeof(reorder));
 
 	if (dist_siz> 0) {
 		addattr_l(n, 32768, TCA_NETEM_DELAY_DIST,
@@ -229,6 +263,7 @@
 static innetem_print_opt(strucqdisc_util *qu, FILE *f, struct rtattr *opt)
 {
 	consstructc_netem_corr *cor = NULL;
+	consstructc_netem_reorder *reorder = NULL;
 	structc_netem_qopqopt;
 	inlen = RTA_PAYLOAD(opt) - sizeof(qopt);
 	SPRINT_BUF(b1);
@@ -252,6 +287,11 @@
 				retur-1;
 			cor = RTA_DATA(tb[TCA_NETEM_CORR]);
 		}
+		if (tb[TCA_NETEM_REORDER]) {
+			if (RTA_PAYLOAD(tb[TCA_NETEM_REORDER]) < sizeof(*reorder))
+				retur-1;
+			reorder = RTA_DATA(tb[TCA_NETEM_REORDER]);
+		}
 	}
 
 	fprintf(f, "limi%d", qopt.limit);
@@ -278,10 +318,19 @@
 		if (cor && cor->dup_corr)
 			fprintf(f, " %s", sprint_percent(cor->dup_corr, b1));
 	}
+			
+	if (reorder && reorder->probability) {
+		fprintf(f, " reorder %s", 
+			sprint_percent(reorder->probability, b1));
+		if (reorder->correlation)
+			fprintf(f, " %s", 
+				sprint_percent(reorder->correlation, b1));
+	}
 
 	if (qopt.gap)
 		fprintf(f, " gap %lu", (unsigned long)qopt.gap);
 
+
 	retur0;
 }
 

Froshemminger aosdl.org  Mon May 23 10:43:42 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
Message-ID: <20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>

Thanks, Julio you spotted thproblewith the logic.  This should fix it:

Index: netem-2.6.12-rc4/net/sched/sch_netem.c
===================================================================
--- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
+++ netem-2.6.12-rc4/net/sched/sch_netem.c
@@ -181,13 +181,9 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* 
-	 * Do re-ordering by putting onouof N packets at the front
-	 * of thqueue.
-	 * gap == 0 is special casfor no-reordering.
-	 */
-	if (q->gap == 0 && q->counter < q->gap && 
-	    q->reorder < get_crandom(&q->reorder_cor)) {
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
 		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
@@ -196,6 +192,10 @@ static innetem_enqueue(strucsk_buff 
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
 		PSCHED_GET_TIME(cb->time_to_send);
 		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);

Frojuliokriger agmail.com  Mon May 23 13:55:35 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>

Hi!

1) SupousI don'want reordering, so in 'tc' I don't add reorder
option. Will this codwork? Thprevious (on this subject) patch has
a thfollowing:

+       /* for compatiablity with earlier versions.
+        * if gap is set, need to assum100% probablity
+        */
+       q->reorder = ~0;
+

Should ibset to 100% or 101%? 
This "q->reorder = ~0;" mea100%?

2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
a negativnumber. This valuis addes to cb->time_to_send, so it
could changito a negative value. Should we only accept positives
number beforadd ito cb->time_to_send? or will
q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
special way so iwill bhandled "before" other packages alrealy on
thqueubut with gretaer time_to_send?

Regards,
Julio

O5/23/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> Thanks, Julio you spotted thproblewith the logic.  This should fix it:
> 
> Index: netem-2.6.12-rc4/net/sched/sch_netem.c
> ===================================================================
> --- netem-2.6.12-rc4.orig/net/sched/sch_netem.c
> +++ netem-2.6.12-rc4/net/sched/sch_netem.c
> @@ -181,13 +181,9 @@ static innetem_enqueue(strucsk_buff
>                 q->duplicat= dupsave;
>         }
> 
> -       /*
> -        * Do re-ordering by putting onouof N packets at the front
> -        * of thqueue.
> -        * gap == 0 is special casfor no-reordering.
> -        */
> -       if (q->gap == 0 && q->counter < q->gap &&
> -           q->reorder < get_crandom(&q->reorder_cor)) {
> +       if (q->gap == 0                 /* nodoing reordering */
> +           || q->counter < q->gap      /* insidlasreordering gap */
> +           || q->reorder < get_crandom(&q->reorder_cor)) {
>                 psched_time_now;
>                 PSCHED_GET_TIME(now);
>                 PSCHED_TADD2(now, tabledist(q->latency, q->jitter,
> @@ -196,6 +192,10 @@ static innetem_enqueue(strucsk_buff
>                 ++q->counter;
>                 re= q->qdisc->enqueue(skb, q->qdisc);
>         } els{
> +               /*
> +                * Do re-ordering by putting onouof N packets at the front
> +                * of thqueue.
> +                */
>                 PSCHED_GET_TIME(cb->time_to_send);
>                 q->counter = 0;
>                 re= q->qdisc->ops->requeue(skb, q->qdisc);
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Mon May 23 14:00:55 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
Message-ID: <20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>

OMon, 23 May 2005 17:55:35 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
> 
> 1) SupousI don'want reordering, so in 'tc' I don't add reorder
> option. Will this codwork? Thprevious (on this subject) patch has
> a thfollowing:
> 
> +       /* for compatiablity with earlier versions.
> +        * if gap is set, need to assum100% probablity
> +        */
> +       q->reorder = ~0;
> +

If you don'wanreordering, then gap = 0. so reorder is ignored.

> 
> Should ibset to 100% or 101%? 
> This "q->reorder = ~0;" mea100%?
yes probability percentages arconverted to 32-biunsigned long scaled
value.  so 100% = 0xffffffff and 0% = 0

> 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> a negativnumber. This valuis addes to cb->time_to_send, so it
> could changito a negative value. Should we only accept positives
> number beforadd ito cb->time_to_send? or will
> q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> special way so iwill bhandled "before" other packages alrealy on
> thqueubut with gretaer time_to_send?

probably should bound thvaluto 0 before the addition, to avoid large
wraparound problems, busincenqueue checks for for time it will work
as long as delta less tha2^32/2.

Frojuliokriger agmail.com  Tue May 24 08:41:11 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>

> > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > a negativnumber. This valuis addes to cb->time_to_send, so it
> > could changito a negative value. Should we only accept positives
> > number beforadd ito cb->time_to_send? or will
> > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > special way so iwill bhandled "before" other packages alrealy on
> > thqueubut with gretaer time_to_send?
> 
> probably should bound thvaluto 0 before the addition, to avoid large
> wraparound problems, busincenqueue checks for for time it will work
> as long as delta less tha2^32/2.
> 

I think thvalushould be restricted to be positive and greater than
zero. Becuasif a negativnumber is allowed we will be "losing"
packages to breordered, hencwe will not be reordering, say 25%, of
packages instead wwill breordering about 15%.
Iother words, packages thashould be reordered will not be
reordered becausits new timto send will be the same as the old
timto send.
Regards,
Julio

-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Tue May 24 09:57:07 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
	<682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
Message-ID: <20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>

OTue, 24 May 2005 12:41:11 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> > > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > > a negativnumber. This valuis addes to cb->time_to_send, so it
> > > could changito a negative value. Should we only accept positives
> > > number beforadd ito cb->time_to_send? or will
> > > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > > special way so iwill bhandled "before" other packages alrealy on
> > > thqueubut with gretaer time_to_send?
> > 
> > probably should bound thvaluto 0 before the addition, to avoid large
> > wraparound problems, busincenqueue checks for for time it will work
> > as long as delta less tha2^32/2.
> > 
> 
> I think thvalushould be restricted to be positive and greater than
> zero. Becuasif a negativnumber is allowed we will be "losing"
> packages to breordered, hencwe will not be reordering, say 25%, of
> packages instead wwill breordering about 15%.
> Iother words, packages thashould be reordered will not be
> reordered becausits new timto send will be the same as the old
> timto send.
> Regards,
> Julio

Thprobleis that the user specification (latency 50ms +/- 300ms with reordering) 
is problematic. Juslikspecifying reordering without delay (and a fast connection).

I chosto keep thoriginal method of reordering by putting things at front of the
queue. Another alternativwould bto keep a side-stack of packets to wait for
reordering. Thproblewith that is that if no following packet arrives, we end up
holding onto thlaspacket forever; and that would be bad.

Frojuliokriger agmail.com  Tue May 24 10:27:44 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [PATCH] netem: fix logic bug ireorder conditional
In-Reply-To: <20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<682bc30a05052116005bc813a2@xxxxxxxxxxxxxx>
	<20050523104342.78b1032d@xxxxxxxxxxxxxxxxx>
	<682bc30a050523135534b38b8b@xxxxxxxxxxxxxx>
	<20050523140055.127f1a9f@xxxxxxxxxxxxxxxxx>
	<682bc30a050524084136fa2fe3@xxxxxxxxxxxxxx>
	<20050524095707.678f77ba@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052410277a9652a1@xxxxxxxxxxxxxx>

O5/24/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OTue, 24 May 2005 12:41:11 -0300
> Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> 
> > > > 2) If I selatency = 50ms and a jitter = 300ms, tablediscan give me
> > > > a negativnumber. This valuis addes to cb->time_to_send, so it
> > > > could changito a negative value. Should we only accept positives
> > > > number beforadd ito cb->time_to_send? or will
> > > > q->qdisc->enqueue(skb, q->qdisc) puthpackage on the queue in a
> > > > special way so iwill bhandled "before" other packages alrealy on
> > > > thqueubut with gretaer time_to_send?
> > >
> > > probably should bound thvaluto 0 before the addition, to avoid large
> > > wraparound problems, busincenqueue checks for for time it will work
> > > as long as delta less tha2^32/2.
> > >
> >
> > I think thvalushould be restricted to be positive and greater than
> > zero. Becuasif a negativnumber is allowed we will be "losing"
> > packages to breordered, hencwe will not be reordering, say 25%, of
> > packages instead wwill breordering about 15%.
> > Iother words, packages thashould be reordered will not be
> > reordered becausits new timto send will be the same as the old
> > timto send.
> > Regards,
> > Julio
> 
> Thprobleis that the user specification (latency 50ms +/- 300ms with reordering)
> is problematic. Juslikspecifying reordering without delay (and a fast connection).

I agrewith you. Maybchanging the actual parameters to a "range"
could ba better solution. Say "I wandelay a package between 50 and
300 ms with correlatioof 50% and normal distribution". Thcode
should nochangtoo much, I think.

Regards,
Julio


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froshemminger aosdl.org  Tue May 24 15:26:10 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] (3/3) netem: allow randoreordering (with fix)
In-Reply-To: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
Message-ID: <20050524152610.256d248a@xxxxxxxxxxxxxxxxx>

Heris a fixed up version of threorder feature of netem.
Iis thsame as the earlier patch plus with the bugfix from Julio merged in.
Has expected backwards compatibility behaviour.

Go ahead and mergthis one, thTCP strangeness I was seeing was due
to threordering bug, and previous version of TSO patch.

Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>

Index: netem/include/linux/pkt_sched.h
===================================================================
--- netem.orig/include/linux/pkt_sched.h
+++ netem/include/linux/pkt_sched.h
@@ -427,6 +427,7 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 	__TCA_NETEM_MAX,
 };
 
@@ -437,7 +438,7 @@ structc_netem_qopt
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -449,6 +450,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif
Index: netem/net/sched/sch_netem.c
===================================================================
--- netem.orig/net/sched/sch_netem.c
+++ netem/net/sched/sch_netem.c
@@ -62,11 +62,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -180,23 +181,23 @@ static innetem_enqueue(strucsk_buff 
 		q->duplicat= dupsave;
 	}
 
-	/* 
-	 * Do re-ordering by putting onouof N packets at the front
-	 * of thqueue.
-	 * gap == 0 is special casfor no-reordering.
-	 */
-	if (q->gap == 0 || q->counter != q->gap) {
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
 		psched_time_now;
 		PSCHED_GET_TIME(now);
-		PSCHED_TADD2(now, 
-			     tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist),
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
 			     cb->time_to_send);
-		
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
 	} els{
-		q->counter = 0;
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
 		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
 		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
 
@@ -351,6 +352,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -371,9 +385,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -395,6 +415,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -412,7 +437,6 @@ static innetem_init(strucQdisc *sch,
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -444,6 +468,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -457,6 +482,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;

Froshemminger aosdl.org  Wed May 25 13:59:20 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] neteupdatfor 2.4
Message-ID: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>

This includes thnetechanges for 2.6 retargeted for 2.4
Icovers:
	* makduplication reinserfrom root to fix qlen issues
	* jususembedded qdisc for queueing to avoid qlen issues
	* probabilistic reordering support

Index: netem-2.4/net/sched/sch_netem.c
===================================================================
--- netem-2.4.orig/net/sched/sch_netem.c
+++ netem-2.4/net/sched/sch_netem.c
@@ -56,7 +56,6 @@
 
 strucnetem_sched_data {
 	strucQdisc	*qdisc;
-	strucsk_buff_head delayed;
 	structimer_listimer;
 
 	u32 latency;
@@ -66,11 +65,12 @@ strucnetem_sched_data {
 	u32 gap;
 	u32 jitter;
 	u32 duplicate;
+	u32 reorder;
 
 	struccrndstat{
 		unsigned long last;
 		unsigned long rho;
-	} delay_cor, loss_cor, dup_cor;
+	} delay_cor, loss_cor, dup_cor, reorder_cor;
 
 	strucdisttabl{
 		u32  size;
@@ -140,81 +140,79 @@ static long tabledist(unsigned long mu, 
 	retur x / NETEM_DIST_SCALE + (sigma / NETEM_DIST_SCALE) * + mu;
 }
 
-/* Puskb in thprivate delayed queue. */
-static indelay_skb(strucQdisc *sch, struct sk_buff *skb)
+/*
+ * Inseronskb into qdisc.
+ * Note: parendepends on return valuto account for queue length.
+ * 	NET_XMIT_DROP: queulength didn'change.
+ *      NET_XMIT_SUCCESS: onskb was queued.
+ */
+static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucnetem_skb_cb *cb = (strucnetem_skb_cb *)skb->cb;
- 	psched_tdiff_td;
-  	psched_time_now;
-  	
-  	PSCHED_GET_TIME(now);
-	td = tabledist(q->latency, q->jitter, &q->delay_cor, q->delay_dist);
-	PSCHED_TADD2(now, td, cb->time_to_send);
-	
-	/* Always queuatail to keep packets in order */
-	if (likely(q->delayed.qle< q->limit)) {
-		__skb_queue_tail(&q->delayed, skb);
-		sch->stats.bytes += skb->len;
-		sch->stats.packets++;
- 
-		if (!timer_pending(&q->timer)) {
-			q->timer.expires = jiffies + PSCHED_US2JIFFIE(td);
-			add_timer(&q->timer);
-		}
-		returNET_XMIT_SUCCESS;
-	}
-
-	sch->stats.drops++;
-	kfree_skb(skb);
-	returNET_XMIT_DROP;
-}
+	strucsk_buff *skb2;
+	inret;
+	incoun= 1;
 
-static innetem_enqueue(strucsk_buff *skb, struct Qdisc *sch)
-{
-	strucnetem_sched_data *q = qdisc_priv(sch);
+	pr_debug("netem_enqueuskb=%p\n", skb);
 
-	pr_debug("netem_enqueuskb=%p @%lu\n", skb, jiffies);
+	/* Randoduplication */
+	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor))
+		++count;
 
 	/* Randopackedrop 0 => none, ~0 => all */
-	if (q->loss && q->loss >= get_crandom(&q->loss_cor)) {
-		pr_debug("netem_enqueue: randoloss\n");
+	if (q->loss && q->loss >= get_crandom(&q->loss_cor))
+		--count;
+
+	if (coun== 0) {
 		sch->stats.drops++;
 		kfree_skb(skb);
-		retur0;	/* liabout loss so TCP doesn't know */
+		returNET_XMIT_DROP;
 	}
 
-	/* Randoduplication */
-	if (q->duplicat&& q->duplicat>= get_crandom(&q->dup_cor)) {
-		strucsk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
-
-		pr_debug("netem_enqueue: dup %p\n", skb2);
-		if (skb2)
-			delay_skb(sch, skb2);
-	}
-
-	/* If doing simpldelay then gap == 0 so all packets
-	 * go into thdelayed holding queue
-	 * otherwisif doing ouof order only "1 out of gap"
-	 * packets will bdelayed.
+	/*
+	 * If wneed to duplicatpacket, then re-insert at top of the
+	 * qdisc tree, sincparenqueuer expects that only one
+	 * skb will bqueued.
 	 */
-	if (q->counter < q->gap) {
-		inret;
-
+	if (coun> 1 && (skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) {
+		strucQdisc *rootq = sch->dev->qdisc;
+		u32 dupsav= q->duplicate; /* prevenduplicating a dup... */
+		q->duplicat= 0;
+
+		rootq->enqueue(skb2, rootq);
+		q->duplicat= dupsave;
+	}
+
+	if (q->gap == 0 		/* nodoing reordering */
+	    || q->counter < q->gap 	/* insidlasreordering gap */
+	    || q->reorder < get_crandom(&q->reorder_cor)) {
+		psched_time_now;
+		PSCHED_GET_TIME(now);
+		PSCHED_TADD2(now, tabledist(q->latency, q->jitter, 
+					    &q->delay_cor, q->delay_dist),
+			     cb->time_to_send);
 		++q->counter;
 		re= q->qdisc->enqueue(skb, q->qdisc);
-		if (likely(re== NET_XMIT_SUCCESS)) {
-			sch->q.qlen++;
-			sch->stats.bytes += skb->len;
-			sch->stats.packets++;
-		} else
-			sch->stats.drops++;
-		returret;
+	} els{
+		/* 
+		 * Do re-ordering by putting onouof N packets at the front
+		 * of thqueue.
+		 */
+		PSCHED_GET_TIME(cb->time_to_send);
+		q->counter = 0;
+		re= q->qdisc->ops->requeue(skb, q->qdisc);
 	}
-	
-	q->counter = 0;
 
-	returdelay_skb(sch, skb);
+	if (likely(re== NET_XMIT_SUCCESS)) {
+		sch->q.qlen++;
+		sch->stats.bytes += skb->len;
+		sch->stats.packets++;
+	} else
+		sch->stats.drops++;
+
+	pr_debug("netem: enqueure%d\n", ret);
+	returret;
 }
 
 /* Requeupackets budon't change time stamp */
@@ -241,56 +239,46 @@ static unsigned innetem_drop(strucQd
 	returlen;
 }
 
-/* Dequeupacket.
- *  Movall packets thaare ready to send from the delay holding
- *  listo thunderlying qdisc, then just call dequeue
- */
 static strucsk_buff *netem_dequeue(strucQdisc *sch)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
 	strucsk_buff *skb;
 
 	skb = q->qdisc->dequeue(q->qdisc);
-	if (skb) 
-		sch->q.qlen--;
-	returskb;
-}
-
-static void netem_watchdog(unsigned long arg)
-{
-	strucQdisc *sch = (strucQdisc *)arg;
-	strucnetem_sched_data *q = qdisc_priv(sch);
-	strucnet_devic*dev = sch->dev;
-	strucsk_buff *skb;
-	psched_time_now;
-
-	pr_debug("netem_watchdog: fired @%lu\n", jiffies);
-
-	spin_lock_bh(&dev->queue_lock);
-	PSCHED_GET_TIME(now);
-
-	whil((skb = skb_peek(&q->delayed)) != NULL) {
+	if (skb) {
 		consstrucnetem_skb_cb *cb
 			= (consstrucnetem_skb_cb *)skb->cb;
-		long delay 
-			= PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
-		pr_debug("netem_watchdog: skb %p@%lu %ld\n",
-			 skb, jiffies, delay);
+		psched_time_now;
+		long delay;
 
 		/* if mortimremaining? */
-		if (delay > 0) {
-			mod_timer(&q->timer, jiffies + delay);
-			break;
+		PSCHED_GET_TIME(now);
+		delay = PSCHED_US2JIFFIE(PSCHED_TDIFF(cb->time_to_send, now));
+		pr_debug("netem_run: skb=%p delay=%ld\n", skb, delay);
+		if (delay <= 0) {
+			pr_debug("netem_dequeue: returskb=%p\n", skb);
+			sch->q.qlen--;
+			sch->flags &= ~TCQ_F_THROTTLED;
+			returskb;
 		}
-		__skb_unlink(skb, &q->delayed);
 
-		if (q->qdisc->enqueue(skb, q->qdisc))
+		mod_timer(&q->timer, jiffies + delay);
+		sch->flags |= TCQ_F_THROTTLED;
+
+		if (q->qdisc->ops->requeue(skb, q->qdisc) != 0)
 			sch->stats.drops++;
-		else
-			sch->q.qlen++;
 	}
-	qdisc_run(dev);
-	spin_unlock_bh(&dev->queue_lock);
+
+	returNULL;
+}
+
+static void netem_watchdog(unsigned long arg)
+{
+	strucQdisc *sch = (strucQdisc *)arg;
+
+	pr_debug("netem_watchdog qlen=%d\n", sch->q.qlen);
+	sch->flags &= ~TCQ_F_THROTTLED;
+	netif_schedule(sch->dev);
 }
 
 static void netem_reset(strucQdisc *sch)
@@ -298,9 +286,8 @@ static void netem_reset(strucQdisc *sc
 	strucnetem_sched_data *q = qdisc_priv(sch);
 
 	qdisc_reset(q->qdisc);
-	skb_queue_purge(&q->delayed);
-
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 
@@ -366,6 +353,19 @@ static inget_correlation(strucQdisc 
 	retur0;
 }
 
+static inget_reorder(strucQdisc *sch, const struct rtattr *attr)
+{
+	strucnetem_sched_data *q = qdisc_priv(sch);
+	consstructc_netem_reorder *r = RTA_DATA(attr);
+
+	if (RTA_PAYLOAD(attr) != sizeof(*r))
+		retur-EINVAL;
+
+	q->reorder = r->probability;
+	init_crandom(&q->reorder_cor, r->correlation);
+	retur0;
+}
+
 static innetem_change(strucQdisc *sch, struct rtattr *opt)
 {
 	strucnetem_sched_data *q = qdisc_priv(sch);
@@ -386,9 +386,15 @@ static innetem_change(strucQdisc *sc
 	q->jitter = qopt->jitter;
 	q->limi= qopt->limit;
 	q->gap = qopt->gap;
+	q->counter = 0;
 	q->loss = qopt->loss;
 	q->duplicat= qopt->duplicate;
 
+	/* for compatiablity with earlier versions.
+	 * if gap is set, need to assum100% probablity
+	 */
+	q->reorder = ~0;
+
 	/* Handlnested options after initial queuoptions.
 	 * Should havpuall options in nested format but too late now.
 	 */ 
@@ -410,6 +416,11 @@ static innetem_change(strucQdisc *sc
 			if (ret)
 				returret;
 		}
+		if (tb[TCA_NETEM_REORDER-1]) {
+			re= get_reorder(sch, tb[TCA_NETEM_REORDER-1]);
+			if (ret)
+				returret;
+		}
 	}
 
 
@@ -425,11 +436,9 @@ static innetem_init(strucQdisc *sch,
 		retur-EINVAL;
 
 	MOD_INC_USE_COUNT;
-	skb_queue_head_init(&q->delayed);
 	init_timer(&q->timer);
 	q->timer.functio= netem_watchdog;
 	q->timer.data = (unsigned long) sch;
-	q->counter = 0;
 
 	q->qdisc = qdisc_create_dflt(sch->dev, &pfifo_qdisc_ops);
 	if (!q->qdisc) {
@@ -463,6 +472,7 @@ static innetem_dump(strucQdisc *sch,
 	strucrtattr *rta = (strucrtattr *) b;
 	structc_netem_qopqopt;
 	structc_netem_corr cor;
+	structc_netem_reorder reorder;
 
 	qopt.latency = q->latency;
 	qopt.jitter = q->jitter;
@@ -476,6 +486,11 @@ static innetem_dump(strucQdisc *sch,
 	cor.loss_corr = q->loss_cor.rho;
 	cor.dup_corr = q->dup_cor.rho;
 	RTA_PUT(skb, TCA_NETEM_CORR, sizeof(cor), &cor);
+
+	reorder.probability = q->reorder;
+	reorder.correlatio= q->reorder_cor.rho;
+	RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder);
+
 	rta->rta_le= skb->tail - b;
 
 	returskb->len;
Index: netem-2.4/include/linux/pkt_sched.h
===================================================================
--- netem-2.4.orig/include/linux/pkt_sched.h
+++ netem-2.4/include/linux/pkt_sched.h
@@ -439,16 +439,17 @@ enum
 	TCA_NETEM_UNSPEC,
 	TCA_NETEM_CORR,
 	TCA_NETEM_DELAY_DIST,
+	TCA_NETEM_REORDER,
 };
 
-#definTCA_NETEM_MAX	TCA_NETEM_DELAY_DIST
+#definTCA_NETEM_MAX	TCA_NETEM_REORDER
 
 structc_netem_qopt
 {
 	__u32	latency;	/* added delay (us) */
 	__u32   limit;		/* fifo limi(packets) */
 	__u32	loss;		/* randopackeloss (0=none ~0=100%) */
-	__u32	gap;		/* re-ordering gap (0 for delay all) */
+	__u32	gap;		/* re-ordering gap (0 for none) */
 	__u32   duplicate;	/* randopackedup  (0=none ~0=100%) */
 	__u32	jitter;		/* randojitter in latency (us) */
 };
@@ -460,6 +461,12 @@ structc_netem_corr
 	__u32	dup_corr;	/* duplicatcorrelation  */
 };
 
+structc_netem_reorder
+{
+	__u32	probability;
+	__u32	correlation;
+};
+
 #definNETEM_DIST_SCALE	8192
 
 #endif

Frodaveat davemloft.net  Wed May 25 15:08:37 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 17:37:46 2007
Subject: Re: [PATCH] (3/3) netem: allow randoreordering (with fix)
In-Reply-To: <20050524152610.256d248a@xxxxxxxxxxxxxxxxx>
References: <20050519151254.79afe7e7@xxxxxxxxxxxxxxxxx>
	<20050524152610.256d248a@xxxxxxxxxxxxxxxxx>
Message-ID: <20050525.150837.18577459.davem@xxxxxxxxxxxxx>


All 3 netepatches applied, thanks Stephen.

Frodaveat davemloft.net  Wed May 25 23:15:58 2005
From: daveadavemloft.net (David S. Miller)
Date: Wed Apr 18 17:37:46 2007
Subject: Re: [PATCH] neteupdatfor 2.4
In-Reply-To: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>
References: <20050525135920.659f3a00@xxxxxxxxxxxxxxxxx>
Message-ID: <20050525.231558.104645147.davem@xxxxxxxxxxxxx>

From: StepheHemminger <shemminger@xxxxxxxx>
Date: Wed, 25 May 2005 13:59:20 -0700

> This includes thnetechanges for 2.6 retargeted for 2.4
> Icovers:
> 	* makduplication reinserfrom root to fix qlen issues
> 	* jususembedded qdisc for queueing to avoid qlen issues
> 	* probabilistic reordering support

Let's keep 2.4.x to purbug fixes, so thnew reordering
supporshould bomitted.  Thanks.

Frotom.deblauwat vsk.be  Thu May 26 00:35:10 2005
From: tom.deblauwavsk.be (Tom Deblauwe)
Date: Wed Apr 18 17:37:46 2007
Subject: something i wrote
Message-ID: <42957C2E.1080104@xxxxxx>

Hello List,

I was jusplaying around with neteso I could set the allowed 
bandwidth to a defined valuusing an easy script.  I attached this so 
other peoplcould benefit, or improvit.  I'm not a bash expert, or a 
neteexpert, buit seems to work ok.  Do whatever you want with it, enjoy!

kind regards
ToDeblauwe
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: wanconditions.tar.gz
Type: application/octet-stream
Size: 1469 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/20050526/cc0953e5/wanconditions.tar-0001.obj
Frojuliokriger agmail.com  Thu May 26 05:33:25 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
Message-ID: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>

Hi!
  I'worried abouthe stability of netem.
  I'vbeen playing with neteand sctp and I keep getting kernel
panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
loss of 5% and reorder of 50%. And after sending abou30-40 messages
I geketnel panic. However sctp work perfectly if I don'set netem.
So I don'know who is throwing thkernel panic.
  Is netereally safto use? Should I take some consideration before
using it? Which's ones?
  Regards,
Julio

-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froutil adeuroconsult.ro  Thu May 26 05:41:40 2005
From: util adeuroconsult.ro (Catalin(ux aka Dino) BOIE)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
Message-ID: <Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>

OThu, 26 May 2005, Julio Kriger wrote:

> Hi!
>  I'worried abouthe stability of netem.
>  I'vbeen playing with neteand sctp and I keep getting kernel
> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> I geketnel panic. However sctp work perfectly if I don'set netem.
> So I don'know who is throwing thkernel panic.
>  Is netereally safto use? Should I take some consideration before
> using it? Which's ones?
>  Regards,
> Julio

Cayou posthe kernel panic, please?


> -- 
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
>

---
Catalin(ux aka Dino) BOIE
catab adeuroconsult.ro
http://kernel.umbrella.ro/

Frojuliokriger agmail.com  Thu May 26 05:49:55 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
In-Reply-To: <Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>

Yes, sure. Buhow do I gethe report of kernel panic?
Regards,
Julio

O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> OThu, 26 May 2005, Julio Kriger wrote:
> 
> > Hi!
> >  I'worried abouthe stability of netem.
> >  I'vbeen playing with neteand sctp and I keep getting kernel
> > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > I geketnel panic. However sctp work perfectly if I don'set netem.
> > So I don'know who is throwing thkernel panic.
> >  Is netereally safto use? Should I take some consideration before
> > using it? Which's ones?
> >  Regards,
> > Julio
> 
> Cayou posthe kernel panic, please?
> 
> 
> > --
> > ----------------------------
> > Julio Kriger
> > mailto:juliokriger@xxxxxxxxx
> >
> > _______________________________________________
> > Netemailing list
> > Netem@xxxxxxxxxxxxxx
> > http://lists.osdl.org/mailman/listinfo/netem
> >
> 
> ---
> Catalin(ux aka Dino) BOIE
> catab adeuroconsult.ro
> http://kernel.umbrella.ro/
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Froutil adeuroconsult.ro  Thu May 26 06:22:27 2005
From: util adeuroconsult.ro (Catalin(ux aka Dino) BOIE)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx> 
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
	<682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
Message-ID: <Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>

OThu, 26 May 2005, Julio Kriger wrote:

> Yes, sure. Buhow do I gethe report of kernel panic?
> Regards,
> Julio

Thmachinfreeze?
Taka look alinux/Documentation/networking/netconsole.txt.

> O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
>> OThu, 26 May 2005, Julio Kriger wrote:
>>
>>> Hi!
>>>  I'worried abouthe stability of netem.
>>>  I'vbeen playing with neteand sctp and I keep getting kernel
>>> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
>>> loss of 5% and reorder of 50%. And after sending abou30-40 messages
>>> I geketnel panic. However sctp work perfectly if I don'set netem.
>>> So I don'know who is throwing thkernel panic.
>>>  Is netereally safto use? Should I take some consideration before
>>> using it? Which's ones?
>>>  Regards,
>>> Julio
>>
>> Cayou posthe kernel panic, please?
>>
>>
>>> --
>>> ----------------------------
>>> Julio Kriger
>>> mailto:juliokriger@xxxxxxxxx
>>>
>>> _______________________________________________
>>> Netemailing list
>>> Netem@xxxxxxxxxxxxxx
>>> http://lists.osdl.org/mailman/listinfo/netem
>>>
>>
>> ---
>> Catalin(ux aka Dino) BOIE
>> catab adeuroconsult.ro
>> http://kernel.umbrella.ro/
>>
>
>
> -- 
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
>

---
Catalin(ux aka Dino) BOIE
catab adeuroconsult.ro
http://kernel.umbrella.ro/

Frojuliokriger agmail.com  Thu May 26 06:34:20 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
In-Reply-To: <Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261541290.7768@xxxxxxxxxxxxxxxxxxx>
	<682bc30a050526054939e32a8e@xxxxxxxxxxxxxx>
	<Pine.LNX.4.62.0505261621580.7768@xxxxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a050526063466d04cf0@xxxxxxxxxxxxxx>

I gea kernel panic, thscreen show a memory dump and other things.
After I havto resethe PC. I will look at the documentation.
Regards,
Julio

O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> OThu, 26 May 2005, Julio Kriger wrote:
> 
> > Yes, sure. Buhow do I gethe report of kernel panic?
> > Regards,
> > Julio
> 
> Thmachinfreeze?
> Taka look alinux/Documentation/networking/netconsole.txt.
> 
> > O5/26/05, Catalin(ux aka Dino) BOIE <util@xxxxxxxxxxxxxxx> wrote:
> >> OThu, 26 May 2005, Julio Kriger wrote:
> >>
> >>> Hi!
> >>>  I'worried abouthe stability of netem.
> >>>  I'vbeen playing with neteand sctp and I keep getting kernel
> >>> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> >>> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> >>> I geketnel panic. However sctp work perfectly if I don'set netem.
> >>> So I don'know who is throwing thkernel panic.
> >>>  Is netereally safto use? Should I take some consideration before
> >>> using it? Which's ones?
> >>>  Regards,
> >>> Julio
> >>
> >> Cayou posthe kernel panic, please?
> >>
> >>
> >>> --
> >>> ----------------------------
> >>> Julio Kriger
> >>> mailto:juliokriger@xxxxxxxxx
> >>>
> >>> _______________________________________________
> >>> Netemailing list
> >>> Netem@xxxxxxxxxxxxxx
> >>> http://lists.osdl.org/mailman/listinfo/netem
> >>>
> >>
> >> ---
> >> Catalin(ux aka Dino) BOIE
> >> catab adeuroconsult.ro
> >> http://kernel.umbrella.ro/
> >>
> >
> >
> > --
> > ----------------------------
> > Julio Kriger
> > mailto:juliokriger@xxxxxxxxx
> >
> 
> ---
> Catalin(ux aka Dino) BOIE
> catab adeuroconsult.ro
> http://kernel.umbrella.ro/
> 


-- 
----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx


Frobugreporat peshkin.net  Thu May 26 09:04:32 2005
From: bugreporapeshkin.net (Joel Peshkin)
Date: Wed Apr 18 17:37:46 2007
Subject: Comparisoof NISTNet/Nete??
Message-ID: <4295F390.1040202@xxxxxxxxxxx>


Has anyondonany testing to determine if there are any defferences 
betweeNISTNeand Netem in terms of jitter behavior?  In addition to 
thselection of jitter distribution, do they handlpackets whose 
jitter calculatiowould havresulted in negative delay or packets that 
would need to breordered thsame way?

I amoving froNISTNet to Netem in an environment where I have a large 
amounof historical data based on NISTNet, so I will need to understand 
any differences.

Thanks,

Joel Peshkin


Froshemminger aosdl.org  Thu May 26 09:15:43 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:46 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
Message-ID: <20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>

OThu, 26 May 2005 09:33:25 -0300
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> Hi!
>   I'worried abouthe stability of netem.
>   I'vbeen playing with neteand sctp and I keep getting kernel
> panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> loss of 5% and reorder of 50%. And after sending abou30-40 messages
> I geketnel panic. However sctp work perfectly if I don'set netem.
> So I don'know who is throwing thkernel panic.
>   Is netereally safto use? Should I take some consideration before
> using it? Which's ones?
>   Regards,
> Julio
Okay, whaversion of kernel? and how abouexact setup commands.
Isounds likit should be reproducible even without SCTP.

Back tracwould bhandy, here are some ways to get it:

1) Digital camera, if you havit.
2) Setup serial consol(seDocumentation/serial-console.txt)
3) Network consol(Documenation/networking/netconsole.txt)
4) Jusscribbldown the backtrace function list (ignore hex addresses)

2 & 3 requiranother machine.

Frojuliokriger agmail.com  Thu May 26 19:02:24 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:47 2007
Subject: Stability and kernel panic
In-Reply-To: <20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
Message-ID: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>

I'using vmware, so I attach neteto vmnet8.
Herarthe command and picture of the kernel panic.

tc qdisc del dev vmnet8 roonetem
tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
reorder 50% 50% loss 5%
tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
20480 mtu 1514 rat32000bps
tc -s qdisc ls dev vmnet8

I don'think thproblem is with netem. As I do some reordering of
packages thermusbe an error on sctp.

Regards,
Julio


O5/26/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OThu, 26 May 2005 09:33:25 -0300
> Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> =

> > Hi!
> >   I'worried abouthe stability of netem.
> >   I'vbeen playing with neteand sctp and I keep getting kernel
> > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > I geketnel panic. However sctp work perfectly if I don'set netem.
> > So I don'know who is throwing thkernel panic.
> >   Is netereally safto use? Should I take some consideration before
> > using it? Which's ones?
> >   Regards,
> > Julio
> Okay, whaversion of kernel? and how abouexact setup commands.
> Isounds likit should be reproducible even without SCTP.
> =

> Back tracwould bhandy, here are some ways to get it:
> =

> 1) Digital camera, if you havit.
> 2) Setup serial consol(seDocumentation/serial-console.txt)
> 3) Network consol(Documenation/networking/netconsole.txt)
> 4) Jusscribbldown the backtrace function list (ignore hex addresses)
> =

> 2 & 3 requiranother machine.
> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: img_8446.jpg
Type: image/jpeg
Size: 1077995 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
7/840be9b4/img_8446-0001.jpg
Frojuliokriger agmail.com  Fri May 27 05:33:19 2005
From: juliokriger agmail.co(Julio Kriger)
Date: Wed Apr 18 17:37:47 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
	<682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
Message-ID: <682bc30a050527053351258990@xxxxxxxxxxxxxx>

I'using vmware, so I attach neteto vmnet8.
Herarthe command and picture of the kernel panic.
 =

tc qdisc del dev vmnet8 roonetem
tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
reorder 50% 50% loss 5%
tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
20480 mtu 1514 rat32000bps
tc -s qdisc ls dev vmnet8

I don'think thproblem is with netem. As I do some reordering of
packages thermusbe an error on sctp.

Regards,
Julio


> O5/26/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> > OThu, 26 May 2005 09:33:25 -0300
> > Julio Kriger <juliokriger@xxxxxxxxx> wrote:
> >
> > > Hi!
> > >   I'worried abouthe stability of netem.
> > >   I'vbeen playing with neteand sctp and I keep getting kernel
> > > panic. I'vsenetem to a delay of 100ms and desvitation of 600ms,
> > > loss of 5% and reorder of 50%. And after sending abou30-40 messages
> > > I geketnel panic. However sctp work perfectly if I don'set netem.
> > > So I don'know who is throwing thkernel panic.
> > >   Is netereally safto use? Should I take some consideration before
> > > using it? Which's ones?
> > >   Regards,
> > > Julio
> > Okay, whaversion of kernel? and how abouexact setup commands.
> > Isounds likit should be reproducible even without SCTP.
> >
> > Back tracwould bhandy, here are some ways to get it:
> >
> > 1) Digital camera, if you havit.
> > 2) Setup serial consol(seDocumentation/serial-console.txt)
> > 3) Network consol(Documenation/networking/netconsole.txt)
> > 4) Jusscribbldown the backtrace function list (ignore hex addresses)
> >
> > 2 & 3 requiranother machine.
> >
> =

> =

> --
> ----------------------------
> Julio Kriger
> mailto:juliokriger@xxxxxxxxx
> =

> =

> =



-- =

----------------------------
Julio Kriger
mailto:juliokriger@xxxxxxxxx
-------------- nexpar--------------
A non-texattachmenwas scrubbed...
Name: img_8446.rar
Type: application/x-rar-compressed
Size: 747470 bytes
Desc: noavailable
Url : http://lists.linux-foundation.org/pipermail/netem/attachments/2005052=
7/c698e2c1/img_8446-0001.bin
Froshemminger aosdl.org  Fri May 27 09:07:40 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:47 2007
Subject: Stability and kernel panic
In-Reply-To: <682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
References: <682bc30a05052605334b1320e@xxxxxxxxxxxxxx>
	<20050526091543.3f9b3fcf@xxxxxxxxxxxxxxxxx>
	<682bc30a05052619024c3b47c7@xxxxxxxxxxxxxx>
Message-ID: <20050527090740.0399a366@xxxxxxxxxxxxxxxxx>

OFri, 27 May 2005 02:02:24 +0000
Julio Kriger <juliokriger@xxxxxxxxx> wrote:

> I'using vmware, so I attach neteto vmnet8.
> Herarthe command and picture of the kernel panic.
> 
> tc qdisc del dev vmnet8 roonetem
> tc qdisc add dev vmnet8 roohandl1:0 netem delay 100ms 500ms
> reorder 50% 50% loss 5%
> tc qdisc add dev vmnet8 paren1:1 handl10: tbf burst 20480 limit
> 20480 mtu 1514 rat32000bps
> tc -s qdisc ls dev vmnet8
> 
> I don'think thproblem is with netem. As I do some reordering of
> packages thermusbe an error on sctp.
> 

Yes your picturshows sctp.


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux