Saturday, June 8, 2013

[Trema] How to install Trema-edge on Ubuntu10.04

Installing Trema-edge needs to use the version of Ruby that is greater than 1.9. In best situation, version 2.0 is best.

1. Install Ruby 2.0
http://www.jeffduckett.com/blog/18/installing-ruby-2-0-0.html

> wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
> tar zxvf ruby-2.0.0-p0.tar.gz
> cd ruby-2.0.0-p0
> ./configure --prefix=/usr/local
> make
> sudo make install
> sudo apt-get -y install libreadline-ruby libopenssl-ruby
> sudo gem update --system
> gem -v

2. Install Bundler
> sudo gem install bundler

3. Clone Trema-edge source code
> git clone https://github.com/trema/trema-edge

4. Install sqlite3 and sqlite3-dev
> sudo apt-get install sqlite3 libsqlite3-dev

5. Build Trema-edge
(In your trema-edge directory)
> sudo bundle install
> sudo rake

6. Try a sample
> ./trema run src/examples/learning_switch/learning-switch.rb -c src/examples/learning_switch/sample.conf

Friday, April 19, 2013

[SDN] Networking in the cloud: An SDN primer

Ben Cherian, Chief Strategy Officer for Midokura, give a session talk in OpenStack Summit 2013 and the topic is "Networking in the cloud: An SDN primer". I didn't attend this Summit, but someone has summarized the points here:
http://blog.scottlowe.org/2013/04/16/openstack-summit-2013-networking-in-the-cloud-an-sdn-primer/

Furthermore, if you want to know more about what MidoNet truely is, you can check out these:
http://bradhedlund.com/2012/10/06/mind-blowing-l2-l4-network-virtualization-by-midokura-midonet/

















http://blog.ioshints.info/2012/08/midokuras-midonet-layer-2-4-virtual.html




Friday, March 22, 2013

[mininet] A simple example to build your own topology in mininet

Well, first of all I want to thank my colleague to giving me an example to build myself topology. It is very simple. Everyone can modify it and do your own topology with OpenFlow Controller.
Second, due to introducing switch cluster concept in Floodlight Controller, I will provide a simple example to give switch clusters in topology.

my_topology.py


from mininet.topo import Topo class MyTopo( Topo ): "Simple topology example." def __init__( self ): "Create custom topo." # Initialize topology Topo.__init__( self ) h1 = self.addHost( 'h1' ) h2 = self.addHost( 'h2' ) h3 = self.addHost( 'h3' ) h4 = self.addHost( 'h4' ) h5 = self.addHost( 'h5' ) h6 = self.addHost( 'h6' ) s1 = self.addSwitch( 's1' ) s2 = self.addSwitch( 's2' ) s3 = self.addSwitch( 's3' ) s4 = self.addSwitch( 's4' ) s5 = self.addSwitch( 's5' ) s6 = self.addSwitch( 's6' ) s7 = self.addSwitch( 's7' ) self.addLink( s1, s2 ) self.addLink( s1, s3 ) self.addLink( s2, s3 ) self.addLink( s2, s4 ) self.addLink( s2, s5 ) self.addLink( s3, s4 ) self.addLink( s3, s5 ) self.addLink( s4, h1 ) self.addLink( s4, h2 ) self.addLink( s5, s3 ) self.addLink( s5, s4 ) self.addLink( s6, h5 ) self.addLink( s7, h6 ) topos = { 'mytopo': ( lambda: MyTopo() ) }

Testing
Use the REST API in Floodlight Controller to query the related information as follows:

> curl -s http://localhost:8080/wm/topology/switchclusters/json
{
    "00:00:00:00:00:00:00:06": [
        "00:00:00:00:00:00:00:06",
        "00:00:00:00:00:00:00:07"
    ],
    "00:00:00:00:00:00:00:01": [
        "00:00:00:00:00:00:00:05",
        "00:00:00:00:00:00:00:02",
        "00:00:00:00:00:00:00:01",
        "00:00:00:00:00:00:00:03",
        "00:00:00:00:00:00:00:04"
    ]
}

> curl -s http://localhost:8080/wm/topology/links/json
[
    {
        "src-switch": "00:00:00:00:00:00:00:05",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:02",
        "dst-port": 4,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:02",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:01",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:04",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:02",
        "dst-port": 3,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:05",
        "src-port": 2,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:03",
        "dst-port": 4,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:02",
        "src-port": 3,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:04",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:06",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:07",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:07",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:06",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:03",
        "src-port": 3,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:04",
        "dst-port": 2,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:03",
        "src-port": 4,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:05",
        "dst-port": 2,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:03",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:01",
        "dst-port": 2,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:03",
        "src-port": 2,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:02",
        "dst-port": 2,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:02",
        "src-port": 4,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:05",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:04",
        "src-port": 2,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:03",
        "dst-port": 3,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:02",
        "src-port": 2,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:03",
        "dst-port": 2,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:01",
        "src-port": 2,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:03",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    },
    {
        "src-switch": "00:00:00:00:00:00:00:01",
        "src-port": 1,
        "src-port-state": 0,
        "dst-switch": "00:00:00:00:00:00:00:02",
        "dst-port": 1,
        "dst-port-state": 0,
        "type": "internal"
    }
]

> curl -s http://localhost:8080/wm/device/
[
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "82:da:cd:82:03:13"
        ],
        "ipv4": [
            "10.0.0.6"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 2,
                "switchDPID": "00:00:00:00:00:00:00:07",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763792481
    },
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "62:76:b0:43:51:c7"
        ],
        "ipv4": [
            "10.0.0.1"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 3,
                "switchDPID": "00:00:00:00:00:00:00:04",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763762405
    },
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "4a:77:dc:12:86:50"
        ],
        "ipv4": [
            "10.0.0.3"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 3,
                "switchDPID": "00:00:00:00:00:00:00:05",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763762427
    },
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "de:42:94:b1:24:a7"
        ],
        "ipv4": [
            "10.0.0.2"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 4,
                "switchDPID": "00:00:00:00:00:00:00:04",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763762417
    },
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "02:ee:63:f6:65:ea"
        ],
        "ipv4": [
            "10.0.0.4"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 4,
                "switchDPID": "00:00:00:00:00:00:00:05",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763767429
    },
    {
        "entityClass": "DefaultEntityClass",
        "mac": [
            "42:a4:fd:b6:62:b9"
        ],
        "ipv4": [
            "10.0.0.5"
        ],
        "vlan": [],
        "attachmentPoint": [
            {
                "port": 2,
                "switchDPID": "00:00:00:00:00:00:00:06",
                "errorStatus": null
            }
        ],
        "lastSeen": 1363763792493
    }
]


P.S: Here is a more complete example of mininet for you to refer to: http://blog.sflow.com/2013/06/flow-collisions.html
It also contains the setting of sFlow. Awesome!

Wednesday, March 13, 2013

[astyle] A tool to format your source code

This is a good tool to consist your code style in some kind of programming languages, such as C, C++, C#, and Java.
http://astyle.sourceforge.net/astyle.html

Wednesday, February 27, 2013

[sFlow] Use sflowtool to parse sFlow datagram

In order to test and understand sFlow more in details, I prepare the following environment below. Switch 1 and 2 are emulated using Open vSwitch. In the previous sFlow article, there is a sFlow setting on Open vSwitch. Please check it out.

            192.168.12.201           10.3.207.244           192.168.12.202
            +------------+        +-----------------+       +------------+
            |  PC1       |        | sFlow Collector |       |  PC2       |
            |            |        |                 |       |            |
            |            |        |                 |       |            |
            +-----+------+        +---^--------^----+       +-----+------+
                  |                   |        |                  |
                  |                   |        |                  |
                  |                   ^ sFlow  ^                  |
                  +---------+         | Data   |       +----------+
                            |         ^        ^       |
                            |         |        |       |
                            |         ^        ^       |
                            |         |        |       |
                   +--------+---------++      ++-------++---------+
                   |    Switch 1       |      |   Switch 2        |
                   | 10.3.207.142      +------+ 10.3.207.143      |
                   +-------------------+      +-------------------+

sFlowtool is an open source toolkit for us to leverage the functionality of parsing sFlow datagram. In my environment, when I ping PC2 from PC1, then Switch 1 and 2 will send sFlow Counter and Flow Sample datagram to the sFlow collector. Now, I will use sFlowtool to parse  the information that it gets.

> ./sflowtool
Counter Sample:startDatagram =================================
datagramSourceIP 0.0.0.0
datagramSize 144
unixSecondsUTC 1359534209
datagramVersion 5
agentSubId 0
agent 10.3.207.142
packetSequenceNo 403
sysUpTime 947000
samplesInPacket 1
startSample ----------------------
sampleType_tag 0:2
sampleType COUNTERSSAMPLE
sampleSequenceNo 95
sourceId 0:4
counterBlock_tag 0:1
ifIndex 4
networkType 6
ifSpeed 1000000000
ifDirection 1
ifStatus 3
ifInOctets 126361
ifInUcastPkts 1072
ifInMulticastPkts 0
ifInBroadcastPkts 4294967295
ifInDiscards 0
ifInErrors 0
ifInUnknownProtos 4294967295
ifOutOctets 137350
ifOutUcastPkts 1135
ifOutMulticastPkts 4294967295
ifOutBroadcastPkts 4294967295
ifOutDiscards 0
ifOutErrors 0
ifPromiscuousMode 0
endSample   ----------------------
endDatagram   =================================
startDatagram =================================
datagramSourceIP 0.0.0.0
datagramSize 144
unixSecondsUTC 1359534210
datagramVersion 5
agentSubId 0
agent 10.3.207.244
packetSequenceNo 404
sysUpTime 948000
samplesInPacket 1
startSample ----------------------
sampleType_tag 0:2
sampleType COUNTERSSAMPLE
sampleSequenceNo 95
sourceId 0:5
counterBlock_tag 0:1
ifIndex 5
networkType 6
ifSpeed 100000000
ifDirection 2
ifStatus 1
ifInOctets 0
ifInUcastPkts 0
ifInMulticastPkts 0
ifInBroadcastPkts 4294967295
ifInDiscards 0
ifInErrors 0
ifInUnknownProtos 4294967295
ifOutOctets 0
ifOutUcastPkts 0
ifOutMulticastPkts 4294967295
ifOutBroadcastPkts 4294967295
ifOutDiscards 0
ifOutErrors 0
ifPromiscuousMode 0
endSample   ----------------------
endDatagram   =================================

Flow Sample:startDatagram =================================
datagramSourceIP 10.3.207.244
datagramSize 216
unixSecondsUTC 1359597631
datagramVersion 5
agentSubId 0
agent 10.3.207.142
packetSequenceNo 941
sysUpTime 2174000
samplesInPacket 1
startSample ----------------------
sampleType_tag 0:1
sampleType FLOWSAMPLE
sampleSequenceNo 72
sourceId 0:4
meanSkipCount 64
samplePool 4010
dropEvents 0
inputPort 4
outputPort 3
flowBlock_tag 0:1001
extendedType SWITCH
in_vlan 0
in_priority 0
out_vlan 0
out_priority 0
flowBlock_tag 0:1
flowSampleType HEADER
headerProtocol 1
sampledPacketSize 102
strippedBytes 4
headerLen 98
headerBytes 00-AB-77-E3-4B-00-00-AB-71-13-2D-00-08-00-45-00-00-54-00-00-40-00-40-01-9F-C5-C0-A8-0C-CA-C0-A8-0C-C9-08-00-C4-0E-55-06-08-57-28-96-AD-FD-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
dstMAC 00ab77e34b00
srcMAC 00ab71132d00
IPSize 84
ip.tot_len 84
srcIP 192.168.12.202
dstIP 192.168.12.201
IPProtocol 1
IPTOS 0
IPTTL 64
ICMPType 8
ICMPCode 0
endSample   ----------------------
endDatagram   =================================

If you use this, then you will get another format of data:
> ./sflowtool -l
Counter Sample:
CNTR,10.3.207.142,3,6,1000000000,1,3,112616,955,1,4294967295,0,0,4294967295,123043,1012,4294967295,4294967295,0,0,0

Flow Sample:
FLOW,10.3.207.142,4,3,00ab71132d00,00ab77e34b00,0x0800,0,0,192.168.12.202,192.168.12.201,1,0x00,64,0,0,0x00,102,84,64


Monday, February 25, 2013

[C++ STL] Containers

We all know that using data structure well is very important in programming, because it affects the performance, data accuracy, maintenance no matter what kind of the program you write. In C language, we have to provide our data structure by ourselves or by searching for related library and grab it to use. But, if possible ( I mean if your program is able to use g++ compiler and the environment ), you can consider to just use Containers (C++ STL) in your program. It is useful and powerful. For more information, here is the official web site : http://www.cplusplus.com/reference/stl/

Container class templates

Sequence containers:

Container adaptors:

Associative containers:



Friday, January 25, 2013

[Library] The useful libraries for C

Needless to say, C is powerful. But, if you use Java or Python, you will reconize that C lakes a bunch of Libraries(APIs) or a framework for C programmer to do job quicker. Sometimes you have to look for some C libraries to meet your requirement, and then you can avoid from carving the same wheels again and again. This document will record the useful libraries for C language and I will continue to add the new one on it. For those who are a great C programmer, if you know a good library for C, please also let me know that. Thanks in advance.

OGDF - Open Graph Drawing Framework
http://www.ogdf.net/ogdf.php

Curl Lib
the multiprotocol file transfer library
http://curl.haxx.se/libcurl/

mongoose
The lightweight web server in C
http://code.google.com/p/mongoose/

SimCList – A C library for Lists
http://mij.oltrelinux.com/devel/simclist/

JSON Library
http://www.digip.org/jansson/

The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts
http://libevent.org/

libev - a high performance full-featured event loop written in C
It is similar with libevent, but is more efficiently
http://doc.dvgu.ru/devel/ev.html

The Better String Library
http://bstring.sourceforge.net/

Unit Test Frameworks
https://github.com/imb/fctx

Exception Handling for C
http://code.google.com/p/exceptions4c/

SSL Library
https://polarssl.org/ssl-library

libssh2 is a client-side C library implementing the SSH2 protocol
http://www.libssh2.org/

MD5
http://256.com/sources/md5/

CIDR Library ( Need to verify )
http://www.over-yonder.net/~fullermd/projects/libcidr 

NETCONF library in C
https://code.google.com/p/libnetconf/

SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
http://www.sqlite.org/