gymwipe.networking.simple_stack module

The simple_stack package contains basic network stack layer implementations. Layers are modelled by gymwipe.networking.construction.Module objects.

TIME_SLOT_LENGTH = 1e-06[source]

The length of one time slot in seconds (used for simulating slotted time)

Type:float
class SimplePhy(name, device, frequencyBand)[source]

Bases: gymwipe.networking.construction.Module

A physical layer implementation that does not take propagation delays into account. It provides a port called mac to be connected to a mac layer. Slotted time is used, with the length of a time slot being defined by TIME_SLOT_LENGTH.

During simulation the frequency band is sensed and every successfully received packet is sent via the macOut gate.

The macIn gate accepts Message objects with the following StackMessageTypes:

  • SEND

    Send a specified packet on the frequency band.

    Message args:

    packet:The Packet object representing the packet to be sent
    power:The transmission power in dBm
    mcs:The Mcs object representing the MCS for the transmission
NOISE_POWER_DENSITY = 4.0454699999999995e-21[source]

The receiver’s noise power density in Watts/Hertz

Type:float
macInHandler()[source]

A SimPy process method which is decorated with the GateListener decorator. It is processed when the module’s macIn Gate receives an object.

class SimpleMac(name, device, frequencyBandSpec, addr)[source]

Bases: gymwipe.networking.construction.Module

A MAC layer implementation of the contention-free protocol described as follows:

  • Every SimpleMac has a unique 6-byte-long MAC address.

  • The MAC layer with address 0 is considered to belong to the RRM.

  • Time slots are grouped into frames.

  • Every second frame is reserved for the RRM and has a fixed length (number of time slots).

  • The RRM uses those frames to send a short announcement containing a destination MAC address and the frame length (number of time slots n) of the following frame. By doing so it allows the specified device to use the frequency band for the next frame. Announcements are packets with a SimpleMacHeader having the following attributes:

    sourceMAC: The RRM MAC address

    destMAC: The MAC address of the device that may transmit next

    flag: 1 (flag for allowing a device to transmit)

    The packet’s payload is the number n mentioned above (wrapped inside a Transmittable)

  • Every other packet sent has a SimpleMacHeader with flag 0.

The networkIn gate accepts objects of the following types:

  • Message

    Types:

    • RECEIVE

      Listen for packets sent to this device.

      Message args:

      duration:The time in seconds to listen for

      When a packet destinated to this device is received, the eProcessed event of the Message will be triggered providing the packet as the value. If the time given by duration has passed and no packet was received, it will be triggered with None.

  • Packet

    Send a given packet (with a SimpleNetworkHeader) to the MAC address defined in the header.

The phyIn gate accepts objects of the following types:

  • Packet

    A packet received by the physical layer

Parameters:
  • name (str) – The layer’s name
  • device (Device) – The device that operates the SimpleMac layer
  • addr (bytes) – The 6-byte-long MAC address to be assigned to this MAC layer
rrmAddr = b'\x00\x00\x00\x00\x00\x00'[source]

The 6 bytes long RRM MAC address

Type:bytes
classmethod newMacAddress()[source]

A method for generating unique 6-byte-long MAC addresses (currently counting upwards starting at 1)

Return type:bytes
phyInHandler()[source]

A SimPy process method which is decorated with the GateListener decorator. It is processed when the module’s phyIn Gate receives an object.

networkInHandler()[source]

A method which is decorated with the GateListener decorator. It is invoked when the module’s networkIn Gate receives an object.

class SimpleRrmMac(name, device, frequencyBandSpec)[source]

Bases: gymwipe.networking.construction.Module

The RRM implementation of the protocol described in SimpleMac

The networkIn gate accepts objects of the following types:

StackMessageTypes:

  • ASSIGN

    Send a frequency band assignment announcement that permits a device to transmit for a certain time.

    Message args:

    dest:The 6-byte-long MAC address of the device to be allowed to transmit
    duration:The number of time steps to assign the frequency band for the specified device

The payloads of packets from other devices are outputted via the networkOut gate, regardless of their destination address. This enables an interpreter to extract observations and rewards for a frequency band assignment learning agent.

addr = None[source]

The RRM’s MAC address

Type:bytes
phyInHandler()[source]

A method which is decorated with the GateListener decorator. It is invoked when the module’s phyIn Gate receives an object.

networkInHandler()[source]

A method which is decorated with the GateListener decorator. It is invoked when the module’s networkIn Gate receives an object.