Running Faucet and Gauge on localhost

In my post about how to configure mininet-ryu-faucet-gauge-influxdb I used faucet in a remote machine (as virtual machine).
Now, I going to explain how to install and configure it in localhost.
First, download it form github:

git clone https://github.com/onfsdn/faucet.git
cd faucet
sudo python setup.py install

Probably, you will see this message:

build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No such file or directory

To avoid it, you need to install yaml:

apt-get install libyaml-dev

If you try to install it again you will see this message:

ERROR:root:Error parsing
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pbr/core.py", line 111, in pbr
    attrs = util.cfg_to_args(path, dist.script_args)
  File "/usr/local/lib/python2.7/dist-packages/pbr/util.py", line 248, in cfg_to_args
    kwargs = setup_cfg_to_setup_kwargs(config, script_args)
  File "/usr/local/lib/python2.7/dist-packages/pbr/util.py", line 382, in setup_cfg_to_setup_kwargs
    cmd = cls(dist)
  File "/home/nboettcher/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 127, in __init__
    _Command.__init__(self, dist)
  File "/usr/lib/python2.7/distutils/cmd.py", line 59, in __init__
    raise TypeError, "dist must be a Distribution instance"
TypeError: dist must be a Distribution instance
error: Setup script exited with error in setup command: Error parsing /tmp/easy_install-SnaOB8/traceback2-1.4.0/setup.cfg: TypeError: dist must be a Distribution instance

To skip it, install throught pip with either of these two commands

sudo pip install -e /path_to_faucet_folder/
or
sudo pip install ryu-faucet

Now, we procced to create the files in /etc/ryu/faucet with their respective content:

vim faucet.yaml

version: 2
dps:
    test-faucet-1:
        dp_id: 0x0000000000000001   # The id of the datapath to be controlled
        description: "Initial Test Faucet"    # Purely informational
        hardware: "Open_vSwitch"  # used to determine which valve implementation to use
        interfaces:
            1:
                native_vlan: 100
                name: "port1"   # name for this port, used for logging/monitoring
                description: "Port 1"    # informational
            2:
                native_vlan: 100
                name: "port2"
                description: "Port 2"
vlans:
    100:
        description: "Test vlan" # informational
        name: "test_vlan"  # used for logging/monitoring

        max_hosts: 3 # Maxium of 3 hosts can go on this VLAN

vim gauge.yaml

faucet_configs:
    - '/etc/ryu/faucet/faucet.yaml'
watchers:
    port_stats_poller:
        type: 'port_stats'
        dps: ['test-faucet-1']
        interval: 10
        db: 'influx'
dbs:
    influx:
        type: 'influx'
        influx_db: 'faucet'
        influx_host: '127.0.0.1'
        influx_port: 8086
        influx_user: ''
        influx_pwd: ''

        influx_timeout: 10

Now, run faucet as follows:

sudo ryu-manager --ofp-tcp-listen-port=6633 /path_to_faucet_folder/src/ryu_faucet/org/onfsdn/faucet/faucet.py ryu.app.simple_switch_13 ryu.app.ofctl_rest

Probably you will see this error:

IOError: [Errno 2] No such file or directory: '/var/log/ryu/faucet/faucet.log'

To fix it, you need create this folder:

cd /var/log/ 
sudo mkdir ryu             
cd ryu      
mkdir faucet  

Run it again and go to http://127.0.0.1:8083/ to create a faucet database in InfluxDB









Now, run gauge in other terminal:

sudo ryu-manager --verbose  --ofp-tcp-listen-port=6663 /path_to_faucet_folder/src/ryu_faucet/org/onfsdn/faucet/gauge.py

In other terminal, execute mininet and connect it to gauge with the second comand (you must put this command inside mininet with the ip with number. If you use localhost it doesn't works):

sudo mn --mac --controller remote,ip=127.0.0.1,port=6633
sh ovs-vsctl set-controller s1 tcp:127.0.0.1:6633 tcp:127.0.0.1:6663

Enjoy it!



Comments

Popular posts from this blog

Exception: Could not find a default OpenFlow controller in Mininet

How to fix Android when developer options are not available for this user

Webcam streaming throught VLC with YUY2 compatibility