Skip to content

Commit

Permalink
Merging branches: HandoverMultichannel and Statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
luissequeira committed Sep 1, 2016
1 parent 9623efa commit 478ce75
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 107 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,35 @@ agent-click-file-gen.py

Click file generator for the agent. Configure and use this script
to generate the appropriate Odin agent click file.

This is an example of how to use the python command:

$ python agent-click-file-gen.py 4 50 14:CC:20:AC:72:91 192.168.1.129 2819 /sys/kernel/debug/ieee80211/phy0/ath9k/bssid_extra odin-unizar 192.168.1.7 0 11 12 25 0

where the parameters have the next meaning:

`4` number of the channel

`50` size of the queue

`14:CC:20:AC:72:91` MAC address of the AP

`192.168.1.129` IP address of the Controller

`2819` port used to connect with the Controller

`/sys/kernel/debug/ieee80211/phy0/ath9k/bssid_extra` directory of the debug file

`odin-unizar` SSID

`192.168.1.7` IP address of the AP

`0` No click debug info

`11` Debug level 1, with Demo appearance (1)

`12` 6 Mbps of TX rate

`25` the Tx power of the AP is 25 dBm (obtained with `$iw dev mon0 info`)

`0 no hidden mode: the AP will respond to all active scanning requests, even if they have no SSID name
26 changes: 17 additions & 9 deletions agent-click-file-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

import sys

if (len(sys.argv) != 11):
if (len(sys.argv) != 14):
print 'Usage:'
print ''
print '%s <AP_CHANNEL> <QUEUE_SIZE> <MAC_ADDR_AP> <ODIN_MASTER_IP> <ODIN_MASTER_PORT> <DEBUGFS_FILE> <SSIDAGENT> <ODIN_AGENT_IP> <DEBUG_CLICK> <DEBUG_ODIN>' %(sys.argv[0])
print '%s <AP_CHANNEL> <QUEUE_SIZE> <MAC_ADDR_AP> <ODIN_MASTER_IP> <ODIN_MASTER_PORT> <DEBUGFS_FILE> <SSIDAGENT> <ODIN_AGENT_IP> <DEBUG_CLICK> <DEBUG_ODIN> <TX_RATE> <TX_POWER> <HIDDEN>' %(sys.argv[0])
print ''
print 'AP_CHANNEL: it must be the same where mon0 of the AP is placed. To avoid problems at init time, it MUST be the same channel specified in the /etc/config/wireless file of the AP'
print 'QUEUE_SIZE: you can use the size 50'
Expand All @@ -28,10 +28,16 @@
print 'SSIDAGENT is the name of the SSID of this Odin agent'
print 'ODIN_AGENT_IP is the IP address of the AP where this script is running (the IP used for communicating with the controller)'
print 'DEBUG_CLICK: "0" no info displayed; "1" only basic info displayed; "2" all the info displayed'
print 'DEBUG_ODIN: "0" no info displayed; "1" only basic info displayed; "2" all the info displayed; "1x" demo info displayed'
print 'DEBUG_ODIN: "00" no info displayed; "01" only basic info displayed; "02" all the info displayed; "11" or "12": demo mode (more separators)'
print 'TX_RATE: it is an integer, and the rate is obtained by its product with 500kbps. e.g. if it is 108, this means 108*500kbps = 54Mbps'
print ' we are not able to send packets at different rates, so a single rate has to be specified'
print 'TX_POWER: (in dBm) as we are not able to modify it, you should add it here manually'
print ' for getting the value, use e.g. $# iw dev mon0 info'
print 'HIDDEN: If HIDDEN is 1, then the AP will only send responses to the active scans targetted to the SSID of Odin'
print ' If HIDDEN is 0, then the AP will also send responses to active scans with an empty SSID'
print ''
print 'Example:'
print '$ python %s X 50 XX:XX:XX:XX:XX:XX 192.168.1.X 2819 /sys/kernel/debug/ieee80211/phy0/ath9k/bssid_extra odin-unizar 192.168.1.Y L M > agent.click' %(sys.argv[0])
print '$ python %s X 50 XX:XX:XX:XX:XX:XX 192.168.1.X 2819 /sys/kernel/debug/ieee80211/phy0/ath9k/bssid_extra odin-unizar 192.168.1.Y L MM N P 0 > agent.click' %(sys.argv[0])
print ''
print 'and then run the .click file you have generated'
print 'click$ ./bin/click agent.click'
Expand All @@ -49,13 +55,15 @@
AP_UNIQUE_IP = sys.argv[8] # IP address of the wlan0 interface of the router where Click runs (in monitor mode). It seems it does not matter.
DEBUG_CLICK = int(sys.argv[9])
DEBUG_ODIN = int(sys.argv[10])
TX_RATE = int(sys.argv[11])
TX_POWER = int(sys.argv[12])
HIDDEN = int(sys.argv[13])

# Set the value of some constants
NETWORK_INTERFACE_NAMES = "mon" # beginning of the network interface names in monitor mode. e.g. mon
TAP_INTERFACE_NAME = "ap" # name of the TAP device that Click will create in the
STA_IP = "192.168.1.11" # IP address of the STA in the LVAP tuple. It only works for a single client without DHCP
STA_MAC = "74:F0:6D:20:D4:74" # MAC address of the STA in the LVAP tuple. It only works for a single client without DHCP
RATE = "108" # e.g. if it is 108, this means 108*500kbps = 54Mbps

print '''
// This is the scheme:
Expand All @@ -74,8 +82,8 @@

print '''
// call OdinAgent::configure to create and configure an Odin agent:
odinagent::OdinAgent(HWADDR %s, RT rates, CHANNEL %s, DEFAULT_GW %s, DEBUGFS %s, SSIDAGENT %s, DEBUG_ODIN %s)
''' % (AP_UNIQUE_BSSID, AP_CHANNEL, DEFAULT_GW, DEBUGFS_FILE, SSIDAGENT, DEBUG_ODIN )
odinagent::OdinAgent(HWADDR %s, RT rates, CHANNEL %s, DEFAULT_GW %s, DEBUGFS %s, SSIDAGENT %s, DEBUG_ODIN %s, TX_RATE %s, TX_POWER %s, HIDDEN %s)
''' % (AP_UNIQUE_BSSID, AP_CHANNEL, DEFAULT_GW, DEBUGFS_FILE, SSIDAGENT, DEBUG_ODIN, TX_RATE, TX_POWER, HIDDEN )

print '''
// send a ping to odinsocket every 2 seconds
Expand Down Expand Up @@ -103,7 +111,7 @@
print '''
// output 3 of odinagent goes to odinsocket
odinagent[3] -> odinsocket
rates :: AvailableRates(DEFAULT 24 36 48 108); // wifi rates in multiples of 500kbps
rates :: AvailableRates(DEFAULT 12 18 24 36 48 72 96 108); // wifi rates in multiples of 500kbps
control :: ControlSocket("TCP", 6777);
chatter :: ChatterSocket("TCP", 6778);
'''
Expand Down Expand Up @@ -156,7 +164,7 @@
-> SetTXRate (%s) // e.g. if it is 108, this means 54Mbps=108*500kbps
-> RadiotapEncap()
-> to_dev :: ToDevice (%s0);
''' % (QUEUE_SIZE, RATE, NETWORK_INTERFACE_NAMES )
''' % (QUEUE_SIZE, TX_RATE, NETWORK_INTERFACE_NAMES )

print '''
odinagent[2]
Expand Down
36 changes: 36 additions & 0 deletions scripts_start_ap_odin/init_cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

#Setup variables
# My local IP address, i.e. the one I am using to connect with the Odin Controller
MYIP=192.168.101.9

# This is the IP of the Odin Controller
CTLIP=192.168.101.129

# This is the TCP port number for the openvswitch database
TCP_PORT_OVS_DBASE=6632

# This is the TCP port number for the Click control socket (controlskt)
TCP_PORT_CLICK_CTRL_SOCKET=6777

# This is the name of the bridge that we are going to create
SW=br0


# Start Click, using the correct name of the ALIGNED .cli file
./click a_agent.cli &

# Wait some time
sleep 3

# Start the 'ap' interface created by Click
ifconfig ap up

# Add the 'ap' interface to the openvswitch
ovs-vsctl --db=tcp:$MYIP:$TCP_PORT_OVS_DBASE add-port $SW ap

# Wait some time
sleep 3

# Add an Openflow rule in the Controller, to manage the new flows of the Click control socket
ovs-ofctl add-flow $SW in_port=1,dl_type=0x0800,nw_src=$CTLIP,nw_dst=$MYIP,nw_proto=6,tp_dst=$TCP_PORT_CLICK_CTRL_SOCKET,actions=output:LOCAL
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# This has been taken from https://gist.github.com/marciolm/9f0ab13b877372d08e8f
#!/bin/sh
# This has been adapted from https://gist.github.com/marciolm/9f0ab13b877372d08e8f

#Setup variables
#My local IP address is required for the ovsdb server.
MYIP=192.168.1.6
MYIP=192.168.101.9

# This is the OpenFlow controller ID which we're going to load into the OVS
CTLIP=192.168.1.2
CTLIP=192.168.101.129

# This is our DataPath ID
DPID=0000000000000212

# This is the name of the bridge that we're going to be creating
# This is the name of the bridge that we are going to create
SW=br0

# This is the TCP port number for the openvswitch database
TCP_PORT_OVS=6632
TCP_PORT_OVS_DBASE=6632

# This is the TCP port number for the control of OpenFlow
TCP_PORT_OPENFLOW=6633

#What ports are we going to put in the OVS?
#DPPORTS="eth0.1 eth0.2 eth0.3 eth0.4 wlan0 wlan0-2 wlan0-3"
DPPORTS="eth1.1"

#Alias some variables
VSCTL="ovs-vsctl --db=tcp:$MYIP:$TCP_PORT_OVS"
VSCTL="ovs-vsctl --db=tcp:$MYIP:$TCP_PORT_OVS_DBASE"
OVSDB=/tmp/ovs-vswitchd.conf.db

# Subroutine to wait until a port is ready
Expand All @@ -46,19 +50,24 @@ rm -f $OVSDB
ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema

# Start the OVSDB server and wait until it starts
ovsdb-server $OVSDB --remote=ptcp:$TCP_PORT_OVS:$MYIP &
#wait_port_listen $TCP_PORT_OVS
ovsdb-server $OVSDB --remote=ptcp:$TCP_PORT_OVS_DBASE:$MYIP &
#wait_port_listen $TCP_PORT_OVS_DBASE
sleep 5

# Start vSwitchd
ovs-vswitchd tcp:$MYIP:$TCP_PORT_OVS --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- &
ovs-vswitchd tcp:$MYIP:$TCP_PORT_OVS_DBASE --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- &

# Create the bridge and pass in some configuration options
$VSCTL add-br $SW

# In OpenWrt 15.05 the bridge is created down
ifconfig $SW up

#optional: define the version of OpenFlow to be used
#$VSCTL set bridge $SW protocols=OpenFlow10

#Configure the switch to have an OpenFlow Controller. This will contact the controller.
$VSCTL set-controller $SW tcp:$CTLIP:6633
$VSCTL set-controller $SW tcp:$CTLIP:$TCP_PORT_OPENFLOW

# Turn off the fail-safe mode
$VSCTL set-fail-mode $SW secure
Expand Down
8 changes: 0 additions & 8 deletions scripts_start_ap_odin/script_start_click.sh

This file was deleted.

31 changes: 31 additions & 0 deletions scripts_start_ap_odin/start_odin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ route add -net 155.210.156.0 netmask 255.255.255.0 gw 155.210.157.254 eth0
# set the default gateway where masquerading is being performed
# NOTE: This may vary according to your setup. Add your default gateway as needed
route del default gw 155.210.157.254
<<<<<<< HEAD
route add default gw 192.168.1.129

# if you have put click and start-up scripts in a usb device, mount the USB
Expand All @@ -31,3 +32,33 @@ cd /mnt/usb/
./script_start_ovs.sh
sleep 2
./script_start_click.sh
=======
route add default gw 192.168.101.129

# this script assumes you have:
# - in the root directory (current): start_odin.sh
# - in the USB:
# - init_ovs.sh
# - init_cli.sh
# - click the compiled Click application
# - a_agent.cli the .cli file to be run by Click. It must be aligned

# mount the USB
mkdir -p /mnt/usb
mount /dev/sda1 /mnt/usb/ #sda1 may have to be replaced by other device


# initiate openvswitch and click with the corresponding scripts:

# move to /mnt/usb
cd /mnt/usb

# initiate openvswitch (ovs)
./init_ovs.sh

# wait some time
sleep 2

# initiate click (cli)
./init_cli.sh
>>>>>>> refs/heads/alpha_stats
Loading

0 comments on commit 478ce75

Please sign in to comment.