Monday, April 16, 2012

[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:
http://www.gns3.net/gns3-virtualbox-edition/


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


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

Saturday, April 14, 2012

[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 = 192.168.0.2/32, nw_dst = 192.168.0.1/32, 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 = 192.168.0.1/32, nw_dst = 192.168.0.2/32, tp_src = 1, tp_dst = 1], actions = [output: port=1 max_len=65535]

4. So, we can see all the flows here.

Wednesday, April 11, 2012

[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 \
             other-config:max-rate=50000000
  • Qos can have more than 1 queue

Tuesday, April 10, 2012

[Tutorial] Trema Tutorial

http://www.fp7-ofelia.eu/assets/Uploads/201203xx-TremaTutorial.pdf

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

1. Show the bridge info
> sudo ovs-vsctl show
result:
2909bfce-536e-4184-a5bb-507f0553abee
    Bridge "br0"
        Controller "tcp:10.6.186.244"
        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
result:
{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}

Monday, April 9, 2012

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


import sys class ApiCall(object): """A Decorator to add support for format and tenant overriding""" def __init__(self, function): self.function = function def __get__(self, instance, owner): def with_params(*args, **kwargs): """ Temporarily sets the format and tenant for this request """ (format, tenant) = (instance.format, instance.tenant) if 'format' in kwargs: instance.format = kwargs['format'] if 'tenant' in kwargs: instance.tenant = kwargs['tenant'] ret = self.function(instance, *args) (instance.format, instance.tenant) = (format, tenant) return ret return with_params class Client(object): def __init__(self, tenant=None, format="xml"): self.tenant = tenant self.format = format @ApiCall def list_ports(self, network): """ Fetches a list of ports on a given network """ return network def main(): client = Client(tenant="AAA",format="xml") client.list_ports('my network') sys.exit(0) if __name__ == "__main__": main()