gymwipe.networking.devices module

Device implementations for network devices

class NetworkDevice(name, xPos, yPos, frequencyBand)[source]

Bases: gymwipe.devices.core.Device

A subclass of Device that extends the constructor’s parameter list by a frequencyBand argument. The provided FrequencyBand object will be stored in the frequencyBand attribute.

Parameters:
  • name (str) – The device name
  • xPos (float) – The device’s physical x position
  • yPos (float) – The device’s physical y position
  • band (frequency) – The FrequencyBand instance that will be used for transmissions
frequencyBand = None[source]

The FrequencyBand instance that is used for transmissions

Type:FrequencyBand
class SimpleNetworkDevice(name, xPos, yPos, frequencyBand)[source]

Bases: gymwipe.networking.devices.NetworkDevice

A NetworkDevice implementation running a network stack that consists of a SimplePHY and a SimpleMAC. It offers a method for sending a packet using the MAC layer, as well as a callback method that will be invoked when a packet is received. Also, receiving can be turned on or of by setting receiving either to True or to False.

Parameters:
  • name (str) – The device name
  • xPos (float) – The device’s physical x position
  • yPos (float) – The device’s physical y position
  • band (frequency) – The FrequencyBand instance that will be used for transmissions
macAddr = None[source]

The address that is used by the MAC layer to identify this device

Type:bytes
RECEIVE_TIMEOUT = 100[source]

The timeout in seconds for the simulated blocking MAC layer receive call

Type:int
receiving[source]
Return type:bool
send(data, destinationMacAddr)[source]
onReceive(packet)[source]

This method is invoked whenever receiving is True and a packet has been received.

Note

After receiving has been set to False it might still be called within RECEIVE_TIMEOUT seconds.

Parameters:packet (Packet) – The packet that has been received
class SimpleRrmDevice(name, xPos, yPos, frequencyBand, deviceIndexToMacDict, interpreter)[source]

Bases: gymwipe.networking.devices.NetworkDevice

A Radio Resource Management NetworkDevice implementation. It runs a network stack consisting of a SimplePHY and a SimpleRrmMAC. It offers a method for frequency band assignment and operates an Interpreter instance that provides observations and rewards for a learning agent.

Parameters:
  • name (str) – The device name
  • xPos (float) – The device’s physical x position
  • yPos (float) – The device’s physical y position
  • band (frequency) – The FrequencyBand instance that will be used for transmissions
  • deviceIndexToMacDict (Dict[int, bytes]) – A dictionary mapping integer indexes to device MAC addresses. This allows to pass the device index used by a learning agent instead of a MAC address to assignFrequencyBand().
  • interpreter (Interpreter) – The Interpreter instance to be used for observation and reward calculations
interpreter = None[source]

The Interpreter instance that provides domain-specific feedback on the consequences of assignFrequencyBand() calls

Type:Interpreter
deviceIndexToMacDict = None[source]

A dictionary mapping integer indexes to device MAC addresses. This allows to pass the device index used by a learning agent instead of a MAC address to assignFrequencyBand().

macToDeviceIndexDict = None[source]

The counterpart to deviceIndexToMacDict

macAddr[source]

The RRM’s MAC address

Type:bytes
Return type:bytes
assignFrequencyBand(deviceIndex, duration)[source]

Makes the RRM assign the frequency band to a certain device for a certain time.

Parameters:
  • deviceIndex (bytes) – The integer id that maps to the MAC address of the device to assign the frequency band to (see deviceIndexToMacDict)
  • duration (int) – The number of time units for the frequency band to be assigned to the device
Return type:

Tuple[Any, float]

Returns:

The Signal object that was used to make the RRM MAC layer assign the frequency band. When the frequency band assignment is over, the signal’s eProcessed event will succeed.