edu.cmu.emulator.wlandev
Class WLANDevice

java.lang.Object
  extended by edu.cmu.emulator.wlandev.WLANDevice
Direct Known Subclasses:
MadwifiNGDevice

public abstract class WLANDevice
extends Object


Field Summary
protected  int channel
          desired channel
private static long cmdDelayMillis
           
protected  DaemonCommunicator dComm
          the dComm on the remote node
protected  String devName
          device name
protected  EmuNode emuNode
          emuNode on which the device resides
protected  String essid
          desired essid
protected  byte[] ip
          desired device IP
protected  gmj.net.PhysicalAddress mac
          node's mac address
protected static HashMap macToEmuNodeMap
          maps mac addresses for node's wireless devices to the node's emuNode object
protected static long MSG_TIMEOUT_MILLIS
           
protected  String prefix
           
protected  double txRateMbps
          desired tx rate
protected  boolean useSudo
           
 
Constructor Summary
protected WLANDevice(EmuNode emuNode, DaemonCommunicator dComm, String devName, byte[] ip, String essid, int channel)
           
protected WLANDevice(EmuNode emuNode, DaemonCommunicator dComm, String devName, byte[] ip, String essid, int channel, boolean useSudo)
          Construct a WLANDevice.
 
Method Summary
abstract  void adHocMode(String essid, int channel)
          Sets the device into ad hoc mode with the given essid and channel.
abstract  void apMode(String essid, int channel)
          Sets the device into AP mode with the given essid and channel.
abstract  void create()
          Creates the device.
abstract  void destroy()
          Destroys the device.
 void determineMAC()
          Query the device to determine the mac.
abstract  gmj.net.PhysicalAddress getBSSID()
          Get the BSSID reported by iwconfig.
 String getDevName()
          get the name of the wireless device
static EmuNode getEmuNodeFromMAC(gmj.net.PhysicalAddress nodeMAC)
          finds the emuNode object corresponding to the given mac address
 byte[] getIP()
          Get the desired ip address of the wireless device.
 gmj.net.PhysicalAddress getMAC()
          Return the mac of the device.
abstract  int getSignalLevel()
          Get the current signal level reported by iwconfig.
 void ifconfig()
          Set the actual device ip address to the desired ip using ifconfig.
 ArrayList ifconfigToArrayList()
          Runs ifconfig and stores the results in an ArrayList.
 void iwconfig(String essid, int channel)
          Runs iwconfig on the device to set the essid and channel.
 void iwconfig(String essid, int channel, double txRateMbps)
          Runs iwconfig on the device to set the essid, channel, and txRateMbps.
 ArrayList iwconfigToArrayList()
          Runs iwconfig and stores the results in an ArrayList.
abstract  void managedMode(String essid, int channel)
          Sets the device into managed mode with the given essid and channel.
 void setTxRate(double txRateMbps)
          Runs iwconfig on the device to set the txRateMbps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dComm

protected DaemonCommunicator dComm
the dComm on the remote node


devName

protected String devName
device name


mac

protected gmj.net.PhysicalAddress mac
node's mac address


ip

protected byte[] ip
desired device IP


emuNode

protected EmuNode emuNode
emuNode on which the device resides


essid

protected String essid
desired essid


channel

protected int channel
desired channel


txRateMbps

protected double txRateMbps
desired tx rate


prefix

protected String prefix

useSudo

protected boolean useSudo

macToEmuNodeMap

protected static HashMap macToEmuNodeMap
maps mac addresses for node's wireless devices to the node's emuNode object


MSG_TIMEOUT_MILLIS

protected static final long MSG_TIMEOUT_MILLIS
See Also:
Constant Field Values

cmdDelayMillis

private static final long cmdDelayMillis
See Also:
Constant Field Values
Constructor Detail

WLANDevice

protected WLANDevice(EmuNode emuNode,
                     DaemonCommunicator dComm,
                     String devName,
                     byte[] ip,
                     String essid,
                     int channel,
                     boolean useSudo)
Construct a WLANDevice. Utilized by children of this class.

Parameters:
emuNode -
dComm -
devName -
ip -
essid -
channel -

WLANDevice

protected WLANDevice(EmuNode emuNode,
                     DaemonCommunicator dComm,
                     String devName,
                     byte[] ip,
                     String essid,
                     int channel)
Method Detail

getEmuNodeFromMAC

public static EmuNode getEmuNodeFromMAC(gmj.net.PhysicalAddress nodeMAC)
finds the emuNode object corresponding to the given mac address

Parameters:
nodeMAC - mac address of node
Returns:
emuNode for the given mac

getDevName

public String getDevName()
get the name of the wireless device

Returns:
the name of the wireless device

getIP

public byte[] getIP()
Get the desired ip address of the wireless device. ifconfig() must be called to actually set the ip.

Returns:
the desired ip address of the wireless device

ifconfig

public void ifconfig()
Set the actual device ip address to the desired ip using ifconfig.


iwconfig

public void iwconfig(String essid,
                     int channel)
Runs iwconfig on the device to set the essid and channel. The values passed in are stored in the desired essid and channel members. Existing values are overwritten.

Parameters:
essid - the essid to set
channel - the channel to set

iwconfig

public void iwconfig(String essid,
                     int channel,
                     double txRateMbps)
Runs iwconfig on the device to set the essid, channel, and txRateMbps. The values passed in are stored in the desired essid, channel, and txRateMbps members. Existing values are overwritten.

Parameters:
essid - the essid to set
channel - the channel to set
txRateMbps - the transmit rate in Mbps

setTxRate

public void setTxRate(double txRateMbps)
Runs iwconfig on the device to set the txRateMbps. The value passed in is stored in the desired txRateMbps member. The existing value is overwritten.

Parameters:
txRateMbps - the transmit rate in Mbps

determineMAC

public void determineMAC()
Query the device to determine the mac. The value is stored in the mac member. Must be called if the value of mac is to be accurate.


ifconfigToArrayList

public ArrayList ifconfigToArrayList()
Runs ifconfig and stores the results in an ArrayList. One entry for each line of ifconfig.

Returns:
the results of ifconfig. One Entry for each line.

iwconfigToArrayList

public ArrayList iwconfigToArrayList()
Runs iwconfig and stores the results in an ArrayList. One entry for each line of iwconfig.

Returns:
the results of iwconfig. One Entry for each line.

getMAC

public gmj.net.PhysicalAddress getMAC()
Return the mac of the device. Must call determineMAC() before this is called.

Returns:
the mac of the device as determined by determineMAC

apMode

public abstract void apMode(String essid,
                            int channel)
Sets the device into AP mode with the given essid and channel.

Parameters:
essid - the new essid
channel - the new channel

managedMode

public abstract void managedMode(String essid,
                                 int channel)
Sets the device into managed mode with the given essid and channel.

Parameters:
essid - the new essid
channel - the channel to begin searching on

adHocMode

public abstract void adHocMode(String essid,
                               int channel)
Sets the device into ad hoc mode with the given essid and channel.

Parameters:
essid - the new essid
channel - the new channel

create

public abstract void create()
Creates the device. Must be called before device can be used.


destroy

public abstract void destroy()
Destroys the device.


getBSSID

public abstract gmj.net.PhysicalAddress getBSSID()
Get the BSSID reported by iwconfig.

Returns:
the bssid

getSignalLevel

public abstract int getSignalLevel()
Get the current signal level reported by iwconfig. NOTE: in many cases this value is an average.



Copyright © 2013. All Rights Reserved.