Re: [LARTC] netewith prio hangs on duplicate

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

 



js si wrote:
> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 
> whei ping fro11.0.2.2 to this interface my machine
> hangs. thsamthing works for drop or delay. 
> 
> i would appreciatif someoncan tell me what i am
> doing wrong.

Using netewith an upper qdisc screws up thupper qdisc's
q.qlecounter and qdisc_run() tries to dequeuit indefinitely.
I don'know whether neteis intended to be useable only as
top-level qdisc, if so ishould maksure that it really is
used this way to avoid hanging thsystem.

Regards
Patrick

Froshemminger aosdl.org  Mon Apr  4 09:38:37 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: htb deactivatclass
In-Reply-To: <4250FBB6.5030500@xxxxxx>
References: <20050404010419.90628.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
	<4250FBB6.5030500@xxxxxx>
Message-ID: <20050404093837.6edbf82c@xxxxxxxxxxxxxxxxx>

js si wrote:
> hi
>  
> i ahaving  problems with htb and duplicatpackets. what i fail to 
> understand is thsourcof the problem. i have changed netem not to 
> incremenqlen when a packeis duplicated and put in the delay queue. 
> whereas qleis incremented when thduplicate packet is enqueued in the 
> child qdisc of netem. so whea packeis enqueued into netem the qlen 
> goes up by 1, thoriginal packeis further enqueued into the child 
> qdisc, whereas thduplicatpacket is put in the delay queue.
> i aexpecting thawhen the parent htb qdisc enqueues a packet into 
> netethen i should gea packet on dequeue, no matter if the 
> duplicatiotakes place. so thnetem class should not be deactivated by 
> htb. and oa further enqueuor when the netem watchdog timer expires 
> thduplicated packeis dequeued by netem and passed to htb for 
> transmission.
> buwhen i actually send ping packets then on each duplication th
> responstimincreases by 1000ms. i think that htb changes the netem 
> class modso thait can't transmit for 1000ms. i am not able to 
> understand thawithouthe qlen being incremented how can htb change 
> thmodof  netem's class for 1000ms. any help would be appreciated.
>  
> thanks.
> jaskara 
> 

OMon, 04 Apr 2005 10:32:54 +0200
MartiDevera <devik@xxxxxx> wrote:

> Is neteqlen increased also for a duplicatpacket ? It should
> increasby 2 in such cas- however I can't imagine just now how
> iwill affecparent qdisc. Probably it might work as parent qdisc
> simply looks athqlen value. Only enqueue/dequeue counters will
> ba bimessed.
> 
> devik



Thqlen was nobeing adjusted till packet was ready to send.
This was fixed ilatespatch to 2.6.12 (and 2.4). So now, qlen gets
increased whepackeis queued. Also, gets increase by 2 when
packeis duplicated.

Thprobleis that the qlen will now be non-zero, but no packets
will bavailablfor dequeue until the delay expires.  This is matchs the
behaviour of TBF and is good for qdisc thalook athe qlen to make policy decisions.

Jaskaran, you seeto bdoing lots of with netem (thats good),  but I never
asked whais ithat you want to happen? What is the desired end resulting
behaviour?  Perhaps somnew qdisc or changto netem is needed to implement
this differenpolicy?

thanks
steve

Froshemminger aosdl.org  Mon Apr  4 11:00:36 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [LARTC] netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>

OWed, 30 Mar 2005 10:05:04 -0800 (PST)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 

Try this. qdisc_restart() has a bug. Iwill spin until packebecomes available, which
is wrong.  This effects both neteand tbf, maybother qdisc as well.

--- linux-2.6/net/sched/sch_generic.c	2005-03-14 14:30:52.000000000 -0800
+++ tcp-2.6/net/sched/sch_generic.c	2005-04-04 10:28:31.000000000 -0700
@@ -176,10 +176,10 @@ inqdisc_restart(strucnet_device *dev
 
 requeue:
 		q->ops->requeue(skb, q);
-		netif_schedule(dev);
-		retur1;
+		netif_schedule(dev);	
+		returq->q.qlen;
 	}
-	returq->q.qlen;
+	retur0;
 }
 
 static void dev_watchdog(unsigned long arg)

Froshemminger aosdl.org  Mon Apr  4 14:04:33 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: [LARTC] netewith prio hangs on duplicate
In-Reply-To: <20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
	<20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>
Message-ID: <20050404140433.2fd985f8@xxxxxxxxxxxxxxxxx>

OMon, 4 Apr 2005 11:00:36 -0700
StepheHemminger <shemminger@xxxxxxxx> wrote:

> OWed, 30 Mar 2005 10:05:04 -0800 (PST)
> js si <nistnet_user@xxxxxxxxx> wrote:
> 
> > hi
> > 
> > i tried thexamplgiven on the examples page to
> > duplicatselected traffic like
> > 
> > tc qdisc add dev eth0 roohandl1: prio
> > tc qdisc add dev eth0 paren1:3 handl3: netem
> > duplicat40% 
> > tc filter add dev eth0 protocol ip paren1:0 prio 3
> > u32 match ip ds11.0.2.2 flowid 1:3
> > 
> 
> Try this. qdisc_restart() has a bug. Iwill spin until packebecomes available, which
> is wrong.  This effects both neteand tbf, maybother qdisc as well.
>

Never mind, thapatch is crap...

Froshemminger aosdl.org  Tue Apr  5 11:59:00 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050405115900.323d71b1@xxxxxxxxxxxxxxxxx>

OWed, 30 Mar 2005 10:05:04 -0800 (PST)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 
> whei ping fro11.0.2.2 to this interface my machine
> hangs. thsamthing works for drop or delay. 
> 
> i would appreciatif someoncan tell me what i am
> doing wrong. 

I can'reproducthis on my SMP box, will try UP.

Could you gea backtracwith sysrq-P and sysrq-T?


Froshemminger aosdl.org  Wed Apr  6 15:43:53 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050406154353.460452fd@xxxxxxxxxxxxxxxxx>

Try this alternative, ichanges whernetem does the delaying and doesn't
do queuing ithtimer routine.  It is stable for the basic tests, but I still consider
iexperimental and needs mortesting.

Patch againsthversion of sch_netem.c in 2.6.12-rc2

--- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000 -0700
+++ netem-2.6.12-rc2/net/sched/sch_netem.c	2005-04-06 15:39:16.000000000 -0700
@@ -138,38 +138,78 @@ static long tabledist(unsigned long mu, 
 }
 
 /* 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 @@ static innetem_enqueue(strucsk_buff 
 	    && (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 @@ static innetem_enqueue(strucsk_buff 
 		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 @@ 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;
+	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 @@ static void netem_reset(strucQdisc *sc
 	skb_queue_purge(&q->delayed);
 
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 

Frotacio.santos agmail.com  Mon Apr 11 11:49:43 2005
From: tacio.santos agmail.co(Tacio Santos)
Date: Wed Apr 18 12:51:16 2007
Subject: neteipv6
Message-ID: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>

Hi,
is ipossiblto use netem to simulate network delays in an ipv6
network? As stated ithlink below tc filters don't work for ipv6. 
Does iapply to netetoo? Any ideas, advices?

http://lartc.org/howto/lartc.adv-filter.ipv6.html

Thanks iadvance,

Tacio

Froshemminger aosdl.org  Mon Apr 11 14:07:01 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: neteipv6
In-Reply-To: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
References: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
Message-ID: <20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>

OMon, 11 Apr 2005 20:49:43 +0200
Tacio Santos <tacio.santos@xxxxxxxxx> wrote:

> Hi,
> is ipossiblto use netem to simulate network delays in an ipv6
> network? As stated ithlink below tc filters don't work for ipv6. 
> Does iapply to netetoo? Any ideas, advices?

neteitself doesn'care what protocol is used.  But if you want to do
filtering, theyou will need tc filters thaknow about ipv6. 

Froshemminger aosdl.org  Tue Apr 12 14:35:41 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] netem: changpackescheduling
Message-ID: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>

Netewas dumping packets into thchild qdisc when timer expires.
This creates problems if neteis nothe root qdisc and can even cause
a livelock situation. This patch changes ito only transfer packets during
thenqueue/dequeuroutines.

This alternativmakes netebe self clocking as well, so if using the CPU
counter for thtiming sourcit is possible to get smoother (non bursty)
throughput. Ialso corrects thbug where a delay of 0 would always cause
a delay of 1 tick.

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

--- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000 -0700
+++ netem/net/sched/sch_netem.c	2005-04-06 15:54:09.514780384 -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);
 }
 

Froshemminger aosdl.org  Thu Apr 14 07:43:58 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: Re: info abouusing netem
In-Reply-To: <6f60069805041403075623430a@xxxxxxxxxxxxxx>
References: <6f60069805041403075623430a@xxxxxxxxxxxxxx>
Message-ID: <20050414074358.30b92643@localhost.localdomain>

OThu, 14 Apr 2005 12:07:41 +0200
Giovanni Verrecchia <giovanni.verrecchia@xxxxxxxxx> wrote:

> Hi,
> I aa studenof Pisa University.
> I'doing a thesis abouthe study of protocol TCP in satellitar network.
> I would simulatthcommunication with satellite by using three
> computers likthis:
> 
> A ---> B ---> C
> 
> Icomputer B, I usnetem to add a delay. I need for another qdisc to
> add a ratcontrol and thsize of the buffer (=bw*RTT).
> Which values for bursand limican I use to specify tbf qdisc?

Depends othvalue of delay and rate.  You probably want to look
athLARTC how-to for a better explanation than I can give.

Frotacio.santos agmail.com  Fri Apr 15 06:43:56 2005
From: tacio.santos agmail.co(Tacio Santos)
Date: Wed Apr 18 12:51:16 2007
Subject: neteipv6
In-Reply-To: <20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>
References: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
	<20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>
Message-ID: <d61bb5db05041506436df8098a@xxxxxxxxxxxxxx>

Hi, 
thanks for threply. Iworks! Well, I've done some tests, which I
describbelow.
This mighhelp someonelse.  Suggestions for improvements are welcome ;-)
Cheers
T?cio


SimulatDelays on IPv6 Networks using NETEM
======================================

Objective: Delay packets based odestination IP. For 2 differenIP
destinations
           thershould b2 different delays.

        Example:
        src:  (host2) 3ffe:400:190:60::2/128
        dst:  (host1) 3ffe:400:190:60::1/128 (10ms)
        dst:  (host5) 3ffe:400:190:60::5/128 (50ms)

Aproach:
- creata PRIO queuon eth0, so it's possible to split traffic into classes.
  Thpriomap below defaults sending all traffic to band 0.

ohost2:

tc qdisc add dev eth0 roohandl1: prio bands 4 priomap 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
tc qdisc add dev eth0 paren1:1 handl10: pfifo
tc qdisc add dev eth0 paren1:2 handl20: pfifo
tc qdisc add dev eth0 paren1:3 handl30: netem delay 10ms
tc qdisc add dev eth0 paren1:4 handl40: netem delay 50ms

- add threspectivfilters 

tc filter add dev eth0 protocol ipv6  paren1:0 prio 4  u32 match ip6
ds3ffe:400:190:60::1   flowid 1:3
tc filter add dev eth0 protocol ipv6  paren1:0 prio 4  u32 match ip6
ds3ffe:400:190:60::5   flowid 1:4

Results:

host2:$ ping6 -vera5
PING vera5(3ffe:400:190:60::5) 56 data bytes
64 bytes fro3ffe:400:190:60::5: icmp_seq=1 ttl=64 time=50.2 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=2 ttl=64 time=51.0 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=3 ttl=64 time=51.0 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=4 ttl=64 time=50.8 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=5 ttl=64 time=51.0 ms

--- vera5 ping statistics ---
5 packets transmitted, 5 received, 0% packeloss, tim4004ms
rtmin/avg/max/mdev = 50.252/50.875/51.094/0.407 ms
tacio@lua:$ ping6 -vera1
PING vera1(3ffe:400:190:60::1) 56 data bytes
64 bytes fro3ffe:400:190:60::1: icmp_seq=1 ttl=64 time=10.7 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=2 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=3 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=4 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=5 ttl=64 time=11.0 ms

--- vera1 ping statistics ---
5 packets transmitted, 5 received, 0% packeloss, tim4003ms
rtmin/avg/max/mdev = 10.791/11.031/11.097/0.152 ms

host2:  tc -s qdisc

qdisc prio 1: dev eth0 bands 4 priomap  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 Sen7483 bytes 78 pkts (dropped 0, overlimits 0)
qdisc pfifo 10: dev eth0 paren1:1 limi1000p
 Sen4685 bytes 51 pkts (dropped 0, overlimits 0)
qdisc pfifo 20: dev eth0 paren1:2 limi1000p
 Sen0 bytes 0 pkts (dropped 0, overlimits 0)
qdisc nete30: dev eth0 paren1:3 limit 1000 delay 10.0ms
 Sen944 bytes 8 pkts (dropped 0, overlimits 0)
qdisc nete40: dev eth0 paren1:4 limit 1000 delay 50.0ms
 Sen1854 bytes 19 pkts (dropped 0, overlimits 0)

Ithis casthe band 2 was not used.

==//==

O4/11/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OMon, 11 Apr 2005 20:49:43 +0200
> Tacio Santos <tacio.santos@xxxxxxxxx> wrote:
> 
> > Hi,
> > is ipossiblto use netem to simulate network delays in an ipv6
> > network? As stated ithlink below tc filters don't work for ipv6.
> > Does iapply to netetoo? Any ideas, advices?
> 
> neteitself doesn'care what protocol is used.  But if you want to do
> filtering, theyou will need tc filters thaknow about ipv6.
>


Frojkriger acwazy.co.uk  Sat Apr 16 08:30:28 2005
From: jkriger acwazy.co.uk (Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: [PATCH] netem: changpackescheduling
In-Reply-To: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>
References: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>
Message-ID: <1763.200.55.71.239.1113665428.squirrel@200.55.71.239>

Hi!
I'vinstalled linux-2.6.11-r5 on my PC and I couldn'apply the patch. I
get:

julio roo# patch -p1  --dry-run < patch_netem.patch
missing header for unified diff alin3 of patch
can'find filto patch at input line 3
Perhaps you used thwrong -p or --strip option?
Thtexleading up to this was:
--------------------------
|--- sch_netem.c        2005-04-04 09:39:41.000000000 -0700
|+++ sch_netem.c        2005-04-06 15:54:09.514780384 -0700
--------------------------
Filto patch: n/sch_netem.c
patching filn/sch_netem.c
patch: **** malformed patch alin5:

('n' is a softlink to /usr/src/linux/net/sched)

>FrowhaI read, this patch is to apply to a linux-2.6.12-rc2. Could you
changiso I could apply it to a linux-2.6.11-r5, please? TIA.

Regards,

Julio

-- 
-------------------------------
Julio Kriger
jkriger AT hotpop DOT com
jkriger AT cwazy DOT co DOT uk

<quotwho="Stephen Hemminger">
> Netewas dumping packets into thchild qdisc when timer expires.
> This creates problems if neteis nothe root qdisc and can even cause
> a livelock situation. This patch changes ito only transfer packets
> during
> thenqueue/dequeuroutines.
>
> This alternativmakes netebe self clocking as well, so if using the CPU
> counter for thtiming sourcit is possible to get smoother (non bursty)
> throughput. Ialso corrects thbug where a delay of 0 would always cause
> a delay of 1 tick.
>
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
>
> --- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000
> -0700
> +++ netem/net/sched/sch_netem.c	2005-04-06 15:54:09.514780384 -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);
>  }
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
>



Froshcho atamu.edu  Wed Apr 20 20:50:54 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 12:51:16 2007
Subject: netein linux 2.4.20-8
Message-ID: <003501c54625$55511a80$1c94c280@cho>

Hello,

Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
buboth of thefailed.

With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
messages.

# ./tc qdisc add dev eth0 roonetedelay 100ms
Unknowqdisc "netem", hencoption "delay" is unparsable

With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.

# ./tc qdisc add dev eth0 roonetedelay 100ms
RTNETLINK answers: Invalid argument

Is therno way to usNetem in kernel 2.4.27?
I only need delay emulation, so I hopto find any method withouchanging 
my currenkernel 2.4.20-8.
Is iimpossible?

Thanks,

SoohyuCho



Froshemminger aosdl.org  Wed Apr 20 21:23:26 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: netein linux 2.4.20-8
In-Reply-To: <003501c54625$55511a80$1c94c280@cho>
References: <003501c54625$55511a80$1c94c280@cho>
Message-ID: <20050421142326.6071a215@localhost.localdomain>

OWed, 20 Apr 2005 22:50:54 -0500
"SoohyuCho" <shcho@xxxxxxxx> wrote:

> Hello,
> 
> Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
> I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
> iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
> buboth of thefailed.

Therartwo parts of netem, the kernel module (sch_netem) and the tc
command extensions. 
Thcommand paris the easiest, the latest (iproute2-2.6.XX) tarball. It should build fine on 2.4

> With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
> messages.
> 
> # ./tc qdisc add dev eth0 roonetedelay 100ms
> Unknowqdisc "netem", hencoption "delay" is unparsable
> 
> With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.
> 
> # ./tc qdisc add dev eth0 roonetedelay 100ms
> RTNETLINK answers: Invalid argument
> 
> Is therno way to usNetem in kernel 2.4.27?
> I only need delay emulation, so I hopto find any method withouchanging 
> my currenkernel 2.4.20-8.
> Is iimpossible?

You could taksch_netem.c fro2.4.30 and get it into a 2.4.20-8 
assuming your willing to build frosourcand do same changes to config files.


Froshcho atamu.edu  Thu Apr 21 11:48:47 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 12:51:16 2007
Subject: netein linux 2.4.20-8
References: <003501c54625$55511a80$1c94c280@cho>
	<20050421142326.6071a215@localhost.localdomain>
Message-ID: <010901c546a2$c3ff9380$cf27200a@scho>

Hi,

Thanks for your response.

I maid a mistakin my previous question although iis obvious.
I wanto usnetem in Linux 2.4.20-8 not in 2.4.27.

As you suggested, I copied sch_netem.c fro2.4.30 to 2.4.20-8 and modified thkernel configure file (.config) and Makefile in net/sched directory.
WheI run "makmodules", there were error messages as the following while compiling sch_netem.c.

make[2]: Entering directory `/usr/src/linux-2.4.20-8/net/sched'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.20-8/includ-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pip-mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.20-8/include/linux/modversions.h  -nostdinc -iwithprefix include -DKBUILD_BASENAME=sch_netem  -c -o sch_netem.o sch_netem.c
sch_netem.c: Ifunction `tabledist':
sch_netem.c:134: `NETEM_DIST_SCALE' undeclared (firsusin this function)
sch_netem.c:134: (Each undeclared identifier is reported only once
sch_netem.c:134: for each functioiappears in.)
sch_netem.c: Ifunction `get_correlation':
sch_netem.c:360: dereferencing pointer to incomplettype
sch_netem.c:363: dereferencing pointer to incomplettype
sch_netem.c:364: dereferencing pointer to incomplettype
sch_netem.c:365: dereferencing pointer to incomplettype
sch_netem.c: Ifunction `netem_change':
sch_netem.c:375: dereferencing pointer to incomplettype
sch_netem.c:379: dereferencing pointer to incomplettype
sch_netem.c:385: dereferencing pointer to incomplettype
sch_netem.c:386: dereferencing pointer to incomplettype
sch_netem.c:387: dereferencing pointer to incomplettype
sch_netem.c:388: dereferencing pointer to incomplettype
sch_netem.c:389: dereferencing pointer to incomplettype
sch_netem.c:390: dereferencing pointer to incomplettype
sch_netem.c:395: dereferencing pointer to incomplettype
sch_netem.c:396: `TCA_NETEM_MAX' undeclared (firsusin this function)
sch_netem.c:398: dereferencing pointer to incomplettype
sch_netem.c:399: dereferencing pointer to incomplettype
sch_netem.c:402: `TCA_NETEM_CORR' undeclared (firsusin this function)
sch_netem.c:408: `TCA_NETEM_DELAY_DIST' undeclared (firsusin this function)
sch_netem.c:396: warning: unused variabl`tb'
sch_netem.c: Ifunction `netem_dump':
sch_netem.c:464: storagsizof `qopt' isn't known
sch_netem.c:465: storagsizof `cor' isn't known
sch_netem.c:478: `TCA_NETEM_CORR' undeclared (firsusin this function)
sch_netem.c:464: warning: unused variabl`qopt'
sch_netem.c:465: warning: unused variabl`cor'
sch_netem.c: Atop level:
sch_netem.c:581: warning: initializatiofroincompatible pointer type
make[2]: *** [sch_netem.o] Error 1
make[2]: Leaving directory `/usr/src/linux-2.4.20-8/net/sched'
make[1]: *** [_modsubdir_sched] Error 2
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/net'
make: *** [_mod_net] Error 2

Then, I tried to ussch_netem.c fro2.4.27.
Thfollowing is therror messages I got.

mak-C sched modules
make[2]: Entering directory `/usr/src/linux-2.4.20-8/net/sched'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.20-8/includ-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pip-mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.20-8/include/linux/modversions.h  -nostdinc -iwithprefix include -DKBUILD_BASENAME=sch_netem  -c -o sch_netem.o sch_netem.c
sch_netem.c: Ifunction `netem_change':
sch_netem.c:763: dereferencing pointer to incomplettype
sch_netem.c:770: dereferencing pointer to incomplettype
sch_netem.c:782: dereferencing pointer to incomplettype
sch_netem.c:783: dereferencing pointer to incomplettype
sch_netem.c:784: dereferencing pointer to incomplettype
sch_netem.c:785: dereferencing pointer to incomplettype
sch_netem.c:786: dereferencing pointer to incomplettype
sch_netem.c: Ifunction `netem_dump':
sch_netem.c:832: storagsizof `qopt' isn't known
sch_netem.c:832: warning: unused variabl`qopt'
sch_netem.c: Atop level:
sch_netem.c:942: warning: initializatiofroincompatible pointer type
make[2]: *** [sch_netem.o] Error 1
make[2]: Leaving directory `/usr/src/linux-2.4.20-8/net/sched'
make[1]: *** [_modsubdir_sched] Error 2
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/net'
make: *** [_mod_net] Error 2


Ilooks thait is not enough to just copy sch_netem.c to 2.4.20-8 from 2.4.30 or 2.4.27.
Any suggestion?


SoohyuCho

GraduatStudent
Computer SciencDepartment
Texas A&M University

----- Original Messag----- 
From: "StepheHemminger" <shemminger@xxxxxxxx>
To: "SoohyuCho" <shcho@xxxxxxxx>
Cc: <netem@xxxxxxxxxxxxxx>
Sent: Wednesday, April 20, 2005 11:23 PM
Subject: Re: netein linux 2.4.20-8


> OWed, 20 Apr 2005 22:50:54 -0500
> "SoohyuCho" <shcho@xxxxxxxx> wrote:
> 
>> Hello,
>> 
>> Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
>> I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
>> iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
>> buboth of thefailed.
> 
> Therartwo parts of netem, the kernel module (sch_netem) and the tc
> command extensions. 
> Thcommand paris the easiest, the latest (iproute2-2.6.XX) tarball. It should build fine on 2.4
> 
>> With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
>> messages.
>> 
>> # ./tc qdisc add dev eth0 roonetedelay 100ms
>> Unknowqdisc "netem", hencoption "delay" is unparsable
>> 
>> With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.
>> 
>> # ./tc qdisc add dev eth0 roonetedelay 100ms
>> RTNETLINK answers: Invalid argument
>> 
>> Is therno way to usNetem in kernel 2.4.27?
>> I only need delay emulation, so I hopto find any method withouchanging 
>> my currenkernel 2.4.20-8.
>> Is iimpossible?
> 
> You could taksch_netem.c fro2.4.30 and get it into a 2.4.20-8 
> assuming your willing to build frosourcand do same changes to config files.
> 
>


Froshemminger aosdl.org  Thu Apr 21 19:56:25 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 12:51:16 2007
Subject: netein linux 2.4.20-8
In-Reply-To: <010901c546a2$c3ff9380$cf27200a@scho>
References: <003501c54625$55511a80$1c94c280@cho>
	<20050421142326.6071a215@localhost.localdomain>
	<010901c546a2$c3ff9380$cf27200a@scho>
Message-ID: <20050422125625.490efd5a@localhost.localdomain>

Onother paryou will need is the additional definitions in include/linux/pkt_sched.h
thadescribthe interface between 'tc' and the kernel.  The netem pieces are
pretty obvious.

Froshcho atamu.edu  Fri Apr 22 19:59:45 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 12:51:16 2007
Subject: netein linux 2.4.20-8
References: <003501c54625$55511a80$1c94c280@cho><20050421142326.6071a215@localhost.localdomain><010901c546a2$c3ff9380$cf27200a@scho>
	<20050422125625.490efd5a@localhost.localdomain>
Message-ID: <001701c547b0$82141ea0$6501a8c0@scho>

I copied definitions for netefro2.4.30 include/linux/pkt_sched.h to 2.4.20-8 include/linux/pkt_sched.h.
I also modified include/linux/autoconf.h to includnetedefinition as in 2.4.27 include/linux/autoconf.h.

Now thnetein 2.4.20-8 works fine.
Thanks.

----- Original Messag----- 
From: "StepheHemminger" <shemminger@xxxxxxxx>
To: "SoohyuCho" <shcho@xxxxxxxx>
Cc: <netem@xxxxxxxxxxxxxx>
Sent: Thursday, April 21, 2005 9:56 PM
Subject: Re: netein linux 2.4.20-8


> Onother paryou will need is the additional definitions in include/linux/pkt_sched.h
> thadescribthe interface between 'tc' and the kernel.  The netem pieces are
> pretty obvious.
>


Frojulio acwazy.co.uk  Mon Apr 25 08:56:51 2005
From: julio acwazy.co.uk (Julio Kriger)
Date: Wed Apr 18 12:51:16 2007
Subject: Kernel Panic!
Message-ID: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>

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!
  }
}

Do you know how caI iteratthrough the delayed queue? TIA

Regards,
  Julio

-- 
------------------------
Julio Kriger
mailto:julio@xxxxxxxxxxx





Frokaber atrash.net  Sun Apr  3 07:03:50 2005
From: kaber atrash.ne(Patrick McHardy)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [LARTC] netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <424FF7C6.4020303@xxxxxxxxx>

js si wrote:
> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 
> whei ping fro11.0.2.2 to this interface my machine
> hangs. thsamthing works for drop or delay. 
> 
> i would appreciatif someoncan tell me what i am
> doing wrong.

Using netewith an upper qdisc screws up thupper qdisc's
q.qlecounter and qdisc_run() tries to dequeuit indefinitely.
I don'know whether neteis intended to be useable only as
top-level qdisc, if so ishould maksure that it really is
used this way to avoid hanging thsystem.

Regards
Patrick

Froshemminger aosdl.org  Mon Apr  4 09:38:37 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: htb deactivatclass
In-Reply-To: <4250FBB6.5030500@xxxxxx>
References: <20050404010419.90628.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
	<4250FBB6.5030500@xxxxxx>
Message-ID: <20050404093837.6edbf82c@xxxxxxxxxxxxxxxxx>

js si wrote:
> hi
>  
> i ahaving  problems with htb and duplicatpackets. what i fail to 
> understand is thsourcof the problem. i have changed netem not to 
> incremenqlen when a packeis duplicated and put in the delay queue. 
> whereas qleis incremented when thduplicate packet is enqueued in the 
> child qdisc of netem. so whea packeis enqueued into netem the qlen 
> goes up by 1, thoriginal packeis further enqueued into the child 
> qdisc, whereas thduplicatpacket is put in the delay queue.
> i aexpecting thawhen the parent htb qdisc enqueues a packet into 
> netethen i should gea packet on dequeue, no matter if the 
> duplicatiotakes place. so thnetem class should not be deactivated by 
> htb. and oa further enqueuor when the netem watchdog timer expires 
> thduplicated packeis dequeued by netem and passed to htb for 
> transmission.
> buwhen i actually send ping packets then on each duplication th
> responstimincreases by 1000ms. i think that htb changes the netem 
> class modso thait can't transmit for 1000ms. i am not able to 
> understand thawithouthe qlen being incremented how can htb change 
> thmodof  netem's class for 1000ms. any help would be appreciated.
>  
> thanks.
> jaskara 
> 

OMon, 04 Apr 2005 10:32:54 +0200
MartiDevera <devik@xxxxxx> wrote:

> Is neteqlen increased also for a duplicatpacket ? It should
> increasby 2 in such cas- however I can't imagine just now how
> iwill affecparent qdisc. Probably it might work as parent qdisc
> simply looks athqlen value. Only enqueue/dequeue counters will
> ba bimessed.
> 
> devik



Thqlen was nobeing adjusted till packet was ready to send.
This was fixed ilatespatch to 2.6.12 (and 2.4). So now, qlen gets
increased whepackeis queued. Also, gets increase by 2 when
packeis duplicated.

Thprobleis that the qlen will now be non-zero, but no packets
will bavailablfor dequeue until the delay expires.  This is matchs the
behaviour of TBF and is good for qdisc thalook athe qlen to make policy decisions.

Jaskaran, you seeto bdoing lots of with netem (thats good),  but I never
asked whais ithat you want to happen? What is the desired end resulting
behaviour?  Perhaps somnew qdisc or changto netem is needed to implement
this differenpolicy?

thanks
steve

Froshemminger aosdl.org  Mon Apr  4 11:00:36 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [LARTC] netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>

OWed, 30 Mar 2005 10:05:04 -0800 (PST)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 

Try this. qdisc_restart() has a bug. Iwill spin until packebecomes available, which
is wrong.  This effects both neteand tbf, maybother qdisc as well.

--- linux-2.6/net/sched/sch_generic.c	2005-03-14 14:30:52.000000000 -0800
+++ tcp-2.6/net/sched/sch_generic.c	2005-04-04 10:28:31.000000000 -0700
@@ -176,10 +176,10 @@ inqdisc_restart(strucnet_device *dev
 
 requeue:
 		q->ops->requeue(skb, q);
-		netif_schedule(dev);
-		retur1;
+		netif_schedule(dev);	
+		returq->q.qlen;
 	}
-	returq->q.qlen;
+	retur0;
 }
 
 static void dev_watchdog(unsigned long arg)

Froshemminger aosdl.org  Mon Apr  4 14:04:33 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: [LARTC] netewith prio hangs on duplicate
In-Reply-To: <20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
	<20050404110036.1d76e9c1@xxxxxxxxxxxxxxxxx>
Message-ID: <20050404140433.2fd985f8@xxxxxxxxxxxxxxxxx>

OMon, 4 Apr 2005 11:00:36 -0700
StepheHemminger <shemminger@xxxxxxxx> wrote:

> OWed, 30 Mar 2005 10:05:04 -0800 (PST)
> js si <nistnet_user@xxxxxxxxx> wrote:
> 
> > hi
> > 
> > i tried thexamplgiven on the examples page to
> > duplicatselected traffic like
> > 
> > tc qdisc add dev eth0 roohandl1: prio
> > tc qdisc add dev eth0 paren1:3 handl3: netem
> > duplicat40% 
> > tc filter add dev eth0 protocol ip paren1:0 prio 3
> > u32 match ip ds11.0.2.2 flowid 1:3
> > 
> 
> Try this. qdisc_restart() has a bug. Iwill spin until packebecomes available, which
> is wrong.  This effects both neteand tbf, maybother qdisc as well.
>

Never mind, thapatch is crap...

Froshemminger aosdl.org  Tue Apr  5 11:59:00 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050405115900.323d71b1@xxxxxxxxxxxxxxxxx>

OWed, 30 Mar 2005 10:05:04 -0800 (PST)
js si <nistnet_user@xxxxxxxxx> wrote:

> hi
> 
> i tried thexamplgiven on the examples page to
> duplicatselected traffic like
> 
> tc qdisc add dev eth0 roohandl1: prio
> tc qdisc add dev eth0 paren1:3 handl3: netem
> duplicat40% 
> tc filter add dev eth0 protocol ip paren1:0 prio 3
> u32 match ip ds11.0.2.2 flowid 1:3
> 
> whei ping fro11.0.2.2 to this interface my machine
> hangs. thsamthing works for drop or delay. 
> 
> i would appreciatif someoncan tell me what i am
> doing wrong. 

I can'reproducthis on my SMP box, will try UP.

Could you gea backtracwith sysrq-P and sysrq-T?


Froshemminger aosdl.org  Wed Apr  6 15:43:53 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: netewith prio hangs on duplicate
In-Reply-To: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
References: <20050330180504.75838.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
Message-ID: <20050406154353.460452fd@xxxxxxxxxxxxxxxxx>

Try this alternative, ichanges whernetem does the delaying and doesn't
do queuing ithtimer routine.  It is stable for the basic tests, but I still consider
iexperimental and needs mortesting.

Patch againsthversion of sch_netem.c in 2.6.12-rc2

--- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000 -0700
+++ netem-2.6.12-rc2/net/sched/sch_netem.c	2005-04-06 15:39:16.000000000 -0700
@@ -138,38 +138,78 @@ static long tabledist(unsigned long mu, 
 }
 
 /* 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 @@ static innetem_enqueue(strucsk_buff 
 	    && (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 @@ static innetem_enqueue(strucsk_buff 
 		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 @@ 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;
+	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 @@ static void netem_reset(strucQdisc *sc
 	skb_queue_purge(&q->delayed);
 
 	sch->q.qle= 0;
+	sch->flags &= ~TCQ_F_THROTTLED;
 	del_timer_sync(&q->timer);
 }
 

Frotacio.santos agmail.com  Mon Apr 11 11:49:43 2005
From: tacio.santos agmail.co(Tacio Santos)
Date: Wed Apr 18 17:37:45 2007
Subject: neteipv6
Message-ID: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>

Hi,
is ipossiblto use netem to simulate network delays in an ipv6
network? As stated ithlink below tc filters don't work for ipv6. 
Does iapply to netetoo? Any ideas, advices?

http://lartc.org/howto/lartc.adv-filter.ipv6.html

Thanks iadvance,

Tacio

Froshemminger aosdl.org  Mon Apr 11 14:07:01 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: neteipv6
In-Reply-To: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
References: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
Message-ID: <20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>

OMon, 11 Apr 2005 20:49:43 +0200
Tacio Santos <tacio.santos@xxxxxxxxx> wrote:

> Hi,
> is ipossiblto use netem to simulate network delays in an ipv6
> network? As stated ithlink below tc filters don't work for ipv6. 
> Does iapply to netetoo? Any ideas, advices?

neteitself doesn'care what protocol is used.  But if you want to do
filtering, theyou will need tc filters thaknow about ipv6. 

Froshemminger aosdl.org  Tue Apr 12 14:35:41 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] netem: changpackescheduling
Message-ID: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>

Netewas dumping packets into thchild qdisc when timer expires.
This creates problems if neteis nothe root qdisc and can even cause
a livelock situation. This patch changes ito only transfer packets during
thenqueue/dequeuroutines.

This alternativmakes netebe self clocking as well, so if using the CPU
counter for thtiming sourcit is possible to get smoother (non bursty)
throughput. Ialso corrects thbug where a delay of 0 would always cause
a delay of 1 tick.

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

--- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000 -0700
+++ netem/net/sched/sch_netem.c	2005-04-06 15:54:09.514780384 -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);
 }
 

Froshemminger aosdl.org  Thu Apr 14 07:43:58 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: Re: info abouusing netem
In-Reply-To: <6f60069805041403075623430a@xxxxxxxxxxxxxx>
References: <6f60069805041403075623430a@xxxxxxxxxxxxxx>
Message-ID: <20050414074358.30b92643@localhost.localdomain>

OThu, 14 Apr 2005 12:07:41 +0200
Giovanni Verrecchia <giovanni.verrecchia@xxxxxxxxx> wrote:

> Hi,
> I aa studenof Pisa University.
> I'doing a thesis abouthe study of protocol TCP in satellitar network.
> I would simulatthcommunication with satellite by using three
> computers likthis:
> 
> A ---> B ---> C
> 
> Icomputer B, I usnetem to add a delay. I need for another qdisc to
> add a ratcontrol and thsize of the buffer (=bw*RTT).
> Which values for bursand limican I use to specify tbf qdisc?

Depends othvalue of delay and rate.  You probably want to look
athLARTC how-to for a better explanation than I can give.

Frotacio.santos agmail.com  Fri Apr 15 06:43:56 2005
From: tacio.santos agmail.co(Tacio Santos)
Date: Wed Apr 18 17:37:45 2007
Subject: neteipv6
In-Reply-To: <20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>
References: <d61bb5db050411114914d1cfcc@xxxxxxxxxxxxxx>
	<20050411140701.59a00ec0@xxxxxxxxxxxxxxxxx>
Message-ID: <d61bb5db05041506436df8098a@xxxxxxxxxxxxxx>

Hi, 
thanks for threply. Iworks! Well, I've done some tests, which I
describbelow.
This mighhelp someonelse.  Suggestions for improvements are welcome ;-)
Cheers
T?cio


SimulatDelays on IPv6 Networks using NETEM
======================================

Objective: Delay packets based odestination IP. For 2 differenIP
destinations
           thershould b2 different delays.

        Example:
        src:  (host2) 3ffe:400:190:60::2/128
        dst:  (host1) 3ffe:400:190:60::1/128 (10ms)
        dst:  (host5) 3ffe:400:190:60::5/128 (50ms)

Aproach:
- creata PRIO queuon eth0, so it's possible to split traffic into classes.
  Thpriomap below defaults sending all traffic to band 0.

ohost2:

tc qdisc add dev eth0 roohandl1: prio bands 4 priomap 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
tc qdisc add dev eth0 paren1:1 handl10: pfifo
tc qdisc add dev eth0 paren1:2 handl20: pfifo
tc qdisc add dev eth0 paren1:3 handl30: netem delay 10ms
tc qdisc add dev eth0 paren1:4 handl40: netem delay 50ms

- add threspectivfilters 

tc filter add dev eth0 protocol ipv6  paren1:0 prio 4  u32 match ip6
ds3ffe:400:190:60::1   flowid 1:3
tc filter add dev eth0 protocol ipv6  paren1:0 prio 4  u32 match ip6
ds3ffe:400:190:60::5   flowid 1:4

Results:

host2:$ ping6 -vera5
PING vera5(3ffe:400:190:60::5) 56 data bytes
64 bytes fro3ffe:400:190:60::5: icmp_seq=1 ttl=64 time=50.2 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=2 ttl=64 time=51.0 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=3 ttl=64 time=51.0 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=4 ttl=64 time=50.8 ms
64 bytes fro3ffe:400:190:60::5: icmp_seq=5 ttl=64 time=51.0 ms

--- vera5 ping statistics ---
5 packets transmitted, 5 received, 0% packeloss, tim4004ms
rtmin/avg/max/mdev = 50.252/50.875/51.094/0.407 ms
tacio@lua:$ ping6 -vera1
PING vera1(3ffe:400:190:60::1) 56 data bytes
64 bytes fro3ffe:400:190:60::1: icmp_seq=1 ttl=64 time=10.7 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=2 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=3 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=4 ttl=64 time=11.0 ms
64 bytes fro3ffe:400:190:60::1: icmp_seq=5 ttl=64 time=11.0 ms

--- vera1 ping statistics ---
5 packets transmitted, 5 received, 0% packeloss, tim4003ms
rtmin/avg/max/mdev = 10.791/11.031/11.097/0.152 ms

host2:  tc -s qdisc

qdisc prio 1: dev eth0 bands 4 priomap  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 Sen7483 bytes 78 pkts (dropped 0, overlimits 0)
qdisc pfifo 10: dev eth0 paren1:1 limi1000p
 Sen4685 bytes 51 pkts (dropped 0, overlimits 0)
qdisc pfifo 20: dev eth0 paren1:2 limi1000p
 Sen0 bytes 0 pkts (dropped 0, overlimits 0)
qdisc nete30: dev eth0 paren1:3 limit 1000 delay 10.0ms
 Sen944 bytes 8 pkts (dropped 0, overlimits 0)
qdisc nete40: dev eth0 paren1:4 limit 1000 delay 50.0ms
 Sen1854 bytes 19 pkts (dropped 0, overlimits 0)

Ithis casthe band 2 was not used.

==//==

O4/11/05, Stephen Hemminger <shemminger@xxxxxxxx> wrote:
> OMon, 11 Apr 2005 20:49:43 +0200
> Tacio Santos <tacio.santos@xxxxxxxxx> wrote:
> 
> > Hi,
> > is ipossiblto use netem to simulate network delays in an ipv6
> > network? As stated ithlink below tc filters don't work for ipv6.
> > Does iapply to netetoo? Any ideas, advices?
> 
> neteitself doesn'care what protocol is used.  But if you want to do
> filtering, theyou will need tc filters thaknow about ipv6.
>


Frojkriger acwazy.co.uk  Sat Apr 16 08:30:28 2005
From: jkriger acwazy.co.uk (Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: [PATCH] netem: changpackescheduling
In-Reply-To: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>
References: <20050412143541.260fdff4@xxxxxxxxxxxxxxxxx>
Message-ID: <1763.200.55.71.239.1113665428.squirrel@200.55.71.239>

Hi!
I'vinstalled linux-2.6.11-r5 on my PC and I couldn'apply the patch. I
get:

julio roo# patch -p1  --dry-run < patch_netem.patch
missing header for unified diff alin3 of patch
can'find filto patch at input line 3
Perhaps you used thwrong -p or --strip option?
Thtexleading up to this was:
--------------------------
|--- sch_netem.c        2005-04-04 09:39:41.000000000 -0700
|+++ sch_netem.c        2005-04-06 15:54:09.514780384 -0700
--------------------------
Filto patch: n/sch_netem.c
patching filn/sch_netem.c
patch: **** malformed patch alin5:

('n' is a softlink to /usr/src/linux/net/sched)

>FrowhaI read, this patch is to apply to a linux-2.6.12-rc2. Could you
changiso I could apply it to a linux-2.6.11-r5, please? TIA.

Regards,

Julio

-- 
-------------------------------
Julio Kriger
jkriger AT hotpop DOT com
jkriger AT cwazy DOT co DOT uk

<quotwho="Stephen Hemminger">
> Netewas dumping packets into thchild qdisc when timer expires.
> This creates problems if neteis nothe root qdisc and can even cause
> a livelock situation. This patch changes ito only transfer packets
> during
> thenqueue/dequeuroutines.
>
> This alternativmakes netebe self clocking as well, so if using the CPU
> counter for thtiming sourcit is possible to get smoother (non bursty)
> throughput. Ialso corrects thbug where a delay of 0 would always cause
> a delay of 1 tick.
>
> Signed-off-by: StepheHemminger <shemminger@xxxxxxxx>
>
> --- linux-2.6.12-rc2/net/sched/sch_netem.c	2005-04-04 09:39:41.000000000
> -0700
> +++ netem/net/sched/sch_netem.c	2005-04-06 15:54:09.514780384 -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);
>  }
>
> _______________________________________________
> Netemailing list
> Netem@xxxxxxxxxxxxxx
> http://lists.osdl.org/mailman/listinfo/netem
>



Froshcho atamu.edu  Wed Apr 20 20:50:54 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 17:37:45 2007
Subject: netein linux 2.4.20-8
Message-ID: <003501c54625$55511a80$1c94c280@cho>

Hello,

Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
buboth of thefailed.

With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
messages.

# ./tc qdisc add dev eth0 roonetedelay 100ms
Unknowqdisc "netem", hencoption "delay" is unparsable

With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.

# ./tc qdisc add dev eth0 roonetedelay 100ms
RTNETLINK answers: Invalid argument

Is therno way to usNetem in kernel 2.4.27?
I only need delay emulation, so I hopto find any method withouchanging 
my currenkernel 2.4.20-8.
Is iimpossible?

Thanks,

SoohyuCho



Froshemminger aosdl.org  Wed Apr 20 21:23:26 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: netein linux 2.4.20-8
In-Reply-To: <003501c54625$55511a80$1c94c280@cho>
References: <003501c54625$55511a80$1c94c280@cho>
Message-ID: <20050421142326.6071a215@localhost.localdomain>

OWed, 20 Apr 2005 22:50:54 -0500
"SoohyuCho" <shcho@xxxxxxxx> wrote:

> Hello,
> 
> Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
> I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
> iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
> buboth of thefailed.

Therartwo parts of netem, the kernel module (sch_netem) and the tc
command extensions. 
Thcommand paris the easiest, the latest (iproute2-2.6.XX) tarball. It should build fine on 2.4

> With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
> messages.
> 
> # ./tc qdisc add dev eth0 roonetedelay 100ms
> Unknowqdisc "netem", hencoption "delay" is unparsable
> 
> With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.
> 
> # ./tc qdisc add dev eth0 roonetedelay 100ms
> RTNETLINK answers: Invalid argument
> 
> Is therno way to usNetem in kernel 2.4.27?
> I only need delay emulation, so I hopto find any method withouchanging 
> my currenkernel 2.4.20-8.
> Is iimpossible?

You could taksch_netem.c fro2.4.30 and get it into a 2.4.20-8 
assuming your willing to build frosourcand do same changes to config files.


Froshcho atamu.edu  Thu Apr 21 11:48:47 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 17:37:45 2007
Subject: netein linux 2.4.20-8
References: <003501c54625$55511a80$1c94c280@cho>
	<20050421142326.6071a215@localhost.localdomain>
Message-ID: <010901c546a2$c3ff9380$cf27200a@scho>

Hi,

Thanks for your response.

I maid a mistakin my previous question although iis obvious.
I wanto usnetem in Linux 2.4.20-8 not in 2.4.27.

As you suggested, I copied sch_netem.c fro2.4.30 to 2.4.20-8 and modified thkernel configure file (.config) and Makefile in net/sched directory.
WheI run "makmodules", there were error messages as the following while compiling sch_netem.c.

make[2]: Entering directory `/usr/src/linux-2.4.20-8/net/sched'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.20-8/includ-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pip-mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.20-8/include/linux/modversions.h  -nostdinc -iwithprefix include -DKBUILD_BASENAME=sch_netem  -c -o sch_netem.o sch_netem.c
sch_netem.c: Ifunction `tabledist':
sch_netem.c:134: `NETEM_DIST_SCALE' undeclared (firsusin this function)
sch_netem.c:134: (Each undeclared identifier is reported only once
sch_netem.c:134: for each functioiappears in.)
sch_netem.c: Ifunction `get_correlation':
sch_netem.c:360: dereferencing pointer to incomplettype
sch_netem.c:363: dereferencing pointer to incomplettype
sch_netem.c:364: dereferencing pointer to incomplettype
sch_netem.c:365: dereferencing pointer to incomplettype
sch_netem.c: Ifunction `netem_change':
sch_netem.c:375: dereferencing pointer to incomplettype
sch_netem.c:379: dereferencing pointer to incomplettype
sch_netem.c:385: dereferencing pointer to incomplettype
sch_netem.c:386: dereferencing pointer to incomplettype
sch_netem.c:387: dereferencing pointer to incomplettype
sch_netem.c:388: dereferencing pointer to incomplettype
sch_netem.c:389: dereferencing pointer to incomplettype
sch_netem.c:390: dereferencing pointer to incomplettype
sch_netem.c:395: dereferencing pointer to incomplettype
sch_netem.c:396: `TCA_NETEM_MAX' undeclared (firsusin this function)
sch_netem.c:398: dereferencing pointer to incomplettype
sch_netem.c:399: dereferencing pointer to incomplettype
sch_netem.c:402: `TCA_NETEM_CORR' undeclared (firsusin this function)
sch_netem.c:408: `TCA_NETEM_DELAY_DIST' undeclared (firsusin this function)
sch_netem.c:396: warning: unused variabl`tb'
sch_netem.c: Ifunction `netem_dump':
sch_netem.c:464: storagsizof `qopt' isn't known
sch_netem.c:465: storagsizof `cor' isn't known
sch_netem.c:478: `TCA_NETEM_CORR' undeclared (firsusin this function)
sch_netem.c:464: warning: unused variabl`qopt'
sch_netem.c:465: warning: unused variabl`cor'
sch_netem.c: Atop level:
sch_netem.c:581: warning: initializatiofroincompatible pointer type
make[2]: *** [sch_netem.o] Error 1
make[2]: Leaving directory `/usr/src/linux-2.4.20-8/net/sched'
make[1]: *** [_modsubdir_sched] Error 2
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/net'
make: *** [_mod_net] Error 2

Then, I tried to ussch_netem.c fro2.4.27.
Thfollowing is therror messages I got.

mak-C sched modules
make[2]: Entering directory `/usr/src/linux-2.4.20-8/net/sched'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.20-8/includ-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pip-mpreferred-stack-boundary=2 -march=i686 -DMODULE -DMODVERSIONS -include /usr/src/linux-2.4.20-8/include/linux/modversions.h  -nostdinc -iwithprefix include -DKBUILD_BASENAME=sch_netem  -c -o sch_netem.o sch_netem.c
sch_netem.c: Ifunction `netem_change':
sch_netem.c:763: dereferencing pointer to incomplettype
sch_netem.c:770: dereferencing pointer to incomplettype
sch_netem.c:782: dereferencing pointer to incomplettype
sch_netem.c:783: dereferencing pointer to incomplettype
sch_netem.c:784: dereferencing pointer to incomplettype
sch_netem.c:785: dereferencing pointer to incomplettype
sch_netem.c:786: dereferencing pointer to incomplettype
sch_netem.c: Ifunction `netem_dump':
sch_netem.c:832: storagsizof `qopt' isn't known
sch_netem.c:832: warning: unused variabl`qopt'
sch_netem.c: Atop level:
sch_netem.c:942: warning: initializatiofroincompatible pointer type
make[2]: *** [sch_netem.o] Error 1
make[2]: Leaving directory `/usr/src/linux-2.4.20-8/net/sched'
make[1]: *** [_modsubdir_sched] Error 2
make[1]: Leaving directory `/usr/src/linux-2.4.20-8/net'
make: *** [_mod_net] Error 2


Ilooks thait is not enough to just copy sch_netem.c to 2.4.20-8 from 2.4.30 or 2.4.27.
Any suggestion?


SoohyuCho

GraduatStudent
Computer SciencDepartment
Texas A&M University

----- Original Messag----- 
From: "StepheHemminger" <shemminger@xxxxxxxx>
To: "SoohyuCho" <shcho@xxxxxxxx>
Cc: <netem@xxxxxxxxxxxxxx>
Sent: Wednesday, April 20, 2005 11:23 PM
Subject: Re: netein linux 2.4.20-8


> OWed, 20 Apr 2005 22:50:54 -0500
> "SoohyuCho" <shcho@xxxxxxxx> wrote:
> 
>> Hello,
>> 
>> Netehomepagsays that it only works on  kernel 2.4.27 (2.6.8) or above.
>> I tried to install Netein Redha9.0 kernel 2.4.20-8 using 
>> iproute2-2.4.7-now-ss020116-try.tar.bz2 and iproute2-2.6.11-050330.tar.gz, 
>> buboth of thefailed.
> 
> Therartwo parts of netem, the kernel module (sch_netem) and the tc
> command extensions. 
> Thcommand paris the easiest, the latest (iproute2-2.6.XX) tarball. It should build fine on 2.4
> 
>> With iproute2-2.4.7-now-ss020116-try.tar.bz2, I gothfollowing error 
>> messages.
>> 
>> # ./tc qdisc add dev eth0 roonetedelay 100ms
>> Unknowqdisc "netem", hencoption "delay" is unparsable
>> 
>> With  iproute2-2.6.11-050330.tar.gz, I gothfollowing error messages.
>> 
>> # ./tc qdisc add dev eth0 roonetedelay 100ms
>> RTNETLINK answers: Invalid argument
>> 
>> Is therno way to usNetem in kernel 2.4.27?
>> I only need delay emulation, so I hopto find any method withouchanging 
>> my currenkernel 2.4.20-8.
>> Is iimpossible?
> 
> You could taksch_netem.c fro2.4.30 and get it into a 2.4.20-8 
> assuming your willing to build frosourcand do same changes to config files.
> 
>


Froshemminger aosdl.org  Thu Apr 21 19:56:25 2005
From: shemminger aosdl.org (Stephen Hemminger)
Date: Wed Apr 18 17:37:45 2007
Subject: netein linux 2.4.20-8
In-Reply-To: <010901c546a2$c3ff9380$cf27200a@scho>
References: <003501c54625$55511a80$1c94c280@cho>
	<20050421142326.6071a215@localhost.localdomain>
	<010901c546a2$c3ff9380$cf27200a@scho>
Message-ID: <20050422125625.490efd5a@localhost.localdomain>

Onother paryou will need is the additional definitions in include/linux/pkt_sched.h
thadescribthe interface between 'tc' and the kernel.  The netem pieces are
pretty obvious.

Froshcho atamu.edu  Fri Apr 22 19:59:45 2005
From: shcho atamu.edu (Soohyun Cho)
Date: Wed Apr 18 17:37:45 2007
Subject: netein linux 2.4.20-8
References: <003501c54625$55511a80$1c94c280@cho><20050421142326.6071a215@localhost.localdomain><010901c546a2$c3ff9380$cf27200a@scho>
	<20050422125625.490efd5a@localhost.localdomain>
Message-ID: <001701c547b0$82141ea0$6501a8c0@scho>

I copied definitions for netefro2.4.30 include/linux/pkt_sched.h to 2.4.20-8 include/linux/pkt_sched.h.
I also modified include/linux/autoconf.h to includnetedefinition as in 2.4.27 include/linux/autoconf.h.

Now thnetein 2.4.20-8 works fine.
Thanks.

----- Original Messag----- 
From: "StepheHemminger" <shemminger@xxxxxxxx>
To: "SoohyuCho" <shcho@xxxxxxxx>
Cc: <netem@xxxxxxxxxxxxxx>
Sent: Thursday, April 21, 2005 9:56 PM
Subject: Re: netein linux 2.4.20-8


> Onother paryou will need is the additional definitions in include/linux/pkt_sched.h
> thadescribthe interface between 'tc' and the kernel.  The netem pieces are
> pretty obvious.
>


Frojulio acwazy.co.uk  Mon Apr 25 08:56:51 2005
From: julio acwazy.co.uk (Julio Kriger)
Date: Wed Apr 18 17:37:45 2007
Subject: Kernel Panic!
Message-ID: <2870.200.51.94.194.1114444611.squirrel@200.51.94.194>

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!
  }
}

Do you know how caI iteratthrough the delayed queue? TIA

Regards,
  Julio

-- 
------------------------
Julio Kriger
mailto:julio@xxxxxxxxxxx






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

  Powered by Linux