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.ModuleA 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
Messageobjects with the followingStackMessageTypes:-
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
GateListenerdecorator. It is processed when the module’s macInGatereceives an object.
-
-
class
SimpleMac(name, device, frequencyBandSpec, addr)[source]¶ Bases:
gymwipe.networking.construction.ModuleA 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
0is 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
SimpleMacHeaderhaving the following attributes:The packet’s
payloadis the number n mentioned above (wrapped inside aTransmittable)Every other packet sent has a
SimpleMacHeaderwithflag0.
The networkIn gate accepts objects of the following types:
-
Types:
-
Listen for packets sent to this device.
Messageargs:duration: The time in seconds to listen for When a packet destinated to this device is received, the
eProcessedevent of theMessagewill 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 withNone.
-
-
Send a given packet (with a
SimpleNetworkHeader) to the MAC address defined in the header.
The phyIn gate accepts objects of the following types:
-
A packet received by the physical layer
Parameters: -
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
GateListenerdecorator. It is processed when the module’s phyInGatereceives an object.
-
networkInHandler()[source]¶ A method which is decorated with the
GateListenerdecorator. It is invoked when the module’s networkInGatereceives an object.
-
class
SimpleRrmMac(name, device, frequencyBandSpec)[source]¶ Bases:
gymwipe.networking.construction.ModuleThe RRM implementation of the protocol described in
SimpleMacThe networkIn gate accepts objects of the following types:
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.
-
phyInHandler()[source]¶ A method which is decorated with the
GateListenerdecorator. It is invoked when the module’s phyInGatereceives an object.
-
networkInHandler()[source]¶ A method which is decorated with the
GateListenerdecorator. It is invoked when the module’s networkInGatereceives an object.
-