sábado, 15 de junho de 2013

Dicas de instalação de controladores Openflow


ofsoftswitch13

sudo apt-get install libpcap-dev libxerces-c2-dev libpcre3-dev flex bison libboost-all-dev
wget http://www.nbee.org/download/nbeesrc-12-11-12.php
mv nbeesrc-12-11-12.php nbeesrc-12-11-12.zip
unzip nbeesrc-12-11-12.zip
http://www.nbee.org/doku.php - biblioteca para processamento de pacotes. Usada pelo OFsoftswitch

git clone git://github.com/CPqD/ofsoftswitch13
cd nbeesrc-2012-11-12/src
cmake .
make
sudo cp ../bin/libn*.so /usr/local/lib


git clone git://github.com/CPqD/nox13oflib
To start the controller, run the following commands:

sudo apt-get install libboost-filesystem-dev
sudo apt-get install libboost-test-dev
cd /home/openflow/nox13oflib/
./boot.sh
./configure
make
~/openflow13/nox13oflib/src

cd /home/openflow/nox13oflib/build/src
    ./nox_core -i ptcp:<port> [applications]

Wireshark
 cp openflow.so /usr/lib/wireshark/libwireshark1/plugins

 cd /home/openflow/ofdissector/test


 self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
        ' punix:/tmp/' + self.name + mac_str + ' --no-slicing ' +
        ' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
self.cmd( 'ofprotocol unix:/tmp/' + self.name +
        ' tcp:%s:%d' % ( controller.IP(), controller.port ) +
        ' --fail=closed ' + self.opts +
        ' 1> ' + ofplog + ' 2>' + ofplog + ' &' )


self.cmd( 'ofdatapath -i ' + ','.join( intfs ) +
        ' punix:/var/run/' + self.name + '.sock --no-slicing '
        +' 1> ' + ofdlog + ' 2> ' + ofdlog + ' &' )
self.cmd( 'ofprotocol unix:/var/run/' + self.name +
        '.sock tcp:%s:%d' % ( controller.IP(), controller.port )+
        ' 1> ' + ofplog + ' 2>' + ofplog + ' &' )
     
     
Mininet
sudo mn -c
 sudo mn --topo single,2 --mac --switch user --controller remote

sudo dpctl  unix:/tmp/s1 stats-flow table=0

sudo dpctl  unix:/tmp/s1 flow-mod table=0,cmd=add in_port=2 apply:output=1
sudo dpctl  unix:/tmp/s1 flow-mod table=0,cmd=add in_port=1 apply:output=2
Meter para 5 Mbps
sudo dpctl unix:/tmp/s1 meter-mod cmd=add,flags=1,meter=1 drop:rate=5000
sudo dpctl unix:/tmp/s1 flow-mod table=0,cmd=add in_port=1 meter:1 apply:output=2
altera para 10 Mbps
sudo dpctl unix:/tmp/s1 meter-mod cmd=mod,flags=1,meter=1 drop:rate=10000

NOX
~/nox13oflib/build/src$ ./nox_core -v -i ptcp:6633 switch

POX
openflow@openflowvm:~/pox$ ./pox.py log.level --DEBUG forwarding.l2_learning  openflow.keepalive
./pox.py samples.pretty_log forwarding.l2_learning  openflow.keepalive
POX com Spanning Tree
./pox.py forwarding.l2_learning openflow.discovery openflow.spanning_tree

 POX com servidor DHCP
 ./pox.py log.level --DEBUG forwarding.l2_learning misc.dhcpd --network=172.31.1.0/24 --ip=172.31.1.1 --first=10 --last=None --router=None --dns=4.2.2.1
sudo mn --topo single,2 --switch user --controller remote

./pox.py forwarding.l2_learning web.webcore
curl -i -X POST -d '{"method":"get_flow_stats","params":{"dpid":"00-00-00-00-01-11"},"id":0}' http://127.0.0.1:8000/OF/
curl -i -X POST -d '{"method":"get_switches", "id":0}' http://127.0.0.1:8000/OF/
curl -i -X POST -d '{"method":"get_switch_desc","params":{"dpid":"00-00-00-00-01-11"},"id":0}' http://127.0.0.1:8000/OF/
curl -i -X POST -d '{"method":"set_table","params":{"dpid":"00-00-00-00-01-11","flows":[{"actions":[{"type":"OFPAT_OUTPUT","port":"OFPP_ALL"}],"match":{}}]},"id":0}' http://127.0.0.1:8000/OF/
curl -i -X POST -d '{"method":"set_table","params":{"dpid":"00-00-00-00-01-12","flows":[{"actions":[{"type":"OFPAT_OUTPUT","port":"OFPP_ALL"}],"match":{}}]},"id":0}' http://127.0.0.1:8000/OF/

SNAC
apt-get install openssl libboost-test1.34.1 libboost-filesystem1.34.1 libboost-serialization1.34.1 libxerces-c28 python2.5 python-twisted python-simplejson python-mako python-openssl tmpreaper python-sphinx libldap2-dev



POXDESK
git clone https://github.com/noxrepo/pox
cd pox
git checkout betta
cd ext
git clone https://github.com/MurphyMc/poxdesk
cd poxdesk
wget http://downloads.sourceforge.net/qooxdoo/qooxdoo-2.0.2-sdk.zip
unzip qooxdoo-2.0.2-sdk.zip
mv qooxdoo-2.0.2-sdk qx
cd poxdesk
./generate.py
cd ../../..
basico ./pox.py samples.pretty_log web messenger messenger.log_service messenger.ajax_transport openflow.of_service poxdesk
completo   ./pox.py samples.pretty_log web messenger messenger.log_service messenger.ajax_transport openflow.of_service poxdesk openflow.discovery poxdesk.tinytopo poxdesk.terminal
http://192.168.56.102:8000/poxdesk/


OPENVSWITCH
sudo  ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --pidfile --detach


ROUTEFLOW
cd rftest
sudo ./create
sudo ./rftest1 --nox
sudo lxc-console -n b1     (sai com ctl-a-q)
ping 172.31.2.2
liga interface grafica cd rfweb/
python rfweb_server.py &
http://192.168.31.129:8080/index.html
entra na maquina virtual rfvm1  sudo lxc-console -n rfvm1

Config da interface de rede
/etc/network/interfaces
auto eth0
iface eth0 inet static
address 10.0.0.100
netmask 255.255.255.0
gateway 10.0.0.1

RYU
http://osrg.github.io/ryu/


FLOODLIGHT

sudo apt-get install build-essential default-jdk ant python-dev eclipse
git clone git://github.com/floodlight/floodlight.git
$ cd floodlight
$ git checkout fl-last-passed-build
$ ant



openflow@mininet-vm:~$ cd floodlight/
openflow@mininet-vm:~/floodlight$ java -jar target/floodlight.jar &

FLOODLIGHT
http://192.168.31.128:8080/wm/firewall/module/status/json
http://192.168.31.128:8080/ui/index.html

Criar um passa-tudo no switch
curl -d '{"switch": "00:00:00:00:00:00:01:11", "name":"normal-drain", "cookie":"0", "priority":"0", "active":"true", "actions":"output=normal"}' http://127.0.0.1:8080/wm/staticflowentrypusher/json
Limpar os flow (que não limpa !)
http://127.0.0.1:8080/wm/staticflowentrypusher/clear/00:00:00:00:00:00:01:11/json

openflow@mininet-vm:~/floodlight$ java -jar target/floodlight.jar

sudo mn --controller=remote
sudo mn --topo single,3 --mac --switch ovsk --controller remote
sudo mn -c


http://192.168.31.128:8080/wm/firewall/module/enable/json

Grafico
http://192.168.31.128:8080/ui/index.html
http://10.1.1.39:8080/ui/index.html

curl http://localhost:8080/wm/firewall/module/status/json
curl http://localhost:8080/wm/firewall/module/enable/json
curl -X POST -d '{"switchid": "00:00:00:00:00:00:00:11"}' http://localhost:8080/wm/firewall/rules/json


curl -X POST -d '{"src-ip": "10.0.0.3/32", "action":"DENY"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"src-ip": "10.0.0.3/32"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"dst-ip": "10.0.0.3/32"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"src-ip": "10.0.0.2/32"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"dst-ip": "10.0.0.2/32"}' http://localhost:8080/wm/firewall/rules/json

$ curl -d '{"switch": "00:00:5c:26:0a:5a:c8:b2", "name":"static-flow3", "cookie":"0", "priority":"32768", "dst-mac":"22:22:22:00:cc:10","active":"true", "actions":"output=7"}' http://192.168.1.208:8080/wm/staticflowentrypusher/json
curl -d '{"switch": "00:00:00:00:00:00:00:11", "name":"static-flow3", "cookie":"1", "priority":"32768","active":"true", "actions":"output=3"}' http://127.0.0.1:8080/wm/staticflowentrypusher/json
lista flows
curl http://127.0.0.1:8080/wm/staticflowentrypusher/list/00:00:00:00:00:00:00:11/json
$ curl http://192.168.1.208:8080/wm/staticflowentrypusher /list/00:00:5c:26:0a:5a:c8:b2/json
deleta flows
$ curl http://127.0.0.1:8080/wm/staticflowentrypusher/clear/00:00:00:00:00:00:00:11/json



POXDESK
./pox.py samples.pretty_log web messenger messenger.log_service messenger.ajax_transport openflow.of_service poxdesk openflow.discovery poxdesk.tinytopo &
./pox.py  forwarding.l2_learning web messenger messenger.log_service messenger.ajax_transport openflow.of_service poxdesk openflow.discovery poxdesk.tinytopo

OPENDAYLIGHT
cd ~/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight
./run.sh

service openvswitch-switch start
sudo mn --controller=remote,ip=192.168.56.102 --topo tree,3

http://192.168.56.102:8080/   admin admin

 curl -X POST -d '{"src-mac": "00:00:00:00:00:0a", "dst-mac": "00:00:00:00:00:0b"}' http://localhost:8000/rest/v1/model/link
 curl 'http://localhost:8080/rest/v1/model/link?src-switch=00:00:00:1c:73:10:3e:24'
 curl 'http://localhost:8080/rest/v1/model/link?src-switch=00:00:00:1c:73:10:3e:24' | python -mjson.tool

 OPENDAYLIGHT SDN CONTROLLER
 sudo apt-get remove openjdk-6-jre-lib openjdk-6-jre-headless
 sudo apt-get install unzip python-dev python-virtualenv \
      git openjdk-7-jdk ant build-essential

 git clone http://git.opendaylight.org/gerrit/p/net-virt-platform.git
 ./setup.sh
 make
 sudo pip install Django

 Running:

 make start-cassandra
 make start-sdncon
 make stop-sdncon reset-cassandra start-sdncon
 make start-sdnplatform
 ./cli.py
 http://192.168.56.102:8000/
  sudo mn --controller=remote,ip=192.168.56.102 --topo tree,3
 https://wiki.opendaylight.org/view/OpenDaylight_SDN_Controller_Platform_(OSCP):Installation


domingo, 9 de junho de 2013

The quest for the right openflow controller

Neste fim de semana testei mais um controlador Openflow, o OpenDayLight. Muito interessante, em java, possui já uma interface gráfica, com possibilidade de configuração de flows, com a garantia de continuidade da Linux Foundation. Quantos outros controladores foram descontinuados, porque uma grande empresa contratou os desenvolvedores. O Floodlight está estagnado (sem OF 1.3) desde que a Bigswitch cresceu.
Problemas: não suporta o OF 1.3 (ainda), presente em meus roteadores. Os testes mostrados no tutorial funcionam, mas um flow criado na mão, nada de funcionar, mesmo na mininet.
E que complicação, como tudo desenvolvido em java ! Com o Maven, invés do ant, usado no Floodlight (também em Java.)
A compilação e os testes estão bem documentados no Wiki  e funcionou bem no Ubuntu 12.04. Só precisei instalar o Java e o maven antes: sudo apt-get install build-essential default-jdk ant python-dev eclipse maven, e um export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386
Tentarei utilizar os testes de ACL do Floodlight, já que com a REST API isto é muito fácil, via curl.
Para  OF 1.3, somente o antigo NOX, versão CPQD. Quem sabe volte a testar o Ryu.