commit f4a2a77db9097230236a5c1caf331559ea29ef71
Author: Jiri Prochazka <jprochaz(a)redhat.com>
Date: Thu May 21 18:11:34 2015 +0200
Add example recipes from LNST wiki page about NetEm
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
Acked-by: Jiri Pirko <jiri(a)resnulli.us>
recipes/examples/netem/corruption.xml | 39 +++++++++++++++++++++++++
recipes/examples/netem/delay.xml | 43 ++++++++++++++++++++++++++++
recipes/examples/netem/duplication.xml | 39 +++++++++++++++++++++++++
recipes/examples/netem/loss.xml | 39 +++++++++++++++++++++++++
recipes/examples/netem/netem_test.py | 41 ++++++++++++++++++++++++++
recipes/examples/netem/reordering.xml | 49 ++++++++++++++++++++++++++++++++
6 files changed, 250 insertions(+), 0 deletions(-)
---
diff --git a/recipes/examples/netem/corruption.xml
b/recipes/examples/netem/corruption.xml
new file mode 100644
index 0000000..7d2b645
--- /dev/null
+++ b/recipes/examples/netem/corruption.xml
@@ -0,0 +1,39 @@
+<lnstrecipe>
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <corrupt>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </corrupt>
+ </netem>
+ <addresses>
+ <address>192.168.101.10/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <corrupt>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </corrupt>
+ </netem>
+ <addresses>
+ <address>192.168.101.11/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ </network>
+ <task python="netem_test.py"/>
+</lnstrecipe>
diff --git a/recipes/examples/netem/delay.xml b/recipes/examples/netem/delay.xml
new file mode 100644
index 0000000..aad5cb9
--- /dev/null
+++ b/recipes/examples/netem/delay.xml
@@ -0,0 +1,43 @@
+<lnstrecipe>
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <delay>
+ <options>
+ <option name="time" value="10ms"
/>
+ <option name="jitter" value="1ms"
/>
+ <option name="correlation"
value="50%" />
+ <option name="distribution"
value="normal" />
+ </options>
+ </delay>
+ </netem>
+ <addresses>
+ <address>192.168.101.10/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <delay>
+ <options>
+ <option name="time" value="10ms"
/>
+ <option name="jitter" value="1ms"
/>
+ <option name="correlation"
value="50%" />
+ <option name="distribution"
value="normal" />
+ </options>
+ </delay>
+ </netem>
+ <addresses>
+ <address>192.168.101.11/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ </network>
+ <task python="netem_test.py"/>
+</lnstrecipe>
diff --git a/recipes/examples/netem/duplication.xml
b/recipes/examples/netem/duplication.xml
new file mode 100644
index 0000000..9b43183
--- /dev/null
+++ b/recipes/examples/netem/duplication.xml
@@ -0,0 +1,39 @@
+<lnstrecipe>
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <duplication>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </duplication>
+ </netem>
+ <addresses>
+ <address>192.168.101.10/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <duplication>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </duplication>
+ </netem>
+ <addresses>
+ <address>192.168.101.11/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ </network>
+ <task python="netem_test.py"/>
+</lnstrecipe>
diff --git a/recipes/examples/netem/loss.xml b/recipes/examples/netem/loss.xml
new file mode 100644
index 0000000..2ec6cb9
--- /dev/null
+++ b/recipes/examples/netem/loss.xml
@@ -0,0 +1,39 @@
+<lnstrecipe>
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <loss>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </loss>
+ </netem>
+ <addresses>
+ <address>192.168.101.10/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <loss>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </loss>
+ </netem>
+ <addresses>
+ <address>192.168.101.11/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ </network>
+ <task python="netem_test.py"/>
+</lnstrecipe>
diff --git a/recipes/examples/netem/netem_test.py b/recipes/examples/netem/netem_test.py
new file mode 100644
index 0000000..2405f11
--- /dev/null
+++ b/recipes/examples/netem/netem_test.py
@@ -0,0 +1,41 @@
+from lnst.Controller.Task import ctl
+
+hostA = ctl.get_host("machine1")
+hostB = ctl.get_host("machine2")
+
+hostA.sync_resources(modules=["IcmpPing", "Netperf"])
+hostB.sync_resources(modules=["IcmpPing", "Netperf"])
+
+ping_mod = ctl.get_module("IcmpPing",
+ options={
+ "addr": hostB.get_ip("testiface", 0),
+ "count": 1000,
+ "interval": 0.1,
+ "iface" : hostA.get_devname("testiface")})
+
+netserver = ctl.get_module("Netperf",
+ options={
+ "role" : "server",
+ "bind" : hostA.get_ip("testiface")})
+
+netperf_tcp = ctl.get_module("Netperf",
+ options={
+ "role" : "client",
+ "netperf_server" : hostA.get_ip("testiface"),
+ "duration" : 60,
+ "testname" : "TCP_STREAM",
+ "netperf_opts" : "-L %s" %
hostB.get_ip("testiface")})
+
+netperf_udp= ctl.get_module("Netperf",
+ options={
+ "role" : "client",
+ "netperf_server" : hostA.get_ip("testiface"),
+ "duration" : 60,
+ "testname" : "UDP_STREAM"})
+
+hostA.run(ping_mod, timeout=500)
+server_proc = hostA.run(netserver, bg=True)
+ctl.wait(2)
+hostB.run(netperf_tcp, timeout=100)
+hostB.run(netperf_udp, timeout=100)
+server_proc.intr()
diff --git a/recipes/examples/netem/reordering.xml
b/recipes/examples/netem/reordering.xml
new file mode 100644
index 0000000..5f96893
--- /dev/null
+++ b/recipes/examples/netem/reordering.xml
@@ -0,0 +1,49 @@
+<lnstrecipe>
+ <network>
+ <host id="machine1">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <delay>
+ <options>
+ <option name="time" value="10ms"
/>
+ </options>
+ </delay>
+ <reordering>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </reordering>
+ </netem>
+ <addresses>
+ <address>192.168.101.10/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ <host id="machine2">
+ <interfaces>
+ <eth id="testiface" label="testnet">
+ <netem>
+ <delay>
+ <options>
+ <option name="time" value="10ms"
/>
+ </options>
+ </delay>
+ <reordering>
+ <options>
+ <option name="percent" value="10%"
/>
+ <option name="correlation"
value="50%" />
+ </options>
+ </reordering>
+ </netem>
+ <addresses>
+ <address>192.168.101.11/24</address>
+ </addresses>
+ </eth>
+ </interfaces>
+ </host>
+ </network>
+ <task python="netem_test.py"/>
+</lnstrecipe>
Show replies by date