Wednesday, September 5, 2012

[Virtual Network] Midokura’s MidoNet

Recently I saw the article about Midokura MidoNet as follows:
http://blog.ioshints.info/2012/08/midokuras-midonet-layer-2-4-virtual.html
It is a layer 2-4 virtual network solution and catches my attention and lets me want to know more about.

Meanwhile, Midokura also provide Quantum Plugin for MidoNet to integrate into OpenStack.
https://github.com/midokura/midonet-openstack

On its web site, it provides a lot of features in virtual network solution and is pretty amazing. Due to MidoNet is not an open source project, so we are not able to see how it exactly achieves all of these things.
http://www.midokura.com/midonet/openstack/

MidoNet Key Features

  • Fully virtualized Layer 2 through 7 networking
  • VLAN-less VLANs – Virtual L2 Distributed Level Isolation and Switching with virtually no limitations
  • Fully Distributed Architecture with no single points of failure
  • Virtual L3 Distributed Routing
  • Distributed Load Balancing and Firewall Services
  • NAT
  • VPN
  • Access Control Lists (ACLs)
  • Restful API
  • Web Based Management Control Panel
  • Monitoring and Metering of Networking Services
  • Live Migration
  • Rate Limiting
  • Virtual Tap (Port Monitoring and Mirroring)




[OpenStack] Existing High Availability Options for Networking

 Existing High Availability Options for Networking

    OpenStack offical web site has document to explain the existing HA options for networking. I think most of important item is the option 1: multi-host networking mode. This mode avoids from single point of failure when Nova-Network component is down and also eliminate the potential network bottleneck in single-host networking mode.

For more in details, please see the this:
http://docs.openstack.org/trunk/openstack-compute/admin/content/existing-ha-networking-options.html


Wednesday, August 29, 2012

[Ubuntu] How to build local apt repositories



Summary:
  1. Edit your sources.list file 
  2. Copy your debian packages to the folder where is the packages repository directory  (*.deb folder) 
  3. Change into the packages repository directory  (cd ~/repository) 
  4. Generate a Packages.gz file  (sudo dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz) 
  5. Install the build-essential package  (sudo apt-get install build-essentiall
  6.  Update apt-get server packages list  (sudo apt-get update)


Monday, August 27, 2012

[SDN] HP's SDN solution

http://www.infoworld.com/d/networking/hp-aims-three-part-effort-network-virtualization-200048?source=IFWNLE_nlt_virtualization_2012-08-16

Summary:
HP provides 3 tools (softwares) to deal with network virtualization using SDN
  • EVI (Ethernet Virtual Interconnect)
    • EVI creates a tunnel through the Layer 3 network by encapsulating the packets traveling between the data centers. Rival Cisco already has software that can do this, called OTV (Overlay Transport Virtualization), but it charges extra for that software.
  • MDC (Multitenant Device Context)
    • It allows for segregating the resources of multiple tenants in a virtualized environment without buying separate switches. This secures the data and applications of one department or cloud service customer from other tenants.
  • VSA
    • StoreVirtual VSA, for virtualizing storage management. The software is based on VSA (virtual storage appliance) technology from LeftHand Networks, which HP acquired in 2008.

Tuesday, August 21, 2012

[Trema] The real case to test flow-based ECMP Routing Switch App


The following picture is a topology that used in testing my ECMP Routing Switch App.

After host3 send packets to host1, the app starts making path process and the related log as below. You will see this app picks up 2 paths ( "0xe5->0xe3->0xe4"  and  "0xe5->0xe2->0xe4" ) and choose one of them to setup flow entries.

[pickup_next_candidate] Find a candidate = 0xe5
[update_distance] node = 0xe3, distance = 1
[update_distance] node = 0xe2, distance = 1
[pickup_next_candidate] Find a candidate = 0xe3
[update_distance] node = 0xe1, distance = 2
[update_distance] node = 0xe4, distance = 2
[update_distance] node = 0xe2, distance = 1
[pickup_next_candidate] Find a candidate = 0xe2
[update_distance] node = 0xe1, distance = 2
[update_distance] node = 0xe4, distance = 2
[pickup_next_candidate] Find a candidate = 0xe1
[pickup_next_candidate] Find a candidate = 0xe4
[build_hop_list] build a hop = 0xe4
[build_hop_list] build a hop = 0xe3
[build_hop_list] build a hop = 0xe5
[resolve_path] find a hop list 0
[pickup_next_candidate] Find a candidate = 0xe5
[update_distance] node = 0xe2, distance = 1
[pickup_next_candidate] Find a candidate = 0xe2
[update_distance] node = 0xe1, distance = 2
[update_distance] node = 0xe4, distance = 2
[pickup_next_candidate] Find a candidate = 0xe1
[pickup_next_candidate] Find a candidate = 0xe4
[build_hop_list] build a hop = 0xe4
[build_hop_list] build a hop = 0xe2
[build_hop_list] build a hop = 0xe5
[resolve_path] find a hop list 1
[resolve_path] has 2 paths, pick up the key = 0 from hash_value = 2169503748

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



Monday, June 18, 2012

[OpenFlow] Wildcard Explanation

This article is about flow wildcard for match field. Basically, we can get understood most of them at a glance. But, for  NW_SRC_MASK and NW_DST_MASK they need to do more a little bit math. I only give an example with NW_SRC_MASK because NW_DST_MASK is similar case. Please refer to the following picture:

The position of NW_SRC_MASK is from 8 to 13. If we want to setup a IP subnet mask as 192.168.1.0/24, we should give the value: 001000 (8 bits are wirdcarded). Another example, for instance, 192.168.0.0/16 (16 bits are wirdcarded), the value should be 010000.




/* Flow wildcards. */ enum ofp_flow_wildcards { OFPFW_IN_PORT = 1 << 0, /* Switch input port. */ OFPFW_DL_VLAN = 1 << 1, /* VLAN id. */ OFPFW_DL_SRC = 1 << 2, /* Ethernet source address. */ OFPFW_DL_DST = 1 << 3, /* Ethernet destination address. */ OFPFW_DL_TYPE = 1 << 4, /* Ethernet frame type. */ OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */ OFPFW_TP_SRC = 1 << 6, /* TCP/UDP source port. */ OFPFW_TP_DST = 1 << 7, /* TCP/UDP destination port. */ /* IP source address wildcard bit count. 0 is exact match, 1 ignores the * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard * the entire field. This is the *opposite* of the usual convention where * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */ OFPFW_NW_SRC_SHIFT = 8, OFPFW_NW_SRC_BITS = 6, OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT, OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT, /* IP destination address wildcard bit count. Same format as source. */ OFPFW_NW_DST_SHIFT = 14, OFPFW_NW_DST_BITS = 6, OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT, OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT, OFPFW_DL_VLAN_PCP = 1 << 20, /* VLAN priority. */ OFPFW_NW_TOS = 1 << 21, /* IP ToS (DSCP field, 6 bits). */ /* Wildcard all fields. */ OFPFW_ALL = ((1 << 22) - 1) };


Friday, June 15, 2012

[Summary] Data Center Network Issues


http://muratbuffalo.blogspot.tw/2010/11/vl2-scalable-and-flexible-data-center.html
The key points from my point of view in this article for Data Center :

Agility:
  • Without agility, each service must pre-allocate enough servers to meet difficult to predict demand spikes, or risk failure at the brink of success. With agility, the data center operator can meet the fluctuating demands of individual services from a large shared server pool, resulting in higher server utilization and lower costs. In order to achieve agility, assigning servers to a service should be independent of network topology.
 Downtime Issue:
  • Still, downtimes can be significant, and with no obvious way to eliminate all failures from the top of the hierarchy, this paper's approach is to broaden (fatten) the topmost levels of the network so that the impact of failures is muted and performance degrades gracefully.
Data center traffic:
  • The paper proposes to use valiant load balancing (vlb) to randomize end-to-end communication paths to cope with volatility and achieve load balancing. In this scheme, the ToR switch randomly chooses an intermediate switch (among many available options) on a per flow basis.
This paper provide an approach of Clos topology.




Wednesday, June 13, 2012

[Demo] OpenFlow GUI demo

Here is a video about OpenFlow GUI demo on a simple topology.
I modified the flow animation so that the flow animation is different from the original one.
Check it out.
http://youtu.be/8r93qgt7VVE

Monday, June 11, 2012

[Tutorial] An example of using juju to deploy cloud services

Before you get started with juju, please refer to the official documens
https://juju.ubuntu.com/docs/getting-started.html
https://juju.ubuntu.com/docs/user-tutorial.html

P.S: When you lunch an instance, be careful about the instance type. Except t1.micro, others will charge you money~~
I strongly suggest to add parameter after juju bootstrap and deploy command as follows:
--constraints "instance-type=m1.micro"
or execute this command:
> juju set-constraints instance-type=t1.micro
For more info about this, please check out this document:
https://juju.ubuntu.com/docs/constraints.html

My environment is using EC2.
> vi .juju/environment.yaml
environments:
  sample:
    type: ec2
    access-key: << your access key >>
    secret-key: << your secret key >>
    control-bucket: juju-0f3b4bce2d944893a74967016c98b903
    admin-secret: 0d748130374946babe1f2531d77620d0
    default-series: precise
    ssl-hostname-verification: true

When you prepare your .juju/environment.yaml ready, you are able to do the following steps to try juju:
> juju bootstrap
> juju deploy wordpress
> juju deploy mysql
> juju add-relation mysql wordpress
> juju expose wordpress

After executing above commands, we can use "juju status" to see what we have now on Amazon EC2:
> juju status
2012-06-11 09:00:26,558 INFO Connecting to environment...
2012-06-11 09:00:43,657 INFO Connected to environment.
machines:
  0:
    agent-state: running
    dns-name: ec2-23-22-111-234.compute-1.amazonaws.com
    instance-id: i-30fa4a49
    instance-state: running
  1:
    agent-state: running
    dns-name: ec2-50-17-117-72.compute-1.amazonaws.com
    instance-id: i-b055eac9
    instance-state: running
  2:
    agent-state: running
    dns-name: ec2-23-22-205-88.compute-1.amazonaws.com
    instance-id: i-de52eda7
    instance-state: running
services:
  mysql:
    charm: cs:precise/mysql-2
    relations:
      db:
      - wordpress
    units:
      mysql/0:
        agent-state: started
        machine: 2
        public-address: ec2-23-22-205-88.compute-1.amazonaws.com
  wordpress:
    charm: cs:precise/wordpress-1
    exposed: true
    relations:
      db:
      - mysql
    units:
      wordpress/0:
        agent-state: started
        machine: 1
        open-ports:
        - 80/tcp
        public-address: ec2-50-17-117-72.compute-1.amazonaws.com
2012-06-11 09:01:18,809 INFO 'status' command finished successfully

From now on, we can check EC2 dashboard and see what instances are there ( it will be the same as the result of "juju status")

Because we do "expose" for wordpress, we have a public address ( ec2-50-17-117-72.compute-1.amazonaws.com) and it looks like as below:

Once you are done with an juju deployment, you need to terminate all running instances in order to stop paying for them.
> juju destroy-environment
WARNING: this command will destroy the 'sample' environment (type: ec2).
This includes all machines, services, data, and other resources. Continue [y/N]y
2012-06-11 09:53:03,181 INFO Destroying environment 'sample' (type: ec2)...
2012-06-11 09:53:10,018 INFO Waiting on 3 EC2 instances to transition to terminated state, this may take a while
2012-06-11 09:53:53,257 INFO 'destroy_environment' command finished successfully





Tuesday, June 5, 2012

[How to] do trouble shooting with LLDP setting on Switch

Let me assume if there is a simple topology here
                              +------------------+
                      Switch  |  172.17.255.254  |
                              +-----+------------+
              +-----------------+   |
      Switch  |   172.17.4.1    |<--+
              +----------+------+
 +--------------+        |
 | Your Server: |        |
 | 172.17.2.200 |<-------+
 +--------------+

A. Make sure Switch and Switch could ping each other
  1. telnet 172.17.255.254
  2. ping 172.17.4.1
B. Make sure that every port should have "management address" checked.

C. Use snmpwalk to check 172.17.255.254 has remote ip address of 172.17.4.1
  • exp: snmpwalk -c public -v2c 172.17.255.254 1.0.8802.1.1.2.1.4.2.1.3
  • if we cannot see the result as follows, it means that the LLDP configuration setting on Switch 172.17.255.254 is wrong. 
         Result: iso.0.8802.1.1.2.1.4.2.1.3.0.4.55.1.4.172.17.4.1 = INTEGER: 2

D. Use snmpwalk to check 172.17.4.1if it has remote ip address of 172.17.255.254
  • exp: snmpwalk -c public -v2c 172.17.4.1 1.0.8802.1.1.2.1.4.2.1.3
  •  if we cannot see the result as follows, it means that the LLDP configuration setting on Switch 172.17.4.1 is wrong.

Saturday, May 26, 2012

[Qt] memory management and implicit sharing

There are some points that we have to know when we program using Qt:

  • The ownership of all child QObjects is transferred to the parent.
    • Automatic deletion by the parent
    • Allocated from the heap (using new)
    • manual deletion is not necessary but it won't cause any problems.
  • All QObjects without a parent must be deleted manually.
  • Pay attention to ownership and responsibilities. Qt does not provide a garbage collection.
Only if you have Classes with QObjects, then child items will be deleted if the parent is deleted:

QObject *parent = new QObject; 
QWidget *child1 = new QWidget(parent); QPushButton *child2 = new QPushButton(parent); delete parent; // child1 and child2 will be deleted automatically!

 



Implicit sharing (IS)
The following example is about how implicit sharing works when test() returns QList object (on stack). This memory address of "a" is shared to "result" and "a" is not destroyed when method:test() is out of scope.
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QList> #include <QtGui> QList<QString> MainWindow::test() { QList<QString> a; // on stack QList<QString> b = QList<QString>(); // on stack QList<QString> *c = new QList<QString>(); // on heap for (int i = 0; i < 10; i++) { /* if we append a reference of QString, it will consume the memory of the QList Object based on the size of string */ a.append("a_helo:"); a.append(QString::number(i)); b.append("b_helo:"); b.append(QString::number(i)); c->append("c_helo:"); c->append(QString::number(i)); } qDebug() << a << " addres:" << &a; qDebug() << b << " addres:" << &b; qDebug() << *c << " addres:" << c; //delete &b; // we cannot manually free the memory of b or c on stack delete c; // OK return a; // Implicit Sharing } MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); /* The memory address of result is same with a object in test() because of implicit sharing */ QList<QString> result = test(); QList<QString> result2; qDebug() << result << " addres:" << &result; qDebug() << result2 << " addres:" << &result2; } MainWindow::~MainWindow() { delete ui; }

Monday, May 14, 2012

[Explanation][Trema] The message mechanism in flow_manager app

I give 2 pictures to illustrate the message mechanism in flow_manager app.

1. Request/Reply message using send_request_message() and send_reply_message()


2. (Received) Message using send_message()

Thursday, May 10, 2012

[Open vSwitch] Simply test ovs-ofctl command on GNS3 simulation network


This article is to test ovs-ofctl command on GNS3 simulation network. PC1 and PC2 are  virtual machine on Qemu. U_OVS is emulated with Open vSwitch and an OpenFlow Controller is also on it. Please see the following picture:

1. For how to build the following GNS3 environment, please refer to the URL:
http://brezular.wordpress.com/2011/06/25/part2-openvswich-vlans-trunks-l3-vlan-interface-intervlan-routing-configuration-and-testing/
2. Run > sudo ovs-ofctl show br0

OFPT_FEATURES_REPLY (xid=0x1): ver:0x1, dpid:000008002725cd53
n_tables:1, n_buffers:256
features: capabilities:0x87, actions:0xfff
 1(eth1): addr:08:00:27:95:ef:0b
     config:     0
     state:      LINK_DOWN
     current:    COPPER AUTO_NEG
     advertised: 10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
     supported:  10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
 2(eth3): addr:08:00:27:25:cd:53
     config:     0
     state:      0
     current:    1GB-FD COPPER AUTO_NEG
     advertised: 10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
     supported:  10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
 3(eth2): addr:08:00:27:c3:5f:90
     config:     0
     state:      0
     current:    1GB-FD COPPER AUTO_NEG
     advertised: 10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
     supported:  10MB-HD 10MB-FD 100MB-HD 100MB-FD 1GB-FD COPPER AUTO_NEG
 LOCAL(br0): addr:08:00:27:25:cd:53
     config:     PORT_DOWN
     state:      LINK_DOWN
OFPT_GET_CONFIG_REPLY (xid=0x3): frags=normal miss_send_len=0

3. After PC1 and PC2 ping each other, run > sudo ovs-ofctl dump-flows br0
NXST_FLOW reply (xid=0x4):
 cookie=0x0, duration=17.125s, table=0, n_packets=14, n_bytes=1372, idle_timeout=5,priority=65535,icmp,in_port=2,vlan_tci=0x0000,dl_src=00:aa:00:3c:24:00,dl_dst=00:aa:00:4d:1d:00,nw_src=192.168.1.2,nw_dst=192.168.1.1,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:3
 cookie=0x0, duration=18.13s, table=0, n_packets=15, n_bytes=1470, idle_timeout=5,priority=65535,icmp,in_port=3,vlan_tci=0x0000,dl_src=00:aa:00:4d:1d:00,dl_dst=00:aa:00:3c:24:00,nw_src=192.168.1.1,nw_dst=192.168.1.2,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:2


p.s:
the script of PC1 configuration
Login is tc without password set.
Assign IP address 192.168.1.1/24 to eth0 and make it persistent after next reboot of Microcore
sudo hostname PC1
sudo ifconfig eth0 192.168.1.1 netmask 255.255.255.0
echo "hostname PC1" >> /opt/bootlocal.sh
echo "ifconfig eth0 192.168.1.1 netmask 255.255.255.0" >> /opt/bootlocal.sh
/usr/bin/filetool.sh -b

Monday, May 7, 2012

[Explanation][Trema] The Register Event in Routing Switch App

If we want to understand how Routing Switch App works in Trema, we have to know the event register first. Here is a simple explanation about the register event in Routing Switch App, which is related Topology Ap.

Wednesday, May 2, 2012

[How to] Find a key word or Replace it with other string on Linux

Please refer to these examples:

Find the key word "ProcessType=6" in text files under current path (included sub folder)
> find ./ -name "*.txt" -exec grep -n -H "ProcessType=6" {} \;

Replace the key word "python2.4" with "python2.6" in python files under /opt/stack (included sub folder)
> find /opt/stack -name "*.py" -exec sed -i 's/python2.4/python2.6/' '{}' \;

Based on the script above, you will be able to find or replace a key word quickly and efficiently.

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