OpenWrt Forum Archive

Topic: iproute 2, tc and Netem support

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi All,

I'm interested in using the WRT as WAN Network Emulator for a network/internet application that I am working on.

The WRT should be ideal for this smile

I was wondering if the latest version of OpenWRT supports iproute2 and the NETEM http://developer.osdl.org/shemminger/netem/
options that go with the tc command?

for example -

# tc qdisc change dev eth0 root netem delay 100ms 10ms

and...

# tc qdisc change dev eth0 root netem loss .1%


Most importantly for me is the ability to set delays and packet drop rates individually for each port.

Do you know if this is possible?

Any advice will be of great value and I will post a wiki on my findings if and when I can start acheiving my goals smile

Cheers
Shaun

*Quietly watches the tumble weeds go by...*

Apparently, "Netem is part of the latest 2.4 and 2.6 kernels". What kernel version is OpenWRT on?

*Quietly watches the tumble weeds go by...*

Apparently, "Netem is part of the latest 2.4 and 2.6 kernels". What kernel version is OpenWRT on?

Well... we're using iproute 2.6.9 and Linux 2.4.29, so I guess when you compile your own version of experimental, you can get your NETEM support.

big_smile

OK so this functionality is not yet available? (Darn, I was hoping not to have to buy a second WRT just to find out if this can or can't be done sad )


so I guess when you compile your own version of experimental, you can get your NETEM support.

Hmm, I'm a bit new to Linux (old hat at windoz). Although I have been playing around with the NSLU2 for a while. I guess I could have a go at compiling my own kernel. How hard can it be  :?

Any pointers on how to get started *ducks and waits for the flames*



big_smile

Kind of a late reply, but I figured someone else might be interested.. it took me half a day to figure it all out.

The short version:
- Grab my q_netem.so and put it in /usr/lib
- Grab my sch_netem.o and put it in /lib/modules/2.4.30
- insmod sch_netem
- netem should now be working. test with something like "tc qdisc add dev eth0 root netem delay 5ms"

The long version:
- Find a linux box or run something in vmware
- svn co https://svn.openwrt.org/openwrt/branches/whiterussian/
- open ./target/linux/linux-2.4/config/brcm, find the line "# CONFIG_NET_SCH_NETEM is not set", and change it to "CONFIG_NET_SCH_NETEM=m"

(depending on the box you compile from, you might have to:
- apt-get install bzip2 unzip zlibc zlib1g-dev
- edit toolchain/Makefile and remove the gdb from "TARGETS:=sed utils binutils gcc uClibc ipkg-utils gdb"
- cp -r ./target/linux/package/openwrt/include/* ./staging_dir_mipsel/usr/include/ )

- run make menuconfig
- make sure package selection -> iproute2 TC / IP are enabled (M)
- make sure kernel configuration -> linux 2.4/support for broadcom based routers is enabled (*)
- if you want to save time compiling (and just need the netem modules, not a complete openwrt build), you can disable everything else

- run make clean world
- find your q_netem.so in ./build_mipsel/iproute2-2.6.11-050330/tc/
- find your sch_netem.o in ./build_mipsel/linux-2.4-brcm/modules/lib/modules/2.4.30/kernel/net/sched/


I'm pretty new at this, so please let me know if I did something wrong or left anything out.

lvl wrote:

Kind of a late reply, but I figured someone else might be interested.. it took me half a day to figure it all out.

The short version:
- Grab my q_netem.so and put it in /usr/lib
- Grab my sch_netem.o and put it in /lib/modules/2.4.30
- insmod sch_netem
- netem should now be working. test with something like "tc qdisc add dev eth0 root netem delay 5ms"

Just wanted to say that it works like a charm (installed on top of WhiteRussian 0.9 - http://downloads.openwrt.org/whiterussian/0.9/)!
With this, you get a compact, reliable, almost free hardware network emulator - http://en.wikipedia.org/wiki/Network_emulation! It's great to emulate any kind of network conditions (high latency, asymetric bandwidth, jitter, packet loss, ...).

Thanks a million lvl!

Can anybody do me a huge favor and compile me a copy of these two for BRCM 2.4.30 whiterussian? I'd really really appreciate it. AND I'd be happy to personally host them with a link from this topic for a long, long time. Much appreciated. SQuinlanesq at gmail.com

nevermind my post. I guess you can use ipkg to do this now. ipkg install ip tc

Hello,

   I am opening this topic again since I would like to use netem on the top of my Linksys WRT54GL v1.1 with whiterussian 0.9 but still I am failing to do it.
Here are some logs I got:

root@OpenWrt:/# ipkg install ip tc
Installing ip (2.6.11-050330-1) to root...
Downloading http://downloads.openwrt.org/whiterussi … mipsel.ipk
Package tc (2.6.11-050330-1) installed in root is up to date.
Configuring ip
Successfully terminated.
root@OpenWrt:/#


root@OpenWrt:/# tc qdisc add dev eth0 root netem delay 10ms
Unknown qdisc "netem", hence option "delay" is unparsable
root@OpenWrt:/# insmod sch_netem
insmod: sch_netem.o: no module by that name found


What do you mean I can do it with ipkg?

Cheers

any hint related to my last post?

Sure:

I am using OpenWrt "trunk", which is based on buildroot-ng:  http://wiki.openwrt.org/_media/doc/howt … erview.png and netem works for me :-P

You may get a helping answer from somebody, but WhiteRussian ain't supported any longer.

Download http://downloads.openwrt.org/snapshots/ … cm47xx.ipk
Extract it and look for http://lxr.free-electrons.com/source/ne … ch_netem.c, just compiled. sch_netem.ko

If it ain't present, then kmod-sched was compiled without it, and you need to compile your own WITH it.
It should be enough to compile the package kmod-sched and then install this with opkg!

For installation check: http://wiki.openwrt.org/doc/techref/opkg  opkg install /tmp/kmod-sched_2.6.37.6-1_brcm47xx.ipk  should do the trick.

To compile it, foo, dont' know.
Follow this: http://wiki.openwrt.org/doc/howto/obtai … re.compile

make menuconfig bla bla

And then instead of a simple make, you have to tell him to only compile the missing package: "kmod-sched".

cf: http://wiki.openwrt.org/doc/howto/obtai … e.packages

You need the path of the package.

Please report back

The discussion might have continued from here.