Network Bonding + MPTCP Test

[preparation]

Read the following labs first.

1.      https://nqucsie.myqnapcloud.com/smallko/sdn/mptcp-test.htm

2.      https://nqucsie.myqnapcloud.com/smallko/sdn/mininet-link-aggregate.htm

 

[Topology]

 

[test_bonding_mptcp.py]

#!/usr/bin/env python

from mininet.net import Mininet

from mininet.cli import CLI

from mininet.link import Link, TCLink,Intf

from subprocess import Popen, PIPE

from mininet.log import setLogLevel

 

if '__main__' == __name__:

  setLogLevel('info')

  net = Mininet(link=TCLink)

  key = "net.mptcp.mptcp_enabled"

  value = 1

  p = Popen("sysctl -w %s=%s" % (key, value), shell=True, stdout=PIPE, stderr=PIPE)

  stdout, stderr = p.communicate()

  print "stdout=",stdout,"stderr=", stderr

 

  h1 = net.addHost('h1')

  h2 = net.addHost('h2')

  r1 = net.addHost('r1')

  s1 = net.addHost('s1')

  s2 = net.addHost('s2')

  linkopt={'bw':10}

  linkopt2={'bw':100}

  net.addLink(h1,s1,cls=TCLink, **linkopt)

  net.addLink(h1,s1,cls=TCLink, **linkopt)

  net.addLink(h1,s2,cls=TCLink, **linkopt)

  net.addLink(h1,s2,cls=TCLink, **linkopt)

  net.addLink(s1,r1,cls=TCLink, **linkopt2)

  net.addLink(s2,r1,cls=TCLink, **linkopt2)

  net.addLink(r1,h2,cls=TCLink, **linkopt2)

  net.build()

  s1.cmd("brctl addbr br0")

  s2.cmd("brctl addbr br1")

  r1.cmd("ifconfig r1-eth0 0")

  r1.cmd("ifconfig r1-eth1 0")

  r1.cmd("ifconfig r1-eth2 0")

  s1.cmd("ifconfig s1-eth0 0")

  s1.cmd("ifconfig s1-eth1 0")

  s1.cmd("ifconfig s1-eth2 0")

  s2.cmd("ifconfig s2-eth0 0")

  s2.cmd("ifconfig s2-eth1 0")

  s2.cmd("ifconfig s2-eth2 0")

  h1.cmd("ifconfig h1-eth0 0")

  h1.cmd("ifconfig h1-eth1 0")

  h1.cmd("ifconfig h1-eth2 0")

  h1.cmd("ifconfig h1-eth3 0")

  h2.cmd("ifconfig h2-eth0 0")

  s1.cmd("brctl addif br0 s1-eth0")

  s1.cmd("brctl addif br0 s1-eth1")

  s1.cmd("brctl addif br0 s1-eth2")

  s1.cmd("ifconfig br0 up")

  s2.cmd("brctl addif br1 s2-eth0")

  s2.cmd("brctl addif br1 s2-eth1")

  s2.cmd("brctl addif br1 s2-eth2")

  s2.cmd("ifconfig br1 up")

  r1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

  r1.cmd("ifconfig r1-eth0 10.0.0.254 netmask 255.255.255.0")

  r1.cmd("ifconfig r1-eth1 10.0.1.254 netmask 255.255.255.0")

  r1.cmd("ifconfig r1-eth2 10.0.2.254 netmask 255.255.255.0")

 

  h1.cmd('echo "bonding mode=4 miimon=100" >> /etc/modules')

  h1.cmd("modprobe bonding")

  h1.cmd("ip link add bond0 type bond")

  h1.cmd("ip link set bond0 address 00:00:00:11:22:33")

  h1.cmd("ip link set h1-eth0 down")

  h1.cmd("ip link set h1-eth1 down")

  h1.cmd("ip link set h1-eth0 master bond0")

  h1.cmd("ip link set h1-eth1 master bond0")

  h1.cmd("ip addr add 10.0.0.1/24 dev bond0")

  h1.cmd("ip link set bond0 up")

 

  h1.cmd("ip link add bond1 type bond")

  h1.cmd("ip link set bond1 address 00:00:00:44:55:66")

  h1.cmd("ip link set h1-eth2 down")

  h1.cmd("ip link set h1-eth3 down")

  h1.cmd("ip link set h1-eth2 master bond1")

  h1.cmd("ip link set h1-eth3 master bond1")

  h1.cmd("ip addr add 10.0.1.1/24 dev bond1")

  h1.cmd("ip link set bond1 up")

 

  h1.cmd("ip rule add from 10.0.0.1 table 1")

  h1.cmd("ip rule add from 10.0.1.1 table 2")

  h1.cmd("ip route add 10.0.0.0/24 dev bond0 scope link table 1")

  h1.cmd("ip route add default via 10.0.0.254 dev bond0 table 1")

  h1.cmd("ip route add 10.0.1.0/24 dev bond1 scope link table 2")

  h1.cmd("ip route add default via 10.0.1.254 dev bond1 table 2")

  h1.cmd("ip route add default scope global nexthop via 10.0.0.254 dev bond0")

 

  h2.cmd("ifconfig h2-eth0 10.0.2.1 netmask 255.255.255.0")

  h2.cmd("ip rule add from 10.0.2.1 table 1")

  h2.cmd("ip route add 10.0.2.0/24 dev h2-eth0 scope link table 1")

  h2.cmd("ip route add default via 10.0.2.254 dev h2-eth0 table 1")

  h2.cmd("ip route add default scope global nexthop via 10.0.2.254 dev h2-eth0")

 

  CLI(net)

  net.stop()

 

[execution]

From the following test, we can see that bonding + mptcp can help increase the performance.

 

For use test, we can see that only bonding works.

 

Dr. Chih-Heng Ke (smallko@gmail.com)

Department of Computer Science and Information Engineering,

National Quemoy University, Kinmen, Taiwan