sexta-feira, 2 de maio de 2014

Kernel-based Openflow OpenVSwitch on TP-Link WR-1043nd with OpenWRT

I spent a couple days compiling the OpenVswitch 2.0 (and 2.1.2) for my TP-Link WR-1043ND V1.8. I tried at first the Open WRT "trunk" version, but due some errors regarding the "PKG_USE_MIPS16:=0" parameters, I gave up and I decided to use the stable 12.10 Attitude Adjustment, r40431. Later, I found the solution for this MIPS16 issue in the menuconfig "Target Options", but I still with the 12.10 stable version.

The result was amazing, much better than the results with Pantou or CPQD's user-mode switches. I obtained 92 Mbps of throughput instead of the 29 Mbps in user-mode switches. Probably I can get more, but my computer interfaces negociated only at 100 Mbps for the Iperf test.
There is also a user-mode option on OpenVSwitch, but is very slow, with 4 Mbps of throughput.
I'll try to figure out the differences in features between the two modes later.

The steps to compile the OVS are the following, using a Linux machine (either virtual or real) with Ubuntu 12.19, 7 GB free space, 1,5 Gb RAM.

apt-get install git quilt build-essential binutils flex bison autoconf gettext texinfo sharutils subversion libncurses5-dev ncurses-term zlib1g-dev gawk

git clone git://git.openwrt.org/12.09/openwrt.git cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
The next step is choosing the feed location. For the 2.0 OVS version:
echo 'src-git openvswitch git://github.com/alexanderplatz1999/openvswitch.git' >> feeds.conf
or 2.1.2 OVS version:
echo 'src-git openvswitch git://github.com/pichuang/openvwrt.git' >> feeds.conf

./scripts/feeds update openvswitch
./scripts/feeds install -a -p openvswitch
make menuconfig
Select Target Profile (TP-LINK TL-WR1043N/ND)
<*> iperf
-*- openvswitch-common
<*> openvswitch-controller
<*> openvswitch-ipsec
<*> openvswitch-switch
<*> tcpdump
Kernel modules ---> Network Support ---> <*> kmod-tun
Save and Exit
make kernel_menuconfig
> Networking support > Networking options > <*> Open vSwitch
> Networking support > Networking options > <*> Hierarchical Token Bucket (HTB)
Save and Exit
echo '# CONFIG_KERNEL_BRIDGE is not set' >> .config

     You can do the "make" command right now, but the image will be generated without the configuration files. The image will be in the openwrt/bin/ar71xx/openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin file.The IP address for telnet access using a LAN port is 192.168.1.1, no login and password.
Transfer the image to the router using the Web GUI if you are using the original TP-Link firmware or WINSCP
BusyBox v1.19.4 (2014-04-08 13:48:14 PDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 ATTITUDE ADJUSTMENT (Attitude Adjustment, r40431)
 -----------------------------------------------------
  * 1/4 oz Vodka      Pour all ingredients into mixing
  * 1/4 oz Gin        tin with ice, strain into glass.
  * 1/4 oz Amaretto
  * 1/4 oz Triple sec
  * 1/4 oz Peach schnapps
  * 1/4 oz Sour mix
  * 1 splash Cranberry juice
 -----------------------------------------------------
root@OpenWrt:~#

    If you want to include the configuration files before the "make", follow this steps in the Linux machine (not the router):
mkdir files
mkdir files/etc
mkdir files/etc/config
mkdir files/etc/rc.d
   Copy the files from this Gist location. The S99ovsboot (adapted from a  script used  in NZNOG SDN workshop) must be saved in the files/etc/rc.d, and the "network", "firewall" and "wireless" in the files/etc/config directory.
With these configuration files, the IP address to access the router is 192.168.1.112 on the WAN port and the openflow controller address is 192.168.1.130.
   You can try the compiled image (tested on a TP-Link WR-1043 V1.8). The IP address of WAN interface is 192.168.1.112 and the controller is 192.168.1.130, but you can change them editing the files /etc/config/network and /etc/rc.d/S99bootovs.

Update:
During the tests I obtained more than 500 Mbps. Is much more than the user space switch (29 Mbps). The results of IPERF test for upload and WGET download of a 400 MB file are the following. Without the DUT (the TP-Link), the performance was about 1 Gbps.

IPERF:
------------------------------------------------------------
Client connecting to 200.x.x.x, TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  3] local 100.64.0.1 port 54581 connected with 200.x.x.x port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   611 MBytes   513 Mbits/sec

------------------------------------------------------------
Client connecting to 200.x.x.x, TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  3] local 100.64.0.1 port 54584 connected with 200.x.x.x port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   594 MBytes   498 Mbits/sec

------------------------------------------------------------
Client connecting to 200.x.x.x, TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  3] local 100.64.0.1 port 54587 connected with 200.x.x.x port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   590 MBytes   495 Mbits/sec

WGET (HTTP)
...
410250K .......... .......... .......... .......... ....      100% 89,1M=6,7s
2014-05-19 13:22:36 (60,2 MB/s) - /dev/null

60,2 MB/s = 481,6 Mbps

14 comentários:

  1. Sorry.i am a new student on SDN. I have a problem .I update your compiled image .But I cant connect to 192.168.1.1. how can i solve my problem?What happen on my 1043nd.

    ResponderExcluir
    Respostas
    1. Did you try open a telnet session to the IP 192.168.1.112, with the computer connected in the TP-Link WAN interface ?

      Excluir
  2. Thanks for the thorough instructions. I loaded the new image on my TP-Link WR-1043ND. I don't see an ovs userspace components such as ovs-vsctl. Shouldn't have the binary been built with the correct packages installed? I'm curious what I am doing incorrectly.

    ResponderExcluir
    Respostas
    1. Hi Jeff,
      I've just reinstalled the binary image above in my TP-Link WR-1043 to check you question and all the tools are in there:

      root@OpenWrt:/# ovs-vsctl -V
      ovs-vsctl (Open vSwitch) 2.0.0
      Compiled May 2 2014 10:57:58
      root@OpenWrt:/# ovs
      ovs-appctl ovs-dpctl ovs-pki ovs-vswitchd
      ovs-benchmark ovs-monitor-ipsec ovs-tcpundump ovsdb-client
      ovs-bugtool ovs-ofctl ovs-vlan-test ovsdb-server
      ovs-controller ovs-pcap ovs-vsctl ovsdb-tool

      BTW, the included script /etc/rc.d/S99bootovs uses these tools to start the OVS on the boot time.

      Excluir
    2. OK. I think one problem is that 'trunk' is different now than it was when you wrote this. One difference is that that 'feeds' includes an ovs package.

      Will your binary work for v2.1? Any chance you could post somewhere?

      Excluir
    3. Hi Jeff,
      I uploaded a new firmware for the TP-Link WR-1043v1.8 with OVS 2.3.0 (thanks Pichuang) in http://goo.gl/SWGOrw . The access IP is 192,168.1.1 in LAN interface.
      I still using the Attitude_Adjustment (12.10), Try to use this stable version instead the trunk.

      root@OpenWrt:~# ovs-vsctl -V
      ovs-vsctl (Open vSwitch) 2.3.0
      Compiled Oct 27 2014 17:27:05
      DB Schema 7.6.0

      Excluir
  3. Thanks, Márcio! I didn't know the 1.8 images were binary compatible with 2.1. I guess that's why I don't see Pantou or CPqD binaries for 2.1.

    I tried stable using your directions and Pichuang's. I usually encounter the build error someone else opened at https://dev.openwrt.org/ticket/14158. I'm using your exact build environment and command sequence.

    I'm going to take a break from compilation attempts and use your binary. Thanks again.

    Jeff L.

    ResponderExcluir
    Respostas
    1. Hi Jeff,
      The binary image firmware compiled for TP-Link 1.8 is NOT compatible with TP-Link V2.1. I misunderstood your question. I thought you were talking about the OVS version.
      I think is possible build an image for TPLink 2.1 with the "Barrier Breaker" 14.07 branch. For this, change svn source in the instructions for: svn://svn.openwrt.org/openwrt/branches/barrier_breaker .

      Excluir
    2. Márcio,

      I successfully built an image. The problem appears to have been the use of the '-j' flag for 'make'. I used the OVS package from the official feeds in trunk. I'll post the images once I do some testing to verify OF functionality.

      Thanks for your help.

      Excluir
    3. Hi Jeff,
      I've read in the Openflow list that you succesfully compiled the Openwrt for Tp-link WR1043v2.1, but you was unable to ping it. I guess it's an issue with the script /etc/rc.d/S99openvswitch. To fix this,
      do a telnet (address 192.168.1.1) to the router in the rescue mode (pressing the QSS button just after the system led starts to blink) ,
      mount the root filesystem (mount_root), move that script to another location (/etc) and reboot the router. After this, your router will work (I hope).
      To start the OVS, I suggest the script S99boot-ovs ( http://goo.gl/7iz5ZI ) , but in the first place, edit the addresses in the top of files and make it executable.

      Excluir
    4. Márcio,

      Thanks for the suggestion. In failsafe mode, I will mount the filesystem and examine the start-up scripts. I need a better understanding of these scripts and the physical switch hardware for the v2.1. There are differences according to the 1043 wiki. I am wondering if there is a clash between the linux bridge and OVS. I'm getting closer...

      Excluir
  4. We have made a tutorial to make RouterBoard 750GL Openflow enabled.
    What this tutorial contain:
    -Installation procedure of OpenWRT on RouterBoard GL750
    -Installation procedure of Openflow v1.0 on RouterBoard GL750
    -Installation of NOX/POX/Floodlight Controller
    -Testing of OpenFlow enabled Network
    This tutorial can be downloaded from the following link:
    http://bit.ly/openflow_RouterBoard_GL750

    ResponderExcluir
    Respostas
    1. Nice work, but you have installed the user mode switch (aka Pantou) in there, The user mode switch has a very poor performance. Try to replace to the Open Vswitch 2.1, using this tutorial.

      Excluir
  5. Este comentário foi removido pelo autor.

    ResponderExcluir