Testes de validação Openflow



Instalar dependencias:

sudo apt-get install doxygen doxypy scapy tcpdump pylint

-> mininet e switch OF (ovs)

wget http://ftp.br.debian.org/debian/pool/main/m/mininet/mininet_2.2.1-2_amd64.deb
sudo dpkg -i mininet_2.2.1-2_amd64.deb
sudo apt-get -f install
sudo /etc/init.d/openvswitch-switch stop
sudo update-rc.d openvswitch-switch remove


The default configuration assumes that an OpenFlow 1.0 switch is attempting to
connect to a controller on the machine running OFTest, port 6653. Additionally,
the interfaces veth1, veth3, veth5, and veth7 should be connected to the switch's
dataplane.

-> criação do cenário de teste

sudo ip link add type veth
sudo ip link add type veth
sudo ip link add type veth
sudo ip link add type veth
for i in `seq 0 7`; do sudo ifconfig veth$i up; done

-> clone do oftest

git clone git://github.com/floodlight/oftest

Para checar se o oftest está instalado corretamente:

sudo ./oft --help

Algumas opções interessantes:

 --of-version=XX    versão do openflow no switch que quer testar. Escolha entre '1.0', '1.1', '1.2', '1.3', '1.4', '1.5'
 --host=XXX      Endereço IP que irá aceitar as conexões (default 0.0.0.0)
 --port=XXX      porta que o controlador irá aceitar conexões (switch em teste está tentando conectar), por 
         padrão 6653 (em alguns switches o padrão é 6633)
 -i N@IFACE      Mapeamento do número da porta openflow (N) com a interface física no host que executa o oftest (IFACE). Exemplo: 1@eth1

-> teste simples:

- pox como switch  simples

# Install 'pxpcap' located under the POX folder
sudo apt-get install gcc g++ python-dev libpcap-dev
cd ~/pox/pox/lib/pxpcap/pxpcap_c
./build_linux
#This usually fails at the first run, not sure why, but passes on the second run. So, run this once more to install correctly.
./build_linux

# iniciar o switch basico com pox:
cd ~/pox
sudo ./pox.py --no-openflow datapaths.pcap_switch --address=127.0.0.1 --ports=veth0,veth2,veth4,veth6

# iniciar o oftest:
cd ~/oftest
sudo ./oft -i 1@veth1 -i 2@veth3 -i 3@veth5 -i 4@veth7 -H 127.0.0.1 --port 6633 --log-file="results.log"

- openvswitch

First, add a bridge to the OpenvSwitch. Run:

sudo ovs-­vsctl add­br ofsw0

Configure OpenvSwitch to listen to an OpenFlow controller:
ovs-vsctl set-controller ofsw0 tcp:127.0.0.1:6633

Next, add ports on OpenvSwith for interfaces veth0, veth2, veth4 and veth6
sudo ovs-vsctl add-port br0 veth0
sudo ovs-vsctl add-port br0 veth2
sudo ovs-vsctl add-port br0 veth4
sudo ovs-vsctl add-port br0 veth6


Next, find the ports assigned to veth0, veth2, veth4 and veth6 in the OpenvSwitch configuration. Run:
sudo ovs-vsctl list interface

You should see a “name” and an “ofport” for each of the virtual interfaces. Recall that these virtual interfaces work as pairs:  veth0-veth1, veth2-veth3, veth4-veth5 and veth6-veth7. To run oftest, use the -i option to map the port of veth0 in OpenvSwitch to the veth1 interface in OFTest, the port of veth2 to the veth3 interface and so on. For example, if the ofport of veth0 is 10, the ofport of veth2 is 11, the ofport of veth4 is 12 and the ofport of veth6 is 13, run oftest as follows:

cd ~/oftest
sudo ./oft -i 10@veth1 -i 11@veth3 -i 12@veth5 -i 13@veth7

- switch de referencia:

# Dependencies
sudo apt-get install autoconf make pkg-config
git clone git://openflowswitch.org/openflow.git of-ref-sw

# build switch
cd of-ref-sw/
./boot.sh
./configure; make

# Run the switch startup script:
cd ~/oftest
sudo ./run_switch.py --of_dir=../of-ref-sw

# run oftest in another tab
sudo ./oft basic -i 1@veth1 -i 2@veth3 -i 3@veth5 -i 4@veth7 -H 127.0.0.1 --port 6653 --log-file="results-of-ref-sw.log"

- switch of13 CPQD




Referencias:
 https://github.com/floodlight/oftest
 https://github.com/NetASM/PyDatapath
 https://haryachyy.wordpress.com/tag/oftest/
 mininet.org/walkthrough/

-- ItaloValcy - 19 Sep 2016