Showing posts from April, 2012

[How to] Install Qt SDK on Ubuntu

1. Download Qt SDK

2. Change the file's mode for execution and run it.
> chmod u+x ( e.g )
> ./ ( e.g. )

3. Install g++ compiler
> sudo apt-get install g++

4. If the error message ( Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap" ) shows when running Qt Creator, you need to run:
> sudo apt-get install gtk2-engines-pixbuf

[How to] Install Boost library on Ubuntu

> sudo apt-get install libboost-all-dev
That's it.

And also, there are plenty of examples as follows:

Look for a Qt library for network topology

Qanava could be my solution for network topology based on Qt4. But, it had been not maintained anymore...

main page:

git repository

Qanava Manual v0.1.0

[How to] Use tcpdump to look at LLDP packet

Here is an example about how to use tcpdump tool to look at LLDP information

> sudo tcpdump -c 1 -lv -v -i eth0 -a -e -s 1514 ether proto 0x88cc

The result:
tcpdump: listening on eth4, link-type EN10MB (Ethernet), capture size 1514 bytes
13:30:46.426056 08:00:27:09:61:e9 (oui Unknown) > 01:80:c2:00:00:0e (oui Unknown), ethertype LLDP (0x88cc), length 156: LLDP, length 142
    Chassis ID TLV (1), length 7
      Subtype MAC address (4): 08:00:27:09:61:e9 (oui Unknown)
      0x0000:  0408 0027 0961 e9
    Port ID TLV (2), length 7
      Subtype MAC address (3): 08:00:27:09:61:e9 (oui Unknown)
      0x0000:  0308 0027 0961 e9
    Time to Live TLV (3), length 2: TTL 120s
      0x0000:  0078
    System Name TLV (5), length 15: Ubuntu-Devstack
      0x0000:  5562 756e 7475 2d44 6576 7374 6163 6b
    System Description TLV (6), length 43
      Ubuntu 11.10\0x0a Linux 3.0.0-14-generic x86_64
      0x0000:  5562 756e 7475 2031 312e 3130 0a20 4c69
      0x0010:  6e75 7820 332e 302e 302d 3134 2d67 656e

[ZeroMQ] The new solution for building up distributed system

I have used TIBCO Rendezvous (RV Message), ActiveMQ (JMS), and RabbitMQ(AMQP) before. They all have message broker, which means all the messages will be send to broker (centralized control) first, and then the client or node will receives them later. But, ZeroMQ has totally different story. I personally believe that it could be a very good solution for building up distributed system.

    And also, this article gives the short introduction and summarizes the important items including "communication transport", "End Point Implementation", "The Socket Object", and so on about ZeroMQ. This content is very uesful for beginner to get to know and read first.

[Python] Make pyc file for your Python source code

It could be a situation when you have to give your Python program to customers, but you don't want to give them Python source code. Here is a solution. Give them Python byte code!

For example, on command line:
Compile one file          > python -c "import compileall; compileall.compile_file('')"
Compile one folder          > python -c "import compileall; compileall.compile_dir('YourFolder/', force=True)"

Or, you can put the compiling action in source code

      compileall.compile_dir('YourFolder/', force=True)

[Quantum] An example of OpenStack Quantum's table schema and data

mysql> SELECT * FROM ovs_quantum.networks n LIMIT 0,1000;
| uuid                                 | tenant_id | name    | op_status |
| 5b2c8537-26df-4fdc-9e38-3f3f09797d3f | default   | private | UP        |
1 row in set (0.00 sec)
mysql> SELECT * FROM ovs_quantum.ports p LIMIT 0,1000;
| uuid                                 | network_id                           | interface_id                         | state  | op_status |
| e1b7cec5-1d7c-4bcd-b123-4a97f37ef498 | 5b2c8537-26df-4fdc-9e38-3f3f097…

[sFlow] sFlow Agent and sFlow Collector

sFlow is a technology for monitoring network, wireless and host devices. Based on the following topology, there is a test about using sFlow Agent and sFlow Collector to observe the sFlow data from Open vSwitch.

sFlow agent is from Open vSwitch           How to setup sFlow on Open vSwitch:
          > sudo ovs-vsctl -- --id=@s create sFlow agent=eth0 target=\"colletor ip:6343\" header=128 sampling=64 polling=10 -- set Bridge br0 sflow=@s 
sFlow collector is sFlowTrend  Now, we can see the results from sFlowTrend:

 When trying to ping PC1 and PC2, the result is below:

[Comparsion] Topology graph in NOX GUI and OpenFlow GUI

Using GNS3 for constructing an emulation network environment, I give a simple topology as follows to try running NOX GUI and OpenFlow GUI.
P.S: for more information in GNS3, please refer to this:

In NOX GUI, the topology graph is created like this:

In OpenFlow GUI, the topology graph is created like this:

[Trema] Try Trema App: flow_dumper

1. Choose "routing_switch" as my testing app. (any other simple switch app is all available...)
> ./trema run -c ../apps/routing_switch/routing_switch.conf

2. Send packets between these 2 hosts
> ./trema send_packets -s host2 -d host1
> ./trema send_packets -s host1 -d host2

3. Try to run Trema App: "flow_dumper" as follows
> TREMA_HOME=. ../apps/flow_dumper/flow_dumper
[0x000000000000e0] priority = 65535, match = [wildcards = 0, in_port = 1, dl_src = 00:00:00:01:00:02, dl_dst = 00:00:00:01:00:01, dl_vlan = 65535, dl_vlan_pcp = 0, dl_type = 0x800, nw_tos = 0, nw_proto = 17, nw_src =, nw_dst =, tp_src = 1, tp_dst = 1], actions = [output: port=2 max_len=65535]
[0x000000000000e0] priority = 65535, match = [wildcards = 0, in_port = 2, dl_src = 00:00:00:01:00:01, dl_dst = 00:00:00:01:00:02, dl_vlan = 65535, dl_vlan_pcp = 0, dl_type = 0x800, nw_tos = 0, nw_proto = 17, nw_src =, nw_dst =, tp_src = 1, t…

[Tutorial] How to setup QoS on Open vSwitch

There are two ways to do that:

1. Interface Rate Limiting ( on Interface )
For instance:          > sudo ovs-vsctl set Interface eth1 ingress_policing_rate=10000
         > sudo ovs-vsctl set Interface eth1 ingress_policing_burst=1000

 2. Port  QoS Policy ( on Port )
For instance:          > sudo ovs-vsctl set port eth1 qos=@newqos \
             -- --id=@newqos create qos type=linux-htb \
             other-config:max-rate=200000000 queues=0=@q0,1=@q1 \
             -- --id=@q0 create queue \
             other-config:min-rate=100000000 \
             other-config:max-rate=100000000 \
              -- --id=@q1 create queue \
             other-config:min-rate=50000000 \
Qos can have more than 1 queue

[Tutorial] Trema Tutorial

[Open vSwitch] How to get port statistics from interface in OVS

1. Show the bridge info
> sudo ovs-vsctl show
    Bridge "br0"
        Controller "tcp:"
        Port "br0"
            Interface "br0"
                type: internal
        Port "eth3"
            Interface "eth3"
        Port "eth2"
            Interface "eth2"
        Port "eth1"

2. Get port statistics from interface
> sudo ovs-vsctl get Interface br0 statistics
{collisions=0, rx_bytes=0, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=0, tx_bytes=0, tx_dropped=0, tx_errors=0, tx_packets=0}

[Python] How to use Decorators for Functions and Methods

When list_ports() is executed, Class ApiCall will be created for becoming a decorator to examine the arguments as follows:

importsysclassApiCall(object):"""A Decorator to add support for format and tenant overriding"""def__init__(self,function):self.function=functiondef__get__(self,instance,owner):defwith_params(*args,**kwargs):""" Temporarily sets the format and tenant for this request """(format,tenant)=(instance.format,instance.tenant)if'format'inkwargs:instance.format=kwargs['format']if'tenant'inkwargs:instance.tenant=kwargs['tenant']ret=self.function(instance,*args)(instance.format,instance.tenant)=(format,tenant)returnretreturnwith_paramsclassClient(object):def__init__(self,tenant=None,format="xml"):self.tenant=tenantself.format=format@ApiCalldeflist_ports(self,network):""" Fetches a list of ports on a given network "&q…

[Tutorial][Trema] Show Topology

Trema有一個很不錯的App, 可以利用toplogy與 topology_discovery App, 去產生topology graph…如下:

下列為Network emulation的設定檔內容 # virtual switches vswitch("switch1") { datapath_id "0x1" } vswitch("switch2") { datapath_id "0x2" } vswitch("switch3") { datapath_id "0x3" } vswitch("switch4") { datapath_id "0x4" } vswitch("switch4") { datapath_id "0x5" }
# virtual hosts vhost("host1") vhost("host2") vhost("host3") vhost("host4")
# virtual links link "switch1", "switch2" link "switch1", "switch3" link "switch2", "switch3" link "switch2", "switch4" link "switch2", "switch5" link "switch3", "switch4"
link "switch3", "switch5" link "switch4", "switch5" link "switch4", "host1" link "switch4", "host2" link &…

[Tutorial] ovsdbmonitor GUI 設定步驟 (setup procedure)

The following steps are the setup procedure for running ovsdbmonitor GUI (You have to make sure that your "PYTHONPATH" contains the path of openvswitch source path/python. ) 1. 增加PYTHONPATH到 .bashrc for example:

2. 增加一個symbolic link for ovsdb-client
sudo ln -s /usr/local/bin/ovsdb-client /usr/bin/ovsdb-client

3. 執行ovsdbmonitor
“your openswitch path”/ovsdb/ovsdbmonitor/ovsdbmonitor

4. 設定Host Properties:
Host name or IP: your openvswitch host
SSH Password: ***
Connect target: unix:/usr/local/var/run/openvswitch/db.sock
*     這個connect target 會與 啟動ovsdb-server daemon 的參數有相關 *           sudo ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \                     --remote=db:Open_vSwitch,manager_options \                     --private-key=db:SSL,private_key \                     --certificate=db:SSL,certificate \                     --bootstrap-ca-cert=db:SSL,ca_cert \            …

[Info] Quantum L3 Model and API

The following link is about adding L3 concept and APIs ( routing between Subnets) into OpenStack Quantum.

The more information is here:


# There is an example to do with Singleton in Pythondefsingleton(cls):instances={}defgetinstance():ifclsnotininstances:instances[cls]=cls()returninstances[cls]returngetinstance@singletonclassMyClass():def__init__(self)"AAA"if__name__=="__main__":obj_a=MyClass()"AAAA"printobj_a,obj_a.dataobj_b=MyClass()printobj_b,

Big Switch: the SDN Coffee Talks

Big Switch Networks Launches SDN Coffee Talks to Further Educate the
Broader IT Community on Software-Defined Networking (SDN)

the SDN Coffee Talks

如何取得Open vSwitch 上的 datapath id

ovs-vsctl -- get bridge br-int datapath_id

[HowTo] Build up GRE Tunneling on Open vSwitch

// Create a bridge
ovs-vsctl add-br br0

// Build up GRE Tunnel on remote host's ip = x.x.x.x
ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=x.x.x.x

In this article, the author explains more info about GRE Tunneling in details.
The way for him to build GRE Tunneling is as follows:
ovs-vsctl set interface gre0 type=gre options:remote_ip=x.x.x.x options:pmtud=false