Tuesday, August 21, 2012

[Trema][Concept] How to do flow-based ECMP in Routing Switch App

  As we have known that Routing Switch App uses Dijkstra algorithm to pick up the lowest cost of the path. Only one path will be selected. If we want to do flow-based ECMP, how to do it? I have a simple way to slightly modify the Routing Switch App and then it can become "ECMP Routing Switch" App.

  Here is a topology as follows. If the source is PC1 and destination is PC2, we can know that the source switch is A and destination switch is B. I will base on this to explain my idea.

  First, we setup a number of multi-path , for instance, 8, and let the loop to do Dijkstra algorithm these times.
  Second, we need to add a new chosen flag to record nodes in the path that we have picked up, and get rid of the source and destination node. And also, when Dijkstra algorithm is running, we also need to add a condition to avoid from choosing the node whose chosen flag is true.

For instance, Path 1 is A->B->C->D. We need to add flag on B and C as true.
                        Path 2 is A->E->F->D. We need to add flag on E and F as true.

In this case, Dijkstra algorithm is not able to pick up the third path so that making paths is done.
I have implemented this in Routing Switch App and it works. I will post the real case in the next article.


Wednesday, August 8, 2012

[Trema] Provide a monitoring application to watch port and flow loading

I currently provide a initial version of monitoring application to watch port and flow loading information. Here are some items about the configuration and criteria for sending notification.



The configuration
  • port_percentage_condition
    • the threshold of port loading percentage
  • port_setting_feature_rate
    • the speed rate of port
  • flow_bit_rate_conditon
    • the threshold of flow loading
  • flow_times_condition
    • how many seconds will flow become big flow when being over the threshold of flow loading

The notification criteria of Port Loading
  • Check port loading per 4 seconds
  • Calculate the percentage of port loading
    • port_bit_rate = avg_rx_bytes * 8
    • port_loading_percentage = port_bit_rate * 100 / port_feature_rate
  • If the port loading percentage is higer than port_percentage_condition, then it sends port loading notification
The notification criteria of Flow Loading
  • Check port loading per 4 seconds
  • Calculate the flow loading ( flow_bit_rate )
    • flow_bit_rate = bytes_count * 8 / duration seconds
  • If flow_bit_rate  is bigger than flow_bit_rate_condition, then flow_times adds 1.
  • If flow_times is higher than flow_times_condition, for instance, 3, then it sends flow loading notification

Tuesday, August 7, 2012

[Introduction] ar and ranlib

ar and ranlib
ar this program can do the following actions to the archive (static library)
create, modify, and extract.Following is a list of several commonly used options explained:
  • d: delete
    • Remove files from the archive
  • r: replace
    • Insert archive files to be replaced
  • u: update
    • option 'r' is usually to replace all, but the option u only will be inserted over the files in the archive in
  • v: verbose
    • The implementation, as well as additional information
for example:
   > ar uv mylib.a first.o second.o

These directives is to establish two obj file into a mylib.a, and shows the implementation of the process information

ranlib generates an index to the contents of an archive and stores it in the archive. The index lists each symbol defined by a member of an archive that is a relocatable object file.

You can use nm-s or nm, - print-armap Include to list this index

To run this program is to increase the speed of linking to the library and allows routines in the library can call each other without having to worry about these routines in the archive of the placement order

[Cucumber] An brief introduction

http://cukes.info/
I just saw the "Cucumber" and was amazed by its power of scenario testing with human-readable syntax and sentences. It is so amazing...
If you guys want to do the job for testing, that is a good choice~

For more information in details, please also check it out:
http://andrewvos.com/2011/06/15/writing-better-cucumber-features/
http://grosser.it/2008/12/25/getting-started-with-cucumber-on-ubuntu/
http://jeannotsweblog.blogspot.tw/search?q=cucumber
http://holmwood.id.au/~lindsay/2009/11/09/behaviour-driven-infrastructure-through-cucumber/

How to install Cucumber
sudo apt-get install libxslt1-dev libxml2-dev racc
sudo apt-get install gem
sudo gem install gherkin
sudo gem install cucumber./script/generate cucumber
rake features

[How To] Add ZeroMQ in Trema App

If someone wants to add the mechanism of ZeroMQ to send message from Trema Application, for instance, Routing_Switch, there are several things that need to do and I have tested OK.

Example Trema App: Routing_Switch

1. Install ZeroMQ
2. Modify its Makefile: 
  • add the include folder location of ZeroMQ :
    • CFLAGS = $(shell $(TREMA)/trema-config --cflags) -I/home/liudanny/SourceCode/zeromq2-1/include -I../topology -g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Werror -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith
  • add library name of zeroMQ and link it:
    • LDFLAGS = $(shell $(TREMA)/trema-config --libs) -lzmq -L../topology -ltopology
3. Write your ZeroMQ code in Routing_Switch.

Thursday, July 26, 2012

[How to][Trema] Get Flow_Removed message in routing_switch app

I asked an question about how to get Flow_Removed message in routing_switch app. But, soon I realized that I asked a stupid one because the answer is also in OpenFlow Spec v1.0.0.
We should set a "OFPFF_SEND_FLOW_REM" flag into "Flow Mod" message when we want to set a flow. The following list is the discussion message log.

================================================================ 
Hi,


If you want to receive "Flow Removed" message, you have to set
"OFPFF_SEND_FLOW_REM" flag into "Flow Mod" message when you set the flow.


Currently "routing_switch" app does not set this flag, then switches does
not send "Flow Removed" message.

================================================================
Hi,
  I try to get "Flow_Removed" message in routing_switch app, but do not see any one coming in.
The following is what I have done in the app and could someone tell me how to fix or modify it?
Many thanks.


Add it in main():
  set_flow_removed_handler( handle_flow_removed, routing_switch );


Add a method for display:
void handle_flow_removed( uint64_t datapath_id, flow_removed message ) {
  routing_switch *routing_switch = message.user_data;
  info( "[handle_flow_removed] dpid = %#" PRIx64 ", match = %s",
          datapath_id, message.match );
}


Modify routing_switch.conf:
vswitch {
  datapath_id "0xe0"
}
vhost ("host1") {
  ip "192.168.0.1"
  netmask "255.255.0.0"
  mac "00:00:00:01:00:01"
}
vhost ("host2") {
  ip "192.168.0.2"
  netmask "255.255.0.0"
  mac "00:00:00:01:00:02"
}
link "0xe0", "host1"
link "0xe0", "host2"


run {
  path "../apps/topology/topology"
}
run {
  path "../apps/topology/topology_
discovery"
}
run {
  path "../apps/routing_switch/routing_switch"
}


event :port_status => "topology", :packet_in => "filter", :state_notify => "topology", :flow_removed => "routing_switch"
filter :lldp => "topology_discovery", :packet_in => "routing_switch"

Wednesday, July 25, 2012

[Shell Script][Example] Files Copying Operation with Warning When the Same File Exists

Because someone asks me to do him a favor for a sample of of file copying operation, I just use bash shell to do so. Here is an example to use shell script to copy files from source path to destination path, which will give a warning message and skip copying if there is a file that exists.


#!/bin/bash SRC_DIR="/home/liudanny/scripts" # put your source directory DST_DIR="/home/liudanny/Downloads" # put your destination directory for src_full_name in "$SRC_DIR"/* # loop all the files in source directory do fname=$(echo ${src_full_name}|sed 's#^.*/##') # get the file name echo "name:$fname" dst_full_name=`printf "%s/%s" $DST_DIR $fname` # generate the destination file name echo "dst_full_name:$dst_full_name" if [ -e $dst_full_name ]; # check if destination file exists then echo "File: $fname exists..." else echo "Do copying $fname ..." cp $src_full_name $dst_full_name # if not exists, then copy file fi done

Monday, July 9, 2012

[ARP] How to look up arp table (mac/ip mapping) in Linux

First, we can ping hostname(ip_addr) to add mac/ip mapping into arp table
or use arp command to do so:
> arp -s hostname(ip_addr) MAC_addr

Second, look up arp table:
> arp -n   (I recommend to use "-n" for avoiding DNS lookup. It is faster.)
        Address                  HWtype    HWaddress               Flags Mask            Iface
        10.3.207.245             ether      20:aa:4b:a3:4c:b7            C                     eth4

or there is another way:
> ip ne
        10.3.207.245 dev eth4 lladdr 20:aa:4b:a3:4c:b7 REACHABLE



Thursday, June 28, 2012

[OpenFlow] Update and Setup TP-LINK TL-WR1043ND for OpenFlow

Currently the version of TP-LINK TL-WR1043ND which I can get in Taiwan is "(TW) ver:1.0" instead of ver:1.8 I want. But, fortunately, after asking the vendor about this issue, he responds that there is no difference in hardware between "(TW) ver:1.0"and ver:1.8 or ver:1.4. That is a good news to me though. The following items are my steps to  transform original TP-LINK TL-WR1043ND to OpenFlow-enabled switch. Most of information is from http://www.openflow.org/wk/index.php/Pantou_:_OpenFlow_1.0_for_OpenWRT

1. Update firmware on your device
Installing OpenWrt this web site has 4 methods for us to do updating. Because my TL-WR1043ND is brand new one, I choose the simplest of method 1: via orginal firmware.
  • Download  image  (v1.8)
  • Change your PC ip address to 192.168.1.2
  • Connect to the switch with LAN port
  • Browse http://192.168.1.1
  • Choose function "update firmware" with the image bin file


2. Modify Configuration 
  • Login  to 192.168.1.1 using telnet
  • Setup your controller ip address (my controller ip is 192.168.1.244)
    • vi  /etc/config/openflow
        config 'ofswitch'
                option 'dp' 'dp0'
                option 'dpid' '000000000011'
                option 'ofports' 'eth0.0 eth0.1 eth0.2 eth0.3 '
                option 'ofctl' 'tcp:192.168.1.244:6633'
                option 'mode'  'outofband'


  • Setup your network configuration and setup this switch ip address (my switch ip is 192.168.1.11)
    • vi /etc/config/network and paste the following lines
        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.11'
                option 'netmask' '255.255.255.0' 

 3. Restart networking to enable your changes
  • /etc/init.d/network restart
4. Verify (My case is for Trema Controller)
  • Connect your Ethernet cable from LAN port to WAN port
  • Start any kind of Trema app
    • for instance : ./trema run ./objects/examples/learning_switch/learning_switch
  • Show switch description
    • TREMA_HOME=`pwd` ../apps/show_description/show_description
    • And then we can get the information as follows:
        Manufacturer description: Stanford University
        Hardware description: Reference Userspace Switch
        Software description: 1.0.0
        Serial number: None
        Human readable description of datapath: OpenWrt pid=1933
        Datapath ID: 0x11
        Port no: 1(0x1)(Port up)
          Hardware address: 90:f6:52:89:c9:d0
          Port name: eth0.1
        Port no: 2(0x2)(Port up)
          Hardware address: 90:f6:52:89:c9:d0
          Port name: eth0.2
        Port no: 3(0x3)(Port up)
          Hardware address: 90:f6:52:89:c9:d0
          Port name: eth0.3
        Port no: 4(0x4)(Port up)
          Hardware address: 90:f6:52:89:c9:d0
          Port name: eth0.4

Wednesday, June 27, 2012

[OpenFlow] Summary of some current OpenFlow Related Articles


1. http://blog.ioshints.info/2011/11/openflow-enterprise-use-cases.html
This article discusses enterprise use cases in OpenFlow
  • There are four functions you can easily implement with OpenFlow (Tony Bourke wrote about them in more details)
    • packet filters – flow classifier followed by a drop or normal action
    • policy based routing – flow classifier followed by outgoing interface and/or VLAN tag push
    • static routes – flow classifiers using only destination IP prefix
    • NAT – some OpenFlow switches might support source/destination IP address/port rewrites.

2. http://routerjockey.com/2011/11/02/nec-and-programmableflow-switching/
This article writer give some information and comments about NEC programmableflow because he joined NEC presenting at Networking Tech Field Day 2


3. http://blog.ioshints.info/2011/11/openflow-deployment-models.html#of_native
This article provides four different models for OpenFlow deployment have already emerged:
  • Native OpenFlow
    • The controller performs all control-plane functions, including running control-plane protocols with the outside world. 
    • This model has at least two serious drawbacks even if we ignore the load placed on the controller by periodic control-plane protocols:
      • The switches need IP connectivity to the controller for the OpenFlow control session. 
      • Fast control loops like BFD are hard to implement with a central controller, more so if you want to have very fast response time.
  • Native OpenFlow with extensions
    • A switch controlled entirely by the OpenFlow controller could perform some of the low-level control-plane functions independently.
    • Using OpenFlow extensions or functionality implemented locally on the switch, you destroy the mirage of the “OpenFlow networking nirvana”-- smart open-source programmable controllers control dumb low-cost switches, busting the “networking = mainframes” model and bringing the Linux-like golden age to every network.
  • Ships in the night
    • Switches have traditional control plane; OpenFlow controller manages only certain ports or VLANs on trunked links. The local control plane (or linecards) can perform the tedious periodic tasks like running LACP, LLDP and BFD, passing only the link status to the OpenFlow controller.
  • Integrated OpenFlow
    •  OpenFlow classifiers and forwarding entries are integrated with the traditional control plane. For example, Juniper’s OpenFlow implementation inserts compatible flow entries (those that contain only destination IP address matching) as ephemeral static routes into RIB (Routing Information Base)
    •  From my perspective, this approach makes most sense: don’t rip-and-replace the existing network with a totally new control plane, but augment the existing well-known mechanisms with functionality that’s currently hard (or impossible) to implement.