Showing posts with label Open vSwitch. Show all posts
Showing posts with label Open vSwitch. Show all posts

Sunday, January 11, 2015

[Open vSwitch] The Receiving Packet Process in OVS

In my previous article: The function calls about the command: "ovs-vsctl add-port, it mentions a hook point: rx_handler ==> netdev_frame_hook(). This function will be called when the packet is received. So the following diagram is for the function call about receiving packet process in OVS for the reference.




[Open vSwitch] The function calls about the command: "ovs-vsctl add-port"

  Well...it has been a busy month for me so that I don't have too much extra time do something interesting. But, previously I studied a little bit about the source code of Open vSwitcch and drawed some diagrams about its functionality. Here is the one example for the function calls about the command: "ovs-vsctl add-port". Basically the function call is from user space to kernel with Netlink. It needs a lot of time to explain them. So I only paste the diagram for the reference.




Tuesday, January 7, 2014

[Open vSwitch] The basic introduction of Open vSwitch

I post a slide to give a basic introduction of Open vSwitch. For the more in details, please check out the SlideShare URL as follows:
http://www.slideshare.net/teyenliu/the-basic-introduction-of-open-vswitch


Some Useful example of the OVS commands:
sudo ovs-vsctl show
sudo ovs-vsctl add-br mybridge
sudo ovs-vsctl del-br mybridge
sudo ovs-vsctl add-port mybridge port-name
sudo ovs-vsctl del-port mybridge port-name
sudo ovs-vsctl list Bridge/Port/Interface/...
sudo ovs-appctl fdb/show mybridge
sudo ovs-ofctl show mybridge
sudo ovs-ofctl dump-flows mybridge
sudo ovs-ofctl add-flow mybridge dl_src=02:a2:a2:a2:a2:a2,dl_dst=02:b2:b2:b2:b2:b2,in_port=2,dl_type=0x0800,nw_src=10.0.0.1,nw_dst=10.0.0.2,actions=output:6
sudo ovs-ofctl del-flows mybridge dl_src=02:a2:a2:a2:a2:a2,dl_dst=02:b2:b2:b2:b2:b2,in_port=2,dl_type=0x0800,nw_src=10.0.0.1,nw_dst=10.0.0.2
sudo ovs-ofctl add-flow dp0 in_port=2,actions=output:6
# This will delete all the flow entries in the flow table
sudo ovs-ofctl del-flows mybridge

Friday, January 3, 2014

[GNS3] All the related URLs with GNS3 and Open vSwitch

To play with Openvswitch in GNS3, here is Openvswitch 1.2.2 installed on Microcore 4.0 Linux as Qemu image.
http://brezular.com/2013/09/17/linux-core-qemu-and-virtualbox-appliances-download/

Here are the installation steps.
http://brezular.com/2011/09/03/part1-openvswich-creating-and-submitting-openvswitch-extension-to-microcore-upstream/

And GNS3 labs are available here.
http://brezular.com/2011/06/25/part2-openvswich-vlans-trunks-l3-vlan-interface-intervlan-routing-configuration-and-testing/

[KVM and OVS] Installing KVM and Open vSwitch on Ubuntu

These articles provides a very good explanation about how to install KVM and Open vSwitch on Ubuntu.
http://blog.scottlowe.org/2012/08/17/installing-kvm-and-open-vswitch-on-ubuntu/
http://networkstatic.net/installing-open-vswitch-with-kvm/

I summarize the scripts from the above URLs as follows:
  • ### Installing KVM and Open vSwitch on Ubuntu ###
sudo apt-get update && apt-get dist-upgrade
sudo apt-get install kvm qemu-kvm libvirt-bin virtinst virt-manager
sudo virsh net-destroy default
sudo virsh net-autostart --disable default
sudo aptitude purge ebtables
  • ### Open vSwitch on Ubuntu ###
sudo apt-get install openvswitch-controller openvswitch-brcompat \
sudo openvswitch-switch openvswitch-datapath-source

# Edit this: /etc/default/openvswitch-switch and change this line:
  #BRCOMPAT=no ==> #BRCOMPAT=yes 

# to build and install the necessary module
sudo module-assistant auto-install openvswitch-datapath
  • ### Add Open vSwitch bridge ###
sudo ovs-vsctl add-br br0
sudo ovs-vsctl add-port br0 eth0
sudo ovs-vsctl list port
  • ### Change your eth0 IP to your new br0 interface ###
sudo ifconfig eth0 0
sudo ifconfig br0 192.168.1.x netmask 255.255.255.0
sudo route add default gw 192.168.1.1 br0

These two scripts bring up the KVM Tap interfaces into your
bridge from the CLI.

$ cat /etc/ovs-ifup
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1

$ cat /etc/ovs-ifdown
#!/bin/sh
switch='br0'
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1

#Then make executable
chmod +x /etc/ovs-ifup /etc/ovs-ifdown
  • ### BOOT HD IMG ###
Here are some KVM examples. Starting with the CD is easiest. No build needed for testing.

sudo kvm -m 1024 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown &
OS Install

sudo kvm -m 512 -hda /media/Storage/imgs/centos.kvm -net nic,macaddr=00:11:22:CC:CC:C5 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /media/Storage/vm-images/CentOS-6.2-x86_64-LiveCD.iso &
CD Boot

sudo kvm -m 512 -net nic,macaddr=00:11:22:CC:CC:10 -net tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -cdrom /HD/Storage/vm-images/ubuntu-11.10-desktop-amd64.iso &
Make an Image from CD

sudo qemu-img create -f qcow2 /media/Storage/imgs/uCentOS-6.2.img 6G

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







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

[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 2, 2012

如何取得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.
http://d.hatena.ne.jp/kazuya_ax/20120420/1334928361
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