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 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
GateListener
decorator. It is processed when the module’s macInGate
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:The packet’s
payload
is the number n mentioned above (wrapped inside aTransmittable
)Every other packet sent has a
SimpleMacHeader
withflag
0
.
The networkIn gate accepts objects of the following types:
-
Types:
-
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 theMessage
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 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
GateListener
decorator. It is processed when the module’s phyInGate
receives an object.
-
networkInHandler
()[source]¶ A method which is decorated with the
GateListener
decorator. It is invoked when the module’s networkInGate
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:
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
GateListener
decorator. It is invoked when the module’s phyInGate
receives an object.
-
networkInHandler
()[source]¶ A method which is decorated with the
GateListener
decorator. It is invoked when the module’s networkInGate
receives an object.
-