Tag Archives: openflow

Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 3)

Uploading and setting up the firmware on TP-Link TL-WR1043ND router

  1. Connect your PC’s Ethernet adapter to TP-Link TL-WR1043ND router’s LAN port
    Note: The adapter configuration must remain the same as in Asus WL-500g Deluxe setup.
  2. Open http://192.168.1.1 in your browser
    Type your username and password!
    (default admin/admin)
    Click System Tools
    Click Firmware Upgrade
    Click Browse…
    Select “openwrt-ar71xx-tl-wr1043nd-v1-squashfs-factory.bin” file and click Open
    Click Upgrade
    Click OK for question about the upgrade
  3. Wait until the progress bar finish
  4. From a terminal login to the router:
    $ telnet 192.168.1.1
    You should get:
    Connected to 192.168.1.1.
    Escape character is '^]'.
    === IMPORTANT ============================
    Use 'passwd' to set your login password
    this will disable telnet and enable SSH
    ------------------------------------------
    BusyBox v1.15.3 (2013-11-16 00:12:17 CET) 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
    ---------------------------------------------------
    Backfire (10.03.x Snapshot, r33081)
    ---------------------------------------------------
    * 1/3 shot Kahlua    In a shot glass, layer Kahlua
    * 1/3 shot Bailey's  on the bottom, then Bailey's,
    * 1/3 shot Vodka     then Vodka.
    ---------------------------------------------------
    root@OpenWrt:/#
  5. Change the routers IP address (just for running config):
    root@OpenWrt:/# ifconfig br-lan 192.168.1.2

    Close telnet (Ctrl + C, or by closing the terminal)

  6. Login to your router
    $ telnet 192.168.1.2
  7. Change your password:
    root@OpenWrt:/# passwd

    Enter your new password 2 times.

  8. Reconnect to the router using SSH
    root@OpenWrt:/# exit
    $ ssh root@192.168.1.2

    Type “yes” for the question about the RSA key and press Enter
    Give your password and press Enter

  9. Change switch identifier in openflow configuration:
    root@OpenWrt:/# nano /etc/config/openflow
    Change line

    option 'dpid' '000000000001'

    to

    option 'dpid' '000000000002'

    Press Ctrl+O, Enter than Ctrl+X to exit

  10. Change the network configuration
    • You can this by hand:
      root@OpenWrt:/# nano /etc/config/network
      Correct configuration:

      config 'switch'
      	option 'name' 'rtl8366rb'
      	option 'reset' '1'
      	option 'enable_vlan' '1'
      	option 'enable_learning' '0'
      config 'switch_vlan'
      	option 'device' 'rtl8366rb'
      	option 'vlan' '1'
      	option 'ports' '1 5t'
      config 'switch_vlan'
      	option 'device' 'rtl8366rb'
      	option 'vlan' '2'
      	option 'ports' '2 5t'
      config 'switch_vlan'
      	option 'device' 'rtl8366rb'
      	option 'vlan' '3'
      	option 'ports' '3 5t'
      config 'switch_vlan'
      	option 'device' 'rtl8366rb'
      	option 'vlan' '4'
      	option 'ports' '4 5t'
      config 'switch_vlan'
      	option 'device' 'rtl8366rb'
      	option 'vlan' '5'
      	option 'ports' '0 5t'
      config 'interface' 'loopback'
      	option 'ifname' 'lo'
      	option 'proto'  'static'
      	option 'ipaddr' '127.0.0.1'
      	option 'netmask' '255.0.0.0'
      config 'interface'
      	option 'ifname' 'eth0.1'
      	option 'proto' 'static'
      config 'interface'
      	option 'ifname' 'eth0.2'
      	option 'proto' 'static'
      config 'interface'
      	option 'ifname' 'eth0.3'
      	option 'proto' 'static'
      config 'interface'
      	option 'ifname' 'eth0.4'
      	option 'proto' 'static'
      config 'interface'
      	option 'ifname' 'eth0.5'
      	option 'proto' 'static'
      	option 'ipaddr' '192.168.1.2'
      	option 'netmask' '255.255.255.0'

      Press Ctrl+O, Enter than Ctrl+X to exit

    • You can do this with scp:
      Download this file with your browser: network-tplink

       $ scp network-tplink root@192.168.1.2:/etc/config/network

      Enter the router’s password

  11. Reboot the router
    root@OpenWrt:/# reboot
  12. Connect your PC’s Ethernet adapter to TP-Link TL-WR1043ND router’s WAN port
    (this is the configuration port, and the out-of-band communication port for OpenFlow)

That’s all! From now you can install an OpenFlow controller (eg. POX). The default controller address is 192.168.1.10:6633 (which can be set in /etc/config/openflow file).

If you want to restore the factory firmware:
Restoring factory firmware on TP-Link TL-WR1043ND

Jump to previous: Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 2)

Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 2)

Uploading and setting up the firmware on Asus WL-500g Deluxe router

Note:
OpenWrt wiki is wrong. You cannot upload the firmware through Asus WL-500g Deluxe web interface (aka OEM easy installation).

  1. Connect your PC’s Ethernet adapter to Asus WL-500g Deluxe router’s LAN port
  2. Set your network configuration to:
    IP address: 192.168.1.10
    Netmask: 255.255.255.0

    Note 1:
    If you want to make it in VirtualBox than you also have to set bridged networking by:

    1. Click Settings
    2. Click Network
    3. Select “Adapter 1” tab
    4. Set “Attached to:” to “Bridged Adapter”
    5. Set “Promiscuous Mode:” to “Allow All”
    6. Click OK

    Note 2:
    In Fedora 19, you can do this by:

    1. Click the network icon (top right corner)
    2. Click Network Settings
    3. Select Wired
    4. Click the setup icon (bottom right corner)
    5. Select IPv4
    6. Set Addresses to Manual
    7. Set Address to 192.168.1.10
    8. Set Netmask to 255.255.255.0
    9. Set Gateway to 192.168.1.1 (this is only required because of a Fedora 19 bug)
    10. Click Apply
    11. Set the “On” switch to “Off”
    12. Set the “Off” switch to “On”
    13. Close the windows
  3. Install a tftp client if you don’t have one
    $ sudo yum -y install tftp
  4. Disconnect the router from power
  5. Press and hold the reset button (at it’s back)
  6. Power up the Asus WL-500g Deluxe router (still holding the reset button)
  7. After the four LAN leds turn dark you can release the reset button
  8. The power led should start flashing slowly (if not try again from the disconnect part)
  9. From a terminal:
    $ tftp
    tftp> binary
    tftp> trace
    tftp> put openwrt-brcm47xx-squashfs.trx
    Wait until it finish
    tftp> quit
  10. Wait at least 2 minutes (for safety)
  11. Toggle the power
  12. Install a telnet client if you don’t have one
    Note: Yes it’s a shame, but Linux distributions are weird today.

    $ sudo yum -y install telnet
  13. Login to the router
    $ telnet 192.168.1.1
    You should get:

    Connected to 192.168.1.1.
    Escape character is '^]'.
    === IMPORTANT ============================
    Use 'passwd' to set your login password
    this will disable telnet and enable SSH
    ------------------------------------------
    BusyBox v1.15.3 (2013-11-16 00:12:17 CET) 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
    ---------------------------------------------------
    Backfire (10.03.x Snapshot, r33081)
    ---------------------------------------------------
    * 1/3 shot Kahlua    In a shot glass, layer Kahlua
    * 1/3 shot Bailey's  on the bottom, then Bailey's,
    * 1/3 shot Vodka     then Vodka.
    ---------------------------------------------------
    root@OpenWrt:/#
  14. Setup the router’s password
    root@OpenWrt:/# passwd

    Enter your new password 2 times.

  15. Reconnect to the router using SSH
    root@OpenWrt:/# exit
    $ ssh root@192.168.1.1

    Type “yes” for the question about the RSA key and press Enter
    Give your password and press Enter

  16. Change the network configuration
    • You can this by hand:
      root@OpenWrt:/# nano /etc/config/network

      Note:
      You may get here “Error opening terminal: xterm-256color.”
      It’s a Fedora 19 bug, type:
      root@OpenWrt:/# export TERM=xterm-color
      Correct configuration:

      #### VLAN configuration
      config switch eth0
      	option enable   1
      
      config switch_vlan eth0_0
      	option device   "eth0"
      	option vlan     0
      	option ports    "0 5"
      
      config switch_vlan eth0_1
      	option device   "eth0"
      	option vlan     1
      	option ports    "4 5"
      
      config switch_vlan eth0_2
      	option device   "eth0"
      	option vlan     2
      	option ports    "3 5"
      
      config switch_vlan eth0_3
      	option device   "eth0"
      	option vlan     3
      	option ports    "2 5"
      
      config switch_vlan eth0_4
      	option device   "eth0"
      	option vlan     4
      	option ports    "1 5"
      
      #### Loopback configuration
      config interface loopback
      	option ifname    "lo"
      	option proto    static
      	option ipaddr    127.0.0.1
      	option netmask    255.0.0.0
      
      #### LAN configuration
      config interface lan
      	option type     bridge
      	option ifname    "eth0.0"
      	option proto    static
      	option ipaddr    192.168.1.1
      	option netmask    255.255.255.0
      
      config interface
      	option ifname    "eth0.1"
      	option proto    static
      
      config interface
      	option ifname    "eth0.2"
      	option proto    static
      
      config interface
      	option ifname    "eth0.3"
      	option proto    static
      
      config interface
      	option ifname    "eth0.4"
      	option proto    static

      Press Ctrl+O, Enter than Ctrl+X to exit

    • You can do this with scp:
      Download this file with your browser: network-asus

      $ scp network-asus root@192.168.1.1:/etc/config/network

      Enter the router’s password

  17. Reboot the router
    root@OpenWrt:/# reboot
  18. Connect your PC’s Ethernet adapter to Asus WL-500g Deluxe router’s WAN port
    (this is the configuration port, and the out-of-band communication port for OpenFlow)

That’s all! From now you can install an OpenFlow controller (eg. POX). The default controller address is 192.168.1.10:6633 (which can be set in /etc/config/openflow file).

If you want to restore the factory firmware:
Restoring factory firmware on Asus WL-500g Deluxe

Jump to next: Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 3)
Jump to previous: Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 1)

Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 1)

In this guide I will install OpenWrt Backfire on these routers with OpenFlow package.

WARNING: you may brick your router if version is > 1.7!
See Version/Model table

Device: TP-Link TL-WR1043ND Ver: 1.6
FCC ID: TE7WR1043NX
CPU: Atheros AR9132
RAM: 32 MB
Flash: 8 MB
Network: 4 + 1 ports (10/100/1000 Mb/s)
IP address before: 192.168.1.1
IP address after: 192.168.1.2
Software before: TL-WR1043ND_v1_130428
Version: 3.13.13 Build 130428 Rel.58290n

Software after: OpenWrt Backfire
Version: 10.03.1 (r33081)

OpenFlow
Stanford reference implementation
Version: 1.0
Device: Asus WL-500g Deluxe
FCC ID: MSQWL500GD
CPU: Broadcom 5365
RAM: 32 MB
Flash: 4 MB
Network: 4 + 1 ports (10/100 Mb/s)
IP address: 192.168.1.1
Software before: WL-500gD English Firmware
Version: 1.9.6.0
Software after: OpenWrt Backfire
Version: 10.03.1 (r33081)
OpenFlow

Stanford reference implementation
Version: 1.0

Build system:
Fedora 19 (64 bit)

If you are not using Fedora 19, you should virtualize it:
Installing Fedora 19 (64 bit) in VirtualBox

Building OpenWrt with OpenFlow package

  1. Open a terminal (by clicking Activities, typing “terminal” and press Enter)
  2. Update Fedora
    $ sudo yum -y update

    Enter your password
    Press Enter

  3. Install the packages that necessary to build OpenWrt
     $ sudo yum -y install git subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel make patch unzip perl-ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt sed sdcc intltool sharutils bison wget

    Note: All packages are necessary but some of them may has been already installed. And I am not wrong, you need subversion package because scripts use it.
    Enter your password
    Press Enter

  4. Download OpenWrt Backfire source from the OpenWrt Git repository:
    $ git clone git://git.openwrt.org/10.03/openwrt.git
  5. Get in the downloaded directory
    $ cd openwrt
  6. Update and install feeds
    $ ./scripts/feeds update -a
    $ ./scripts/feeds install -a
  7. Get out from openwrt directory
    $ cd ..
  8. Download the Stanford reference implementation of OpenFlow 1.0
    $ git clone git://gitosis.stanford.edu/openflow-openwrt

    If it doesn’t work here is a copy of it one my site: openflow-openwrt.tar.gz
    In this case you must extract it: $ tar -zxvf openflow-openwrt.tar.gz

  9. Get in the downloaded directory
    $ cd openflow-openwrt
  10. Move to the Broadcom branch
    $ git checkout -b openflow-1.0/brcm origin/openflow-1.0/brcm
  11. Link OpenFlow extension and configuration files in the OpenWrt directory
    $ cd ~/openwrt/package
    $ ln -s ~/openflow-openwrt/openflow-1.0/
    $ cd ..
    $ ln -s ~/openflow-openwrt/openflow-1.0/files
  12. Configure the build
    $ make menuconfig

    Select “Target System (…) —>”
    Select “Broadcom BCM947xx/953xx”
    Select “Target Profile (…) —>”
    Select “No WiFi”
    Select “Network —>”
    Check “openflow” package (to built-in <*>)
    Check “tc” package (to built-in <*>)
    Exit
    Select “Kernel modules —>”
    Select “Network Support —>”
    Check “kmod-tun” package (to built-in <*>)
    Exit
    Exit
    Select “Utilites —>”
    Select “Editors —>”
    Check “nano” package (to built-in <*>)
    Exit
    Exit
    Exit
    A dialog asks you here “Do you wish to save your new OpenWrt configuration?”
    Select Yes and Press Enter

  13. Make the toolchain for the target
    $ make tools/install toolchain/install
  14. Configure the Linux kernel
    $ make kernel_menuconfig

    Select Networking Support
    Select Networking options
    Select QoS and/or fair queueing
    Check Hierarchical Token Bucket (HTB) (to built-in <*>)
    Exit
    Exit
    Exit
    Exit
    Select Yes and Press Enter

  15. Build the OpenWrt image
    $ make
  16. Get out from openwrt directory
    $ cd ..
  17. Copy the created general firmware to here
    $ cp openwrt/bin/brcm47xx/openwrt-brcm47xx-squashfs.trx .

    This will be the firmware for Asus WL-500g Deluxe.

  18. Enter to openwrt directory again
    $ cd openwrt
  19. Clean everything
    $ make clean tools/clean toolchain/clean

    Note: a toolchain/clean should be enough here (but I don’t want to meet OpenWrt bugs)

  20. Get out from openwrt directory
    $ cd ..
  21. Get in the openflow directory
    $ cd openflow-openwrt
  22. Move to the TP-Link branch
    $ git checkout -b openflow-1.0/tplink origin/openflow-1.0/tplink
  23. Get to the openwrt directory
    $ cd ~/openwrt
  24. Configure the build
    $ make menuconfig

    Select “Reset to defaults”
    Select “Target System (…) —>”
    Select “Atheros AR71xx/AR7240/AR913x”
    Select “Target Profile (…) —>”
    Select “TP-LINK TL-WR1043ND v1”
    Note: From Backfire version of OpenWrt the Wifi module is automatically built in this platform, so we must clear it later from selection. DO NOT select “Default Profile (no WiFi)” here!
    Select “Network —>”
    Check “openflow” package (to built-in <*>)
    Check “tc” package (to built-in <*>)
    Uncheck “wpad-mini” package
    Exit
    Select “Kernel modules —>”
    Select “Network Support —>”
    Check “kmod-tun” package (to built-in <*>)
    Exit
    Select “Wireless Drivers”
    Uncheck “kmod-ath9k”
    Exit
    Exit
    Select “Utilites —>”
    Select “Editors —>”
    Check “nano” package (to built-in <*>)
    Exit
    Exit
    Exit
    A dialog asks you here “Do you wish to save your new OpenWrt configuration?”
    Select Yes and Press Enter

  25. Make the toolchain for the target
    $ make tools/install toolchain/install

    Note: If you have not cleaned tools than tools/install is not necessary.

  26. Configure the Linux kernel
    $ make kernel_menuconfig

    Select Networking Support
    Select Networking options
    Select QoS and/or fair queueing
    Check Hierarchical Token Bucket (HTB) (to built-in <*>)
    Exit
    Exit
    Exit
    Exit
    Select Yes and Press Enter

  27. Build the OpenWrt image
    $ make
  28. Get out from openwrt directory
    $ cd ..
  29. Copy the created general firmware to here
    $ cp openwrt/bin/ar71xx/openwrt-ar71xx-tl-wr1043nd-v1-squashfs-factory.bin .

    This will be the firmware for TP-Link TL-WR1043ND.

  30. You can safely remove the created directories:
    $ rm -rf ~/openwrt ~/openflow-openwrt

Congratulation! You have built the OpenFlow capable OpenWrt firmwares for these devices.

Jump to: Converting Asus WL-500g Deluxe and TP-Link TL-WR1043ND to OpenFlow switches (Part 2)