From b17e1091694af1a20550150f198ac6ea16b8de0b Mon Sep 17 00:00:00 2001 From: luissequeira Date: Tue, 25 Oct 2016 17:15:46 +0200 Subject: [PATCH 01/14] MobilityManager: Integrating client scanning functionality. --- .directory | 3 - agent-click-file-gen.py | 40 ++++++--- scripts_start_ap_odin/init_cli.sh | 36 -------- scripts_start_ap_odin/init_ovs.sh | 86 ------------------ scripts_start_ap_odin/start.sh | 74 ++++++++++++++++ scripts_start_ap_odin/start_odin.sh | 64 -------------- src/odinagent.cc | 130 +++++++++++++++++++++++++++- src/odinagent.hh | 6 +- 8 files changed, 235 insertions(+), 204 deletions(-) delete mode 100644 .directory delete mode 100644 scripts_start_ap_odin/init_cli.sh delete mode 100644 scripts_start_ap_odin/init_ovs.sh create mode 100644 scripts_start_ap_odin/start.sh delete mode 100644 scripts_start_ap_odin/start_odin.sh diff --git a/.directory b/.directory deleted file mode 100644 index 127b8ac..0000000 --- a/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -Timestamp=2016,4,11,13,41,28 -Version=3 diff --git a/agent-click-file-gen.py b/agent-click-file-gen.py index 38062fd..e81c07a 100644 --- a/agent-click-file-gen.py +++ b/agent-click-file-gen.py @@ -37,7 +37,7 @@ 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 MM N P 0 > agent.click' %(sys.argv[0]) + print '$ python agent-click-file-gen.py 9 50 60:E3:27:4F:C7:E1 192.168.1.129 2819 /sys/kernel/debug/ieee80211/phy0/ath9k/bssid_extra wi5-demo 192.168.1.9 1 01 108 25 0 > agent.cli' %(sys.argv[0]) print '' print 'and then run the .click file you have generated' print 'click$ ./bin/click agent.click' @@ -51,8 +51,8 @@ ODIN_MASTER_PORT = sys.argv[5] DEBUGFS_FILE = sys.argv[6] SSIDAGENT = sys.argv[7] -DEFAULT_GW = sys.argv[8] #the IP address of the Access Point. -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. +DEFAULT_GW = sys.argv[8] #the IP address of the Access Point. +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]) @@ -61,22 +61,24 @@ # 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 +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 print ''' // This is the scheme: // // TAP interface 'ap' in the machine that runs Click -// | ^ -// from host | | to host -// v | -// click -// | ^ -// to device | | to device -// V | -// 'mon0' interface in the machine that runs Click. Must be in monitor mode +// | ^ +// from host | | to host +// v | +// -------------- +// | click | +// -------------- +// | ^ | ^ +// to device | | | | to device +// V | V | +// 'mon0' 'mon1' interfaces in the machine that runs Click. Must be in monitor mode // ''' @@ -183,6 +185,18 @@ -> [0]odinagent ''' % ( NETWORK_INTERFACE_NAMES ) +print ''' +// ----------------Packets coming up (from the STA to the AP) go to the input 0 of the Odin Agent +from_dev1 :: FromDevice(%s1, HEADROOM 50) + -> RadiotapDecap() + -> ExtraDecap() + -> phyerr_filter1 :: FilterPhyErr() + -> tx_filter1 :: FilterTX() + -> dupe1 :: WifiDupeFilter() // Filters out duplicate 802.11 packets based on their sequence number + // click/elements/wifi/wifidupefilter.hh + -> [2]odinagent +''' % ( NETWORK_INTERFACE_NAMES ) + print ''' odinagent[0] -> q diff --git a/scripts_start_ap_odin/init_cli.sh b/scripts_start_ap_odin/init_cli.sh deleted file mode 100644 index 1f3273a..0000000 --- a/scripts_start_ap_odin/init_cli.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/scripts_start_ap_odin/init_ovs.sh b/scripts_start_ap_odin/init_ovs.sh deleted file mode 100644 index b3bc482..0000000 --- a/scripts_start_ap_odin/init_ovs.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/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.101.9 - -# This is the OpenFlow controller ID which we're going to load into the OVS -CTLIP=192.168.101.129 - -# This is our DataPath ID -DPID=0000000000000212 - -# 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_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_DBASE" -OVSDB=/tmp/ovs-vswitchd.conf.db - -# Subroutine to wait until a port is ready -wait_port_listen() { - port=$1 - while ! `netstat -na | grep $port` ; do - echo -n . - sleep 1 - done -} - -# Kill off the servers and remove any stale lockfiles -/usr/bin/killall ovsdb-server -/usr/bin/killall ovs-vswitchd -rm /tmp/ovs-vswitchd.conf.db.~lock~ - -# Remove the OVS Database and then recreate. -rm -f $OVSDB - -# ovsdg-tool is the Open vSwitch database management utility -# if you use #ovsdb-tool create [DB [SCHEMA]], then you create a DB with the given SCHEMA -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_DBASE:$MYIP & -#wait_port_listen $TCP_PORT_OVS_DBASE -sleep 5 - -# Start vSwitchd -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:$TCP_PORT_OPENFLOW - -# Turn off the fail-safe mode -$VSCTL set-fail-mode $SW secure - -#Cycle through the DataPath ports adding them to the switch -for i in $DPPORTS ; do - PORT=$i - ifconfig $PORT up - $VSCTL add-port $SW $PORT -done - -#Ensure that the switch has the correct DataPath ID -$VSCTL set bridge $SW other-config:datapath-id=$DPID - -#Set some parameters for sFlow traffic control (see sFlow in http://openvswitch.org/support/dist-docs/ovs-vsctl.8.txt) -#$VSCTL --id=@sflow create sflow agent=eth1.1 target=\"$CTLIP:6343\" sampling=2 polling=20 -- -- set bridge $SW sflow=@sflow diff --git a/scripts_start_ap_odin/start.sh b/scripts_start_ap_odin/start.sh new file mode 100644 index 0000000..22e56d0 --- /dev/null +++ b/scripts_start_ap_odin/start.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +## Variables +echo "Setting variables" +CTLIP=192.168.1.129 # Controller IP +SW=br0 +DPPORTS="eth1.2" # Ports for data plane +VSCTL="ovs-vsctl" + +## Setting interfaces +echo "Setting interfaces" +ifconfig wlan0 down # Main interface +ifconfig wlan1 down # Auxiliary interface +iw phy phy0 interface add mon0 type monitor +iw phy phy1 interface add mon1 type monitor +iw phy phy0 set retry short 4 +iw phy phy1 set retry short 4 +ifconfig mon0 up +ifconfig mon1 up +ifconfig wlan0 up +ifconfig wlan1 up +# add this route in order to permit control from Unizar networks +# traffic from these networks will not go through the default gateway +route add -net 155.210.158.0 netmask 255.255.255.0 gw 155.210.157.254 eth0 +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 +#route del default gw 155.210.157.254 +#route add default gw 192.168.1.131 + +## We assume that OpenvSwitch runs when OpenWRT starts up +echo "Restarting OpenvSwitch daemon" +/etc/init.d/openvswitch stop +echo "Cleaning DB" +if [ -d "/etc/openvswitch" ]; then + rm -r /etc/openvswitch +fi +if [ -f "/var/run/db.sock" ]; then + rm /var/run/db.sock +fi +if [ -f "/var/run/ovsdb-server.pid" ]; then + rm /var/run/ovsdb-server.pid +fi +if [ -f "/var/run/ovs-vswitchd.pid" ]; then + rm /var/run/ovs-vswitchd.pid +fi +/etc/init.d/openvswitch start +echo "Configuring OpenvSwitch" +$VSCTL add-br $SW # Create the bridge +ifconfig $SW up # In OpenWrt 15.05 the bridge is created down +$VSCTL set-controller $SW tcp:$CTLIP:6633 # Configure the OpenFlow Controller. +for i in $DPPORTS ; do # Including ports to OVS + PORT=$i + ifconfig $PORT up + $VSCTL add-port $SW $PORT +done + +## Launch click +echo "Mounting USB" # Because we have click into the USB +if [ ! -d "/mnt/usb" ]; then + mkdir -p /mnt/usb +fi +mount /dev/sda1 /mnt/usb/ +cd /mnt/usb +sleep 1 +./click aagent9.cli & +sleep 1 +ifconfig ap up # Adding ap interface (click Interface) to OVS +$VSCTL add-port $SW ap +sleep 1 + +## OVS Rules +# DHCP rules needed by odin-wi5 controller +ovs-ofctl add-flow br0 in_port=2,dl_type=0x0800,nw_proto=17,tp_dst=67,actions=output:1,CONTROLLER +ovs-ofctl add-flow br0 in_port=1,dl_type=0x0800,nw_proto=17,tp_dst=68,actions=output:CONTROLLER,2 diff --git a/scripts_start_ap_odin/start_odin.sh b/scripts_start_ap_odin/start_odin.sh deleted file mode 100644 index 04ed575..0000000 --- a/scripts_start_ap_odin/start_odin.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -echo "interfaces" -#put wlan0 down before creating mon0 -ifconfig wlan0 down -#add the monitor device -iw phy phy0 interface add mon0 type monitor -#you should not define the channel here, so we have commented the next line -#iw dev wlan0 set channel 1 -#initiate mon0 -ifconfig mon0 up -#initiate wlan0. You must have it active, otherwise things do not work -ifconfig wlan0 up - -# add this route in order to permit control from Unizar networks -# traffic from these networks will not go through the default gateway -# NOTE: The next two lines are just for our Unizar setup, so you can remove them -route add -net 155.210.158.0 netmask 255.255.255.0 gw 155.210.157.254 eth0 -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 -mkdir -p /mnt/usb -mount /dev/sda1 /mnt/usb/ -cd /mnt/usb/ - -# start ovs and click with the corresponding scripts -./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 diff --git a/src/odinagent.cc b/src/odinagent.cc index 0644ad4..cb680cc 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -119,6 +119,9 @@ OdinAgent::configure(Vector &conf, ErrorHandler *errh) _csa_count = _csa_count_default; _count_csa_beacon_default = 4; // Number of beacons before channel switch _count_csa_beacon = _count_csa_beacon_default; + _active_scanning = false; + _scanned_sta_mac = EtherAddress(); + _scanning_result = 0; // read the arguments of the .cli file if (Args(conf, this, errh) @@ -1465,6 +1468,8 @@ OdinAgent::update_rx_stats(Packet *p) * to be coming from a physical device * In-port-1: Any ethernet encapsulated frame. Expected * to be coming from a tap device + * In-port-2: Any 802.11 encapsulated frame. Used exclusively + * for scanning clients. * * Out-port-0: If in-port-0, and packet was a management frame, * then send out management response. @@ -1487,6 +1492,50 @@ OdinAgent::push(int port, Packet *p) if (port == 0) { // if port == 0, paket is coming from the lower layer + /**************************************************************************** + ***************************************************************************** + ** If scanning interface is mon0 put this code when port == 0 ************* + ***************************************************************************** + *****************************************************************************/ + /* if (_active_scanning) { + + if (p->length() < sizeof(struct click_wifi)) { + p->kill(); + return; + } + + struct click_wifi *w = (struct click_wifi *) p->data(); + EtherAddress src = EtherAddress(w->i_addr2); + if (src == _scanned_sta_mac) { + // Get station statistics + struct click_wifi_extra *ceh = WIFI_EXTRA_ANNO(p); + // StationStats stat; + // HashTable::const_iterator it = _rx_stats.find(src); + // if (it == _rx_stats.end()) + // stat = StationStats(); + // else + // stat = it.value(); + + // stat._rate = ceh->rate; + // stat._noise = ceh->silence; + // stat._signal = ceh->rssi + _signal_offset; + // stat._packets++; + // stat._last_received.assign_now(); + _scanning_result = ceh->rssi + _signal_offset; // FIXME: cook this value + } + }*/ + + /**************************************************************************** + ***************************************************************************** + ***************************************************************************** + *****************************************************************************/ + + /**************************************************************************** + ***************************************************************************** + ** If scanning interface is mon1 leave this code when port == 0 ************* + ***************************************************************************** + *****************************************************************************/ + if (p->length() < sizeof(struct click_wifi)) { p->kill(); return; @@ -1592,6 +1641,10 @@ OdinAgent::push(int port, Packet *p) output(1).push(p); return; } + /**************************************************************************** + ***************************************************************************** + ***************************************************************************** + *****************************************************************************/ } else if (port == 1) { // This means that the packet is coming from the higher layer, @@ -1634,6 +1687,37 @@ OdinAgent::push(int port, Packet *p) } } + else if (port == 2) { + // if port == 2, paket is coming from the lower layer (from scanning device) + if (_active_scanning) { + + if (p->length() < sizeof(struct click_wifi)) { + p->kill(); + return; + } + + struct click_wifi *w = (struct click_wifi *) p->data(); + EtherAddress src = EtherAddress(w->i_addr2); + if (src == _scanned_sta_mac) { + // Get station statistics + struct click_wifi_extra *ceh = WIFI_EXTRA_ANNO(p); + // StationStats stat; + // HashTable::const_iterator it = _rx_stats.find(src); + // if (it == _rx_stats.end()) + // stat = StationStats(); + // else + // stat = it.value(); + + // stat._rate = ceh->rate; + // stat._noise = ceh->silence; + // stat._signal = ceh->rssi + _signal_offset; + // stat._packets++; + // stat._last_received.assign_now(); + _scanning_result = ceh->rssi + _signal_offset; // FIXME: cook this value + } + } + } + p->kill(); return; } @@ -1826,6 +1910,12 @@ OdinAgent::match_against_subscriptions(StationStats stats, EtherAddress src) } +/* + * We have include new handlers an modified others + * + * @author Luis Sequeira + * + * */ String OdinAgent::read_handler(Element *e, void *user_data) { @@ -1953,6 +2043,15 @@ OdinAgent::read_handler(Element *e, void *user_data) sa << agent->_mean << " " << agent->_num_mean << " " << variance << "\n"; break; } + + case handler_scan_client: { + // Scanning result + sa << agent->_scanning_result << "\n"; + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan file \n"); + agent->_active_scanning = false;// Disable scanning + break; + } + } return sa.take_string(); @@ -2276,7 +2375,34 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } break; - } + } + case handler_scan_client: { // need testing + EtherAddress sta_mac; + std::stringstream ss; + int channel; + if (Args(agent, errh).push_back_words(str) + .read_mp("STA_MAC", sta_mac) + .read_mp("CHANNEL", channel) + .complete() < 0) + { + return -1; + } + if (agent->_debug_level % 10 > 0) + fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); + // Set channel to scan + ss << "iw dev wlan1 set channel " << channel; + std::string str = ss.str(); + char *cstr = new char[str.length() + 1]; + strcpy(cstr, str.c_str()); + system(cstr); + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing + // Enable scanning (FIXME: time to begin this action) + agent->_active_scanning = true; + agent->_scanned_sta_mac = sta_mac; + agent->_scanning_result = 0; + break; + } + } return 0; } @@ -2293,6 +2419,7 @@ OdinAgent::add_handlers() add_read_handler("subscriptions", read_handler, handler_subscriptions); add_read_handler("debug", read_handler, handler_debug); add_read_handler("report_mean", read_handler, handler_report_mean); + add_read_handler("scan_client", read_handler, handler_scan_client); add_write_handler("add_vap", write_handler, handler_add_vap); add_write_handler("set_vap", write_handler, handler_set_vap); @@ -2306,6 +2433,7 @@ OdinAgent::add_handlers() add_write_handler("handler_update_signal_strength", write_handler, handler_update_signal_strength); add_write_handler("signal_strength_offset", write_handler, handler_signal_strength_offset); add_write_handler("channel_switch_announcement", write_handler, handler_channel_switch_announcement); + add_write_handler("scan_client", write_handler, handler_scan_client); } /* This debug function prints info about clients */ diff --git a/src/odinagent.hh b/src/odinagent.hh index 81b9d77..66741b5 100644 --- a/src/odinagent.hh +++ b/src/odinagent.hh @@ -47,7 +47,7 @@ public: // From Click const char *class_name() const { return "OdinAgent"; } - const char *port_count() const { return "2/4"; } + const char *port_count() const { return "3/4"; } const char *processing() const { return PUSH; } int initialize(ErrorHandler *); // initialize element int configure(Vector &, ErrorHandler *); @@ -131,6 +131,7 @@ public: handler_update_signal_strength, handler_signal_strength_offset, handler_channel_switch_announcement, + handler_scan_client, }; // Tx and Rx-stats about stations @@ -186,6 +187,9 @@ public: int _count_csa_beacon_default; // Default number of beacons before channel switch int _csa_count; // For _csa FALSE-->TRUE int _csa_count_default; + bool _active_scanning; // To active scanning + EtherAddress _scanned_sta_mac; // MAC to scan + int _scanning_result; // Result for scanning Vector _subscription_list; //bool _debug; int _debug_level; //"0" no info displayed; "1" only basic info displayed; "2" all the info displayed; "1x" demo info displayed From 5ef1cb606835e7db802152ca68117cd02ffcfd02 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Tue, 25 Oct 2016 18:28:38 +0200 Subject: [PATCH 02/14] Startup script update. --- .directory | 3 - scripts_start_ap_odin/init_cli.sh | 36 ------------ scripts_start_ap_odin/init_ovs.sh | 86 ----------------------------- scripts_start_ap_odin/start.sh | 74 +++++++++++++++++++++++++ scripts_start_ap_odin/start_odin.sh | 64 --------------------- 5 files changed, 74 insertions(+), 189 deletions(-) delete mode 100644 .directory delete mode 100644 scripts_start_ap_odin/init_cli.sh delete mode 100644 scripts_start_ap_odin/init_ovs.sh create mode 100644 scripts_start_ap_odin/start.sh delete mode 100644 scripts_start_ap_odin/start_odin.sh diff --git a/.directory b/.directory deleted file mode 100644 index 127b8ac..0000000 --- a/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -Timestamp=2016,4,11,13,41,28 -Version=3 diff --git a/scripts_start_ap_odin/init_cli.sh b/scripts_start_ap_odin/init_cli.sh deleted file mode 100644 index 1f3273a..0000000 --- a/scripts_start_ap_odin/init_cli.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/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 \ No newline at end of file diff --git a/scripts_start_ap_odin/init_ovs.sh b/scripts_start_ap_odin/init_ovs.sh deleted file mode 100644 index b3bc482..0000000 --- a/scripts_start_ap_odin/init_ovs.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/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.101.9 - -# This is the OpenFlow controller ID which we're going to load into the OVS -CTLIP=192.168.101.129 - -# This is our DataPath ID -DPID=0000000000000212 - -# 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_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_DBASE" -OVSDB=/tmp/ovs-vswitchd.conf.db - -# Subroutine to wait until a port is ready -wait_port_listen() { - port=$1 - while ! `netstat -na | grep $port` ; do - echo -n . - sleep 1 - done -} - -# Kill off the servers and remove any stale lockfiles -/usr/bin/killall ovsdb-server -/usr/bin/killall ovs-vswitchd -rm /tmp/ovs-vswitchd.conf.db.~lock~ - -# Remove the OVS Database and then recreate. -rm -f $OVSDB - -# ovsdg-tool is the Open vSwitch database management utility -# if you use #ovsdb-tool create [DB [SCHEMA]], then you create a DB with the given SCHEMA -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_DBASE:$MYIP & -#wait_port_listen $TCP_PORT_OVS_DBASE -sleep 5 - -# Start vSwitchd -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:$TCP_PORT_OPENFLOW - -# Turn off the fail-safe mode -$VSCTL set-fail-mode $SW secure - -#Cycle through the DataPath ports adding them to the switch -for i in $DPPORTS ; do - PORT=$i - ifconfig $PORT up - $VSCTL add-port $SW $PORT -done - -#Ensure that the switch has the correct DataPath ID -$VSCTL set bridge $SW other-config:datapath-id=$DPID - -#Set some parameters for sFlow traffic control (see sFlow in http://openvswitch.org/support/dist-docs/ovs-vsctl.8.txt) -#$VSCTL --id=@sflow create sflow agent=eth1.1 target=\"$CTLIP:6343\" sampling=2 polling=20 -- -- set bridge $SW sflow=@sflow diff --git a/scripts_start_ap_odin/start.sh b/scripts_start_ap_odin/start.sh new file mode 100644 index 0000000..22e56d0 --- /dev/null +++ b/scripts_start_ap_odin/start.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +## Variables +echo "Setting variables" +CTLIP=192.168.1.129 # Controller IP +SW=br0 +DPPORTS="eth1.2" # Ports for data plane +VSCTL="ovs-vsctl" + +## Setting interfaces +echo "Setting interfaces" +ifconfig wlan0 down # Main interface +ifconfig wlan1 down # Auxiliary interface +iw phy phy0 interface add mon0 type monitor +iw phy phy1 interface add mon1 type monitor +iw phy phy0 set retry short 4 +iw phy phy1 set retry short 4 +ifconfig mon0 up +ifconfig mon1 up +ifconfig wlan0 up +ifconfig wlan1 up +# add this route in order to permit control from Unizar networks +# traffic from these networks will not go through the default gateway +route add -net 155.210.158.0 netmask 255.255.255.0 gw 155.210.157.254 eth0 +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 +#route del default gw 155.210.157.254 +#route add default gw 192.168.1.131 + +## We assume that OpenvSwitch runs when OpenWRT starts up +echo "Restarting OpenvSwitch daemon" +/etc/init.d/openvswitch stop +echo "Cleaning DB" +if [ -d "/etc/openvswitch" ]; then + rm -r /etc/openvswitch +fi +if [ -f "/var/run/db.sock" ]; then + rm /var/run/db.sock +fi +if [ -f "/var/run/ovsdb-server.pid" ]; then + rm /var/run/ovsdb-server.pid +fi +if [ -f "/var/run/ovs-vswitchd.pid" ]; then + rm /var/run/ovs-vswitchd.pid +fi +/etc/init.d/openvswitch start +echo "Configuring OpenvSwitch" +$VSCTL add-br $SW # Create the bridge +ifconfig $SW up # In OpenWrt 15.05 the bridge is created down +$VSCTL set-controller $SW tcp:$CTLIP:6633 # Configure the OpenFlow Controller. +for i in $DPPORTS ; do # Including ports to OVS + PORT=$i + ifconfig $PORT up + $VSCTL add-port $SW $PORT +done + +## Launch click +echo "Mounting USB" # Because we have click into the USB +if [ ! -d "/mnt/usb" ]; then + mkdir -p /mnt/usb +fi +mount /dev/sda1 /mnt/usb/ +cd /mnt/usb +sleep 1 +./click aagent9.cli & +sleep 1 +ifconfig ap up # Adding ap interface (click Interface) to OVS +$VSCTL add-port $SW ap +sleep 1 + +## OVS Rules +# DHCP rules needed by odin-wi5 controller +ovs-ofctl add-flow br0 in_port=2,dl_type=0x0800,nw_proto=17,tp_dst=67,actions=output:1,CONTROLLER +ovs-ofctl add-flow br0 in_port=1,dl_type=0x0800,nw_proto=17,tp_dst=68,actions=output:CONTROLLER,2 diff --git a/scripts_start_ap_odin/start_odin.sh b/scripts_start_ap_odin/start_odin.sh deleted file mode 100644 index 04ed575..0000000 --- a/scripts_start_ap_odin/start_odin.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -echo "interfaces" -#put wlan0 down before creating mon0 -ifconfig wlan0 down -#add the monitor device -iw phy phy0 interface add mon0 type monitor -#you should not define the channel here, so we have commented the next line -#iw dev wlan0 set channel 1 -#initiate mon0 -ifconfig mon0 up -#initiate wlan0. You must have it active, otherwise things do not work -ifconfig wlan0 up - -# add this route in order to permit control from Unizar networks -# traffic from these networks will not go through the default gateway -# NOTE: The next two lines are just for our Unizar setup, so you can remove them -route add -net 155.210.158.0 netmask 255.255.255.0 gw 155.210.157.254 eth0 -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 -mkdir -p /mnt/usb -mount /dev/sda1 /mnt/usb/ -cd /mnt/usb/ - -# start ovs and click with the corresponding scripts -./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 From 37c2f72e3edae5bf63debf92b53e94b75254b406 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Wed, 2 Nov 2016 16:34:26 +0100 Subject: [PATCH 03/14] MobilityManager: Set channel to scan in wlan1 --- src/odinagent.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index cb680cc..ac3f8bf 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -2161,12 +2161,13 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Changing AP to channel %i\n", channel); std::stringstream ss; - ss << "hostapd_cli chan_switch " << agent->_count_csa_beacon_default << " " << channel; + // Set channel to wlan0 + ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << channel; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); system(cstr); - system("iw mon0 info"); + system("iw dev wlan0 info"); break; } case handler_interval: { @@ -2349,7 +2350,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) - fprintf(stderr, "[Odinagent.cc] #################### Setting csa new and new channel %i\n", new_channel); + fprintf(stderr, "[Odinagent.cc] #################### Setting csa and new channel %i\n", new_channel); Vector ssidList; while (!args.empty()) { @@ -2389,8 +2390,8 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); - // Set channel to scan - ss << "iw dev wlan1 set channel " << channel; + // Set channel to scan in wlan1 + ss << "hostapd_cli -i wlan1 chan_switch 1 " << channel; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); From 8eec4788d150999e6f20894fc81318d10d6d061f Mon Sep 17 00:00:00 2001 From: luissequeira Date: Thu, 3 Nov 2016 11:25:35 +0100 Subject: [PATCH 04/14] Logs for testing --- src/odinagent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index ac3f8bf..437c346 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -2047,7 +2047,7 @@ OdinAgent::read_handler(Element *e, void *user_data) case handler_scan_client: { // Scanning result sa << agent->_scanning_result << "\n"; - fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan file \n"); + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", _scannig_result); agent->_active_scanning = false;// Disable scanning break; } From 3bd58bf4fd6b256017bcaaa7832fca537ca8e305 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Fri, 4 Nov 2016 11:55:29 +0100 Subject: [PATCH 05/14] Logs for testing scanning. --- src/odinagent.cc | 21 +++++++++++---------- src/odinagent.hh | 19 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index 437c346..9afb72a 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -1548,7 +1548,7 @@ OdinAgent::push(int port, Packet *p) EtherAddress src = EtherAddress(w->i_addr2); - // Update Rx statistics + // Update Rx statistics update_rx_stats(p); type = w->i_fc[0] & WIFI_FC0_TYPE_MASK; @@ -1659,7 +1659,7 @@ OdinAgent::push(int port, Packet *p) if (_sta_mapping_table.find (eth) != _sta_mapping_table.end ()) { OdinStationState oss = _sta_mapping_table.get (eth); - // If the client tried to make an ARP request for + // If the client tried to make an ARP request for // its default gateway, and there is a response coming from // upstream, we have to correct the resolved hw-addr with the // VAP-BSSID to which the client corresponds. @@ -1677,11 +1677,10 @@ OdinAgent::push(int port, Packet *p) // } //} - // Add wifi header - Packet *p_out = wifi_encap (p, oss._vap_bssid); - - // Update Tx statistics with this packet - update_tx_stats(p_out); + // Add wifi header + Packet *p_out = wifi_encap (p, oss._vap_bssid); + // Update Tx statistics with this packet + update_tx_stats(p_out); output(2).push(p_out); return; } @@ -2045,9 +2044,10 @@ OdinAgent::read_handler(Element *e, void *user_data) } case handler_scan_client: { + int scanning_result = agent->_scanning_result; // Scanning result sa << agent->_scanning_result << "\n"; - fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", _scannig_result); + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", scanning_result); agent->_active_scanning = false;// Disable scanning break; } @@ -2366,7 +2366,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa agent->_new_channel = new_channel;//How to put the channel into new_channel? agent->_csa = true; - for (int i = agent->_count_csa_beacon_default; i >= 0; i--){// Sending the CSA 5 times + for (int i = agent->_count_csa_beacon_default; i >= 0; i--){// Sending the CSA n times //if (agent->_debug_level % 10 > 0) //fprintf(stderr,i,"\n"); for (Vector::const_iterator it = ssidList.begin(); @@ -2390,11 +2390,12 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); - // Set channel to scan in wlan1 + // Set channel to scan in wlan1 (auxiliary) ss << "hostapd_cli -i wlan1 chan_switch 1 " << channel; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing system(cstr); fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing // Enable scanning (FIXME: time to begin this action) diff --git a/src/odinagent.hh b/src/odinagent.hh index 66741b5..c1f2890 100644 --- a/src/odinagent.hh +++ b/src/odinagent.hh @@ -140,17 +140,14 @@ public: int _rate; int _noise; int _signal; - int _len_pkt; - - int _packets; //number of packets - double _avg_signal; //average value of the signal - double _avg_rate; //average rate of the packets - double _avg_len_pkt; //average length of the packets - double _air_time; //airtime consumed by this STA, calculated as 8 * _len_pkt / _rate - - Timestamp _time_first_packet; //timestamp of the first packet included in the statistics + int _len_pkt; + int _packets; //number of packets + double _avg_signal; //average value of the signal + double _avg_rate; //average rate of the packets + double _avg_len_pkt; //average length of the packets + double _air_time; //airtime consumed by this STA, calculated as 8 * _len_pkt / _rate + Timestamp _time_first_packet; //timestamp of the first packet included in the statistics Timestamp _time_last_packet; //timestamp of the last packet included in the statistics - StationStats() { memset(this, 0, sizeof(*this)); } @@ -198,7 +195,7 @@ public: private: void compute_bssid_mask (); - void update_tx_stats(Packet *p); + void update_tx_stats(Packet *p); void update_rx_stats(Packet *p); EtherAddress _hw_mac_addr; class AvailableRates *_rtable; From 641ae646f011f87677c3c1592c66a082172005e0 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Mon, 7 Nov 2016 16:55:09 +0100 Subject: [PATCH 06/14] Including channel <--> frequency conversion functions. --- src/odinagent.cc | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index 9afb72a..e5da101 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -112,8 +112,8 @@ OdinAgent::configure(Vector &conf, ErrorHandler *errh) _interval_ms_default = 100; // BI for normal mode _interval_ms_burst = 10; // BI value for burst mode _interval_ms = _interval_ms_default; - _channel = 6; - _new_channel = 1; + _channel = 6; // Actually frequency + _new_channel = 1; // Actually frequency _csa = false; // _csa_count_default = 10; // Wait (n+1) beacons before first channel switch announcement _csa_count = _csa_count_default; @@ -2150,24 +2150,25 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } case handler_channel: { // Modified, now it change the physical channel int channel; + int frequency; if (Args(agent, errh).push_back_words(str) .read_mp("CHANNEL", channel) .complete() < 0) { return -1; } - + frequency = convert_channel_to_frequency(channel); agent->_channel = channel; if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Changing AP to channel %i\n", channel); std::stringstream ss; // Set channel to wlan0 - ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << channel; + ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); system(cstr); - system("iw dev wlan0 info"); + system("sleep 2 && iw dev wlan0 info &"); break; } case handler_interval: { @@ -2381,6 +2382,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa EtherAddress sta_mac; std::stringstream ss; int channel; + int frequency; if (Args(agent, errh).push_back_words(str) .read_mp("STA_MAC", sta_mac) .read_mp("CHANNEL", channel) @@ -2390,12 +2392,12 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); + frequency = convert_channel_to_frequency(channel); // Set channel to scan in wlan1 (auxiliary) - ss << "hostapd_cli -i wlan1 chan_switch 1 " << channel; + ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); - fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing system(cstr); fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing // Enable scanning (FIXME: time to begin this action) @@ -2587,6 +2589,31 @@ void misc_thread(Timer *timer, void *data){ } +/*Miscellaneous*/ +int convert_frequency_to__channel(int freq) { + if (freq >= 2412 & freq <= 2484) { + int chan = (freq - 2412) / 5 + 1; + return chan; + } else if (freq >= 5170 & freq <= 5825) { + int chan = (freq - 5170) / 5 + 34; + return chan; + } else { + return -1; + } +} + +int convert_channel_to_frequency(int chan) { + if (chan >= 1 & chan <= 14) { + int freq = 5 * (chan - 1) + 2412; + return freq; + } else if (chan >= 34 & chan <= 165) { + int freq = 5 * (chan - 34) + 5170; + return freq; + } else { + return -1; + } +} + CLICK_ENDDECLS EXPORT_ELEMENT(OdinAgent) From d2903ba842a0de2b9d29a6e1ef6b9aec34cae095 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Tue, 8 Nov 2016 17:35:13 +0100 Subject: [PATCH 07/14] MobilityManager: Avoid FAIL messages: Do not change the channel if the AP is in the same channel. --- src/odinagent.cc | 45 ++++++++++++++++++++++++--------------------- src/odinagent.hh | 6 +++++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index e5da101..9c54611 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -112,8 +112,9 @@ OdinAgent::configure(Vector &conf, ErrorHandler *errh) _interval_ms_default = 100; // BI for normal mode _interval_ms_burst = 10; // BI value for burst mode _interval_ms = _interval_ms_default; - _channel = 6; // Actually frequency - _new_channel = 1; // Actually frequency + _channel = 6; + _channel_aux = 11; + _new_channel = 1; _csa = false; // _csa_count_default = 10; // Wait (n+1) beacons before first channel switch announcement _csa_count = _csa_count_default; @@ -2045,8 +2046,7 @@ OdinAgent::read_handler(Element *e, void *user_data) case handler_scan_client: { int scanning_result = agent->_scanning_result; - // Scanning result - sa << agent->_scanning_result << "\n"; + sa << agent->_scanning_result << "\n"; // Scanning result fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", scanning_result); agent->_active_scanning = false;// Disable scanning break; @@ -2148,7 +2148,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } break; } - case handler_channel: { // Modified, now it change the physical channel + case handler_channel: { int channel; int frequency; if (Args(agent, errh).push_back_words(str) @@ -2157,13 +2157,12 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa { return -1; } - frequency = convert_channel_to_frequency(channel); + frequency = agent->convert_channel_to_frequency(channel); agent->_channel = channel; if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Changing AP to channel %i\n", channel); std::stringstream ss; - // Set channel to wlan0 - ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; + ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; // Set channel to wlan0 std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); @@ -2392,13 +2391,15 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); - frequency = convert_channel_to_frequency(channel); - // Set channel to scan in wlan1 (auxiliary) - ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; - std::string str = ss.str(); - char *cstr = new char[str.length() + 1]; - strcpy(cstr, str.c_str()); - system(cstr); + if (agent->_channel_aux != channel) { + frequency = agent->convert_channel_to_frequency(channel); + agent->_channel_aux = channel; + ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; // Set channel to scan in wlan1 (auxiliary) + std::string str = ss.str(); + char *cstr = new char[str.length() + 1]; + strcpy(cstr, str.c_str()); + system(cstr); + } fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing // Enable scanning (FIXME: time to begin this action) agent->_active_scanning = true; @@ -2590,11 +2591,12 @@ void misc_thread(Timer *timer, void *data){ } /*Miscellaneous*/ -int convert_frequency_to__channel(int freq) { - if (freq >= 2412 & freq <= 2484) { +int +OdinAgent::convert_frequency_to__channel(int freq) { + if (freq >= 2412 && freq <= 2484) { int chan = (freq - 2412) / 5 + 1; return chan; - } else if (freq >= 5170 & freq <= 5825) { + } else if (freq >= 5170 && freq <= 5825) { int chan = (freq - 5170) / 5 + 34; return chan; } else { @@ -2602,11 +2604,12 @@ int convert_frequency_to__channel(int freq) { } } -int convert_channel_to_frequency(int chan) { - if (chan >= 1 & chan <= 14) { +int +OdinAgent::convert_channel_to_frequency(int chan) { + if (chan >= 1 && chan <= 14) { int freq = 5 * (chan - 1) + 2412; return freq; - } else if (chan >= 34 & chan <= 165) { + } else if (chan >= 34 && chan <= 165) { int freq = 5 * (chan - 34) + 5170; return freq; } else { diff --git a/src/odinagent.hh b/src/odinagent.hh index c1f2890..c553538 100644 --- a/src/odinagent.hh +++ b/src/odinagent.hh @@ -54,7 +54,9 @@ public: void add_handlers(); void run_timer(Timer *timer); void push(int, Packet *); - + /*Miscellaneous*/ + int convert_frequency_to__channel(int freq); + int convert_channel_to_frequency(int chan); // Extend this struct to add // new per-sta VAP state @@ -178,6 +180,7 @@ public: int _interval_ms_default; // Beacon interval: normal mode timer int _interval_ms_burst; // Beacon interval: burst mode timer, used during channel switch int _channel; // Channel to be shared by all VAPs. + int _channel_aux; // Channel to be used for scanning. int _new_channel; // New channel for CSA bool _csa; // For channel switch announcement int _count_csa_beacon; // For channel switch announcement @@ -209,6 +212,7 @@ private: int _tx_rate; int _tx_power; int _hidden; + }; From 6f4a32478c423e224356bf04014fc516a08327a5 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Thu, 10 Nov 2016 11:56:06 +0100 Subject: [PATCH 08/14] MobilityManager: Do not scan if we are scanning a previous STA. --- src/odinagent.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index 9c54611..8240630 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -2380,6 +2380,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa case handler_scan_client: { // need testing EtherAddress sta_mac; std::stringstream ss; + char *cstr = new char[str.length() + 1]; int channel; int frequency; if (Args(agent, errh).push_back_words(str) @@ -2391,20 +2392,21 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); + frequency = agent->convert_channel_to_frequency(channel); + ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; // Set channel to scan in wlan1 (auxiliary) + std::string str = ss.str(); + strcpy(cstr, str.c_str()); if (agent->_channel_aux != channel) { - frequency = agent->convert_channel_to_frequency(channel); agent->_channel_aux = channel; - ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; // Set channel to scan in wlan1 (auxiliary) - std::string str = ss.str(); - char *cstr = new char[str.length() + 1]; - strcpy(cstr, str.c_str()); system(cstr); } fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing - // Enable scanning (FIXME: time to begin this action) - agent->_active_scanning = true; - agent->_scanned_sta_mac = sta_mac; - agent->_scanning_result = 0; + if (agent->_active_scanning != true) { // Do not scan if we are scanning a previous STA + // Enable scanning (FIXME: time to begin this action) + agent->_active_scanning = true; + agent->_scanned_sta_mac = sta_mac; + agent->_scanning_result = 0; + } break; } From 584261cc0aa517e66a760247d2cc8d60c4b81d66 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Thu, 10 Nov 2016 13:44:50 +0100 Subject: [PATCH 09/14] MobilityManager: Update start.sh --- scripts_start_ap_odin/start.sh | 28 +++++++++++++++++----------- src/odinagent.cc | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts_start_ap_odin/start.sh b/scripts_start_ap_odin/start.sh index 22e56d0..3ed0f42 100644 --- a/scripts_start_ap_odin/start.sh +++ b/scripts_start_ap_odin/start.sh @@ -9,12 +9,12 @@ VSCTL="ovs-vsctl" ## Setting interfaces echo "Setting interfaces" -ifconfig wlan0 down # Main interface -ifconfig wlan1 down # Auxiliary interface +ifconfig wlan0 down +ifconfig wlan1 down iw phy phy0 interface add mon0 type monitor iw phy phy1 interface add mon1 type monitor iw phy phy0 set retry short 4 -iw phy phy1 set retry short 4 +#iw dev wlan0 set channel 1 ifconfig mon0 up ifconfig mon1 up ifconfig wlan0 up @@ -27,9 +27,17 @@ route add -net 155.210.156.0 netmask 255.255.255.0 gw 155.210.157.254 eth0 #route del default gw 155.210.157.254 #route add default gw 192.168.1.131 -## We assume that OpenvSwitch runs when OpenWRT starts up -echo "Restarting OpenvSwitch daemon" +## Mount USB +echo "Mounting USB" +if [ ! -d "/mnt/usb" ]; then + mkdir -p /mnt/usb +fi +mount /dev/sda1 /mnt/usb/ + +## OVS +echo "Restarting OpenvSwitch" /etc/init.d/openvswitch stop +sleep 1 echo "Cleaning DB" if [ -d "/etc/openvswitch" ]; then rm -r /etc/openvswitch @@ -43,8 +51,8 @@ fi if [ -f "/var/run/ovs-vswitchd.pid" ]; then rm /var/run/ovs-vswitchd.pid fi +echo "Lanching OVS" /etc/init.d/openvswitch start -echo "Configuring OpenvSwitch" $VSCTL add-br $SW # Create the bridge ifconfig $SW up # In OpenWrt 15.05 the bridge is created down $VSCTL set-controller $SW tcp:$CTLIP:6633 # Configure the OpenFlow Controller. @@ -55,15 +63,13 @@ for i in $DPPORTS ; do # Including ports to OVS done ## Launch click -echo "Mounting USB" # Because we have click into the USB -if [ ! -d "/mnt/usb" ]; then - mkdir -p /mnt/usb -fi -mount /dev/sda1 /mnt/usb/ +echo "Lanching Click" cd /mnt/usb sleep 1 ./click aagent9.cli & sleep 1 +# Add ap to OVS +echo "Adding Click interface to OVS" ifconfig ap up # Adding ap interface (click Interface) to OVS $VSCTL add-port $SW ap sleep 1 diff --git a/src/odinagent.cc b/src/odinagent.cc index 8240630..8aa554c 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -2422,7 +2422,7 @@ OdinAgent::add_handlers() add_read_handler("channel", read_handler, handler_channel); add_read_handler("interval", read_handler, handler_interval); add_read_handler("rxstats", read_handler, handler_rxstat); - add_read_handler("txstats", read_handler, handler_txstat); + add_read_handler("txstats", read_handler, handler_txstat); add_read_handler("subscriptions", read_handler, handler_subscriptions); add_read_handler("debug", read_handler, handler_debug); add_read_handler("report_mean", read_handler, handler_report_mean); From cec6afcb31968ef63d5d991c66a21a9f40daa199 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Thu, 10 Nov 2016 18:15:32 +0100 Subject: [PATCH 10/14] MobilityManager: Logs for testing. --- src/odinagent.cc | 15 +++++++-------- src/odinagent.hh | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index 8aa554c..79bf01a 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -1687,8 +1687,7 @@ OdinAgent::push(int port, Packet *p) } } - else if (port == 2) { - // if port == 2, paket is coming from the lower layer (from scanning device) + else if (port == 2) { // if port == 2, packet is coming from the lower layer (from scanning device) if (_active_scanning) { if (p->length() < sizeof(struct click_wifi)) { @@ -1714,6 +1713,7 @@ OdinAgent::push(int port, Packet *p) // stat._packets++; // stat._last_received.assign_now(); _scanning_result = ceh->rssi + _signal_offset; // FIXME: cook this value + fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Last power seen: --> %i\n", _scanning_result); } } } @@ -2162,11 +2162,11 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Changing AP to channel %i\n", channel); std::stringstream ss; - ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; // Set channel to wlan0 + ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; std::string str = ss.str(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); - system(cstr); + system(cstr); // Set channel to wlan0 system("sleep 2 && iw dev wlan0 info &"); break; } @@ -2393,17 +2393,16 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); frequency = agent->convert_channel_to_frequency(channel); - ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; // Set channel to scan in wlan1 (auxiliary) + ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; std::string str = ss.str(); strcpy(cstr, str.c_str()); if (agent->_channel_aux != channel) { agent->_channel_aux = channel; - system(cstr); + system(cstr); // Set channel to scan in wlan1 (auxiliary) } fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing if (agent->_active_scanning != true) { // Do not scan if we are scanning a previous STA - // Enable scanning (FIXME: time to begin this action) - agent->_active_scanning = true; + agent->_active_scanning = true; // Enable scanning (FIXME: time to begin this action) agent->_scanned_sta_mac = sta_mac; agent->_scanning_result = 0; } diff --git a/src/odinagent.hh b/src/odinagent.hh index c553538..a0f8def 100644 --- a/src/odinagent.hh +++ b/src/odinagent.hh @@ -54,6 +54,7 @@ public: void add_handlers(); void run_timer(Timer *timer); void push(int, Packet *); + /*Miscellaneous*/ int convert_frequency_to__channel(int freq); int convert_channel_to_frequency(int chan); From 36d7e03dfa9f2add1bf43761e2ba244b594fab10 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Fri, 18 Nov 2016 13:33:27 +0100 Subject: [PATCH 11/14] MobilityManager: Minor change in handler_scan_client. --- src/odinagent.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index 79bf01a..f5367a9 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -2393,7 +2393,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); frequency = agent->convert_channel_to_frequency(channel); - ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency; + ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency << " &"; std::string str = ss.str(); strcpy(cstr, str.c_str()); if (agent->_channel_aux != channel) { From 61235d3d4393abd706d2530fe8cd3342e4e252b5 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Mon, 28 Nov 2016 12:17:05 +0100 Subject: [PATCH 12/14] MobilityManager: Minor changes. --- src/odinagent.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index f5367a9..aa9b43d 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -42,7 +42,7 @@ int THRESHOLD_OLD_STATS = 30; //timer interval [sec] after which the stats of ol int RESCHEDULE_INTERVAL_GENERAL = 35; //time interval [sec] after which general_timer will be rescheduled int RESCHEDULE_INTERVAL_STATS = 60; //time interval [sec] after which general_timer will be rescheduled int THRESHOLD_REMOVE_LVAP = 80; //time interval [sec] after which an lvap will be removed if we didn't hear from the client -uint32_t THRESHOLD_PUBLISH_SENT = 100000; //time interval [usec] after which a publish message can be sent again. e.g. THRESHOLD_PUBLISH_SENT = 100000 means 0.1seconds +uint32_t THRESHOLD_PUBLISH_SENT = 1000000; //time interval [usec] after which a publish message can be sent again. e.g. THRESHOLD_PUBLISH_SENT = 100000 means 0.1seconds int MULTICHANNEL_AGENTS = 0; //Odin environment with agents in several channels OdinAgent::OdinAgent() @@ -1688,7 +1688,8 @@ OdinAgent::push(int port, Packet *p) } else if (port == 2) { // if port == 2, packet is coming from the lower layer (from scanning device) - if (_active_scanning) { + //if (_active_scanning) { + if (true) { if (p->length() < sizeof(struct click_wifi)) { p->kill(); @@ -1840,7 +1841,7 @@ OdinAgent::match_against_subscriptions(StationStats stats, EtherAddress src) } } - if (matched) { + if (matched) { // && (_active_scanning == false) if (sub.sta_addr != EtherAddress()) { // It is a specific subscription for a single MAC (not '*') // Calculate the time since the last publish was sent @@ -2402,7 +2403,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing if (agent->_active_scanning != true) { // Do not scan if we are scanning a previous STA - agent->_active_scanning = true; // Enable scanning (FIXME: time to begin this action) + agent->_active_scanning = false; // Enable scanning (FIXME: time to begin this action) agent->_scanned_sta_mac = sta_mac; agent->_scanning_result = 0; } From 4315204083562b5d87a100c1e6f623dae55521b2 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Mon, 9 Jan 2017 11:55:49 +0100 Subject: [PATCH 13/14] MobilityManager: Tuning scan_client handlers for testing. --- src/odinagent.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index aa9b43d..d751c5e 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -113,7 +113,7 @@ OdinAgent::configure(Vector &conf, ErrorHandler *errh) _interval_ms_burst = 10; // BI value for burst mode _interval_ms = _interval_ms_default; _channel = 6; - _channel_aux = 11; + _channel_aux = 0; // Initialized in 0, so it will change the channel the first time _new_channel = 1; _csa = false; // _csa_count_default = 10; // Wait (n+1) beacons before first channel switch announcement @@ -1463,7 +1463,7 @@ OdinAgent::update_rx_stats(Packet *p) } /** - * This element has two input ports and 4 output ports. + * This element has three input ports and 4 output ports. * * In-port-0: Any 802.11 encapsulated frame. Expected * to be coming from a physical device @@ -1688,8 +1688,8 @@ OdinAgent::push(int port, Packet *p) } else if (port == 2) { // if port == 2, packet is coming from the lower layer (from scanning device) - //if (_active_scanning) { - if (true) { + if (_active_scanning) { + //if (false) { // For testing if (p->length() < sizeof(struct click_wifi)) { p->kill(); @@ -2400,12 +2400,13 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa if (agent->_channel_aux != channel) { agent->_channel_aux = channel; system(cstr); // Set channel to scan in wlan1 (auxiliary) + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Setting channel to scan in auxiliary interface \n"); // for testing } fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing if (agent->_active_scanning != true) { // Do not scan if we are scanning a previous STA - agent->_active_scanning = false; // Enable scanning (FIXME: time to begin this action) - agent->_scanned_sta_mac = sta_mac; agent->_scanning_result = 0; + agent->_scanned_sta_mac = sta_mac; + agent->_active_scanning = true; // Enable scanning (FIXME: time to begin this action) } break; } From b8591ba228f63427f1c5ea74680bd859868d04d1 Mon Sep 17 00:00:00 2001 From: luissequeira Date: Tue, 24 Jan 2017 16:25:05 +0100 Subject: [PATCH 14/14] MobilityManager: Re-write scan_client handlers. --- src/odinagent.cc | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/odinagent.cc b/src/odinagent.cc index d751c5e..9394ebe 100644 --- a/src/odinagent.cc +++ b/src/odinagent.cc @@ -1689,9 +1689,12 @@ OdinAgent::push(int port, Packet *p) else if (port == 2) { // if port == 2, packet is coming from the lower layer (from scanning device) if (_active_scanning) { - //if (false) { // For testing + //if (true) { // For testing + + //fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Scanning activated \n"); if (p->length() < sizeof(struct click_wifi)) { + //fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Scanning activated --> killing packet \n"); p->kill(); return; } @@ -1699,6 +1702,7 @@ OdinAgent::push(int port, Packet *p) struct click_wifi *w = (struct click_wifi *) p->data(); EtherAddress src = EtherAddress(w->i_addr2); if (src == _scanned_sta_mac) { + //fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Scanning activated --> found packet for %s\n", src.unparse_colon().c_str()); // Get station statistics struct click_wifi_extra *ceh = WIFI_EXTRA_ANNO(p); // StationStats stat; @@ -1714,8 +1718,10 @@ OdinAgent::push(int port, Packet *p) // stat._packets++; // stat._last_received.assign_now(); _scanning_result = ceh->rssi + _signal_offset; // FIXME: cook this value - fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Last power seen: --> %i\n", _scanning_result); + //fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Last power seen: --> %i\n", _scanning_result); } + //_scanning_result = 200; // For testing + //fprintf(stderr, "[Odinagent.cc] ########### Scanning packets: Last power seen: --> %i\n", _scanning_result); // For testing } } @@ -2046,10 +2052,9 @@ OdinAgent::read_handler(Element *e, void *user_data) } case handler_scan_client: { - int scanning_result = agent->_scanning_result; - sa << agent->_scanning_result << "\n"; // Scanning result - fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", scanning_result); + sa << agent->_scanning_result << "\n"; // Scanned result agent->_active_scanning = false;// Disable scanning + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Sending scan results %i\n", agent->_scanning_result); break; } @@ -2152,6 +2157,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa case handler_channel: { int channel; int frequency; + StringAccum sa; if (Args(agent, errh).push_back_words(str) .read_mp("CHANNEL", channel) .complete() < 0) @@ -2162,12 +2168,8 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa agent->_channel = channel; if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Changing AP to channel %i\n", channel); - std::stringstream ss; - ss << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; - std::string str = ss.str(); - char *cstr = new char[str.length() + 1]; - strcpy(cstr, str.c_str()); - system(cstr); // Set channel to wlan0 + sa << "hostapd_cli -i wlan0 chan_switch " << agent->_count_csa_beacon_default << " " << frequency; + system(sa.c_str()); // Set channel to wlan0 system("sleep 2 && iw dev wlan0 info &"); break; } @@ -2380,33 +2382,31 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa } case handler_scan_client: { // need testing EtherAddress sta_mac; - std::stringstream ss; - char *cstr = new char[str.length() + 1]; - int channel; + int scan_channel; int frequency; - if (Args(agent, errh).push_back_words(str) - .read_mp("STA_MAC", sta_mac) - .read_mp("CHANNEL", channel) + StringAccum sa; + Args args = Args(agent, errh).push_back_words(str); + if (args.read_mp("STA_MAC", sta_mac) + .read_mp("CHANNEL", scan_channel) .complete() < 0) { return -1; } if (agent->_debug_level % 10 > 0) fprintf(stderr, "[Odinagent.cc] ########### Scanning for client %s\n", sta_mac.unparse_colon().c_str()); - frequency = agent->convert_channel_to_frequency(channel); - ss << "hostapd_cli -i wlan1 chan_switch 1 " << frequency << " &"; - std::string str = ss.str(); - strcpy(cstr, str.c_str()); - if (agent->_channel_aux != channel) { - agent->_channel_aux = channel; - system(cstr); // Set channel to scan in wlan1 (auxiliary) + frequency = agent->convert_channel_to_frequency(scan_channel); + sa << "hostapd_cli -i wlan1 chan_switch 0 " << frequency << " &"; + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", sa.c_str()); // for testing + if (agent->_channel_aux != scan_channel) { + agent->_channel_aux = scan_channel; + system(sa.c_str()); // Set channel to scan in wlan1 (auxiliary) fprintf(stderr, "[Odinagent.cc] ########### Scanning: Setting channel to scan in auxiliary interface \n"); // for testing } - fprintf(stderr, "[Odinagent.cc] ########### Scanning: Testing command line --> %s\n", cstr); // for testing if (agent->_active_scanning != true) { // Do not scan if we are scanning a previous STA agent->_scanning_result = 0; agent->_scanned_sta_mac = sta_mac; agent->_active_scanning = true; // Enable scanning (FIXME: time to begin this action) + fprintf(stderr, "[Odinagent.cc] ########### Scanning: Setting scanning --> true \n"); // for testing } break; }