Sunday, April 29, 2012

[How to] Install Qt SDK on Ubuntu

1. Download Qt SDK
wget http://www.developer.nokia.com/dp?uri=http%3A%2F%2Fsw.nokia.com%2Fid%2F14b2039c-0e1f-4774-a4f2-9aa60b6d5313%2FQt_SDK_Lin64_offlinehttp://www.developer.nokia.com/dp?uri=http%3A%2F%2Fsw.nokia.com%2Fid%2F14b2039c-0e1f-4774-a4f2-9aa60b6d5313%2FQt_SDK_Lin64_offline


2. Change the file's mode for execution and run it.
> chmod u+x Qt_SDK_Lin64_offline_v1_2_en.run ( e.g )
> ./Qt_SDK_Lin64_offline_v1_2_en.run ( 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:
http://www.boost.org/doc/libs/1_38_0/doc/html/boost_asio/examples.html

Tuesday, April 24, 2012

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:
http://gna.org/projects/qanava

git repository
http://repo.or.cz/w/qanava.git

Document 
Qanava Manual v0.1.0

Monday, April 23, 2012

[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
      0x0020:  6572 6963 2078 3836 5f36 34
    System Capabilities TLV (7), length 4
      System  Capabilities [Bridge, WLAN AP, Router] (0x001c)
      Enabled Capabilities [Bridge, Router] (0x0014)
      0x0000:  001c 0014
    Management Address TLV (8), length 12
      Management Address length 5, AFI IPv4 (1): Ubuntu-Devstack.local
      Interface Index Interface Numbering (2): 5
      0x0000:  0501 c0a8 7a01 0200 0000 0500
    Port Description TLV (4), length 4: eth4
      0x0000:  6574 6834
    Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
      Link aggregation Subtype (3)
        aggregation status [supported], aggregation port ID 0
      0x0000:  0012 0f03 0100 0000 00
    Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
      MAC/PHY configuration/status Subtype (1)
        autonegotiation [supported, enabled] (0x03)
        PMD autoneg capability [10BASE-T hdx, 10BASE-T fdx, 100BASE-TX hdx, 100BASE-TX fdx, 1000BASE-T fdx] (0x6c01)
        MAU type 1000BASET fdx (0x001e)
      0x0000:  0012 0f01 036c 0100 1e
    Organization specific TLV (127), length 6: OUI IEEE 802.3 Private (0x00120f)
      Max frame size Subtype (4)
        MTU size 0
      0x0000:  0012 0f04 0000
    End TLV (0), length 0



The following is the argument list for reference:
 -a    將網絡地址和廣播地址轉變成名字
 -d    將匹配信息包的代碼以人們能夠理解的彙編格式給出
 -dd    將匹配信息包的代碼以c語言程序段的格式給出
 -ddd   將匹配信息包的代碼以十進制的形式給出
 -e    在輸出行打印出數據鏈路層的頭部信息
 -f    將外部的Internet地址以數字的形式打印出來
 -l    使標準輸出變為緩衝行形式( line buffered mode )
 -n    不把網絡地址轉換成名字
 -t    在輸出的每一行不打印時間戳
 -v    輸出一個稍微詳細的信息,例如在ip包中可以包括ttl和服務類型的信息
 -vv    輸出詳細的報文信息
 -c    在收到指定的包的數目後,tcpdump就會停止
 -F    從指定的文件中讀取表達式,忽略其它的表達式
 -i    指定監聽的網絡接口
 -r    從指定的文件中讀取包(這些包一般通過-w選項產生)
 -w    直接將包寫入文件中,並不分析和打印出來
 -T    將監聽到的包直接解釋為指定的類型的報文,常見的類型有rpc (遠程過程調用)和snmp(簡單網絡管理協議;)

Wednesday, April 18, 2012

[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.

http://www.zeromq.org/

    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.
http://www.coastrd.com/zeromq-messaging


[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('YourPythonFile.py')"
  • Compile one folder
         > python -c "import compileall; compileall.compile_dir('YourFolder/', force=True)"

Or, you can put the compiling action in source code

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

Tuesday, April 17, 2012

[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-3f3f09797d3f | 0a76a701-ea3b-40d8-a56d-fc26a8db69c2 | ACTIVE | DOWN      |
| fdc3836d-c884-4aeb-b5b2-e354745a2de4 | 5b2c8537-26df-4fdc-9e38-3f3f09797d3f | gw-5b2c8537-26                       | ACTIVE | DOWN      |
| d612ccc3-81cd-489c-8cf6-3e37966cebcb | 5b2c8537-26df-4fdc-9e38-3f3f09797d3f | b91861ff-f90b-435d-b9c2-65eb76f0300d | ACTIVE | DOWN      |
+--------------------------------------+--------------------------------------+--------------------------------------+--------+-----------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM ovs_quantum.vlan_bindings v LIMIT 0,1000;
+---------+--------------------------------------+
| vlan_id | network_id                           |
+---------+--------------------------------------+
|       2 | 5b2c8537-26df-4fdc-9e38-3f3f09797d3f |
+---------+--------------------------------------+
1 row in set (0.00 sec)