gymwipe.networking.messages module¶
The messages module provides classes for network packet representations and inter-module communication.
The following classes are used for transmission simulation:
Transmittable(value[, byteSize]) |
The Transmittable class provides a byteSize attribute allowing the simulated sending of Transmittable objects via a frequency band. |
FakeTransmittable(byteSize) |
A Transmittable implementation that sets its value to None. |
Packet(header, payload[, trailer]) |
The Packet class represents packets. |
SimpleMacHeader(sourceMAC, destMAC, flag) |
A class for representing MAC packet headers |
SimpleNetworkHeader(sourceMAC, destMAC) |
Since no network protocol is implemented in Gym-WiPE, there is a need for some interim way to specify source and destination addresses in packets that are passed to the SimpleMAC layer. |
The following classes are used for inter-module communication:
Message(type[, args]) |
A class used for the exchange of arbitrary messages between components. |
StackMessageTypes |
An enumeration of control message types to be used for the exchange of Message objects between network stack layers. |
-
class
Transmittable(value, byteSize=None)[source]¶ Bases:
objectThe
Transmittableclass provides abyteSizeattribute allowing the simulated sending ofTransmittableobjects via a frequency band.Parameters: - value (
Any) – The object of which the string representation will be used - byteSize – The number of bytes that are simulated to be transmitted
when the data represented by this
Transmittableis sent via a frequency band. Defaults to the length of the UTF-8 encoding of str(value).
-
transmissionTime(bitrate)[source]¶ Returns the time in seconds needed to transmit the data represented by the
Transmittableat the specified bit rate.Parameters: bitrate ( float) – The bitrate in bpsReturn type: float
- value (
-
class
FakeTransmittable(byteSize)[source]¶ Bases:
gymwipe.networking.messages.TransmittableA
Transmittableimplementation that sets its value to None. It can be helpful for test applications when the data itself is irrelevant and only its size has to be considered.Parameters: byteSize ( int) – The number of bytes that theFakeTransmittablerepresents
-
class
Packet(header, payload, trailer=None)[source]¶ Bases:
gymwipe.networking.messages.TransmittableThe Packet class represents packets. A Packet consists of a header, a payload and an optional trailer. Packets can be nested by providing them as payloads to the packet constructor.
-
header[source]¶ The object representing the Packet’s header
Type: Transmittable
-
payload[source]¶ The object representing the Packet’s payload. Might be another
Packet.Type: Transmittable
-
trailer[source]¶ The object representing the Packet’s trailer (defaults to
None)Type: Transmittable
-
-
class
SimpleMacHeader(sourceMAC, destMAC, flag)[source]¶ Bases:
gymwipe.networking.messages.TransmittableA class for representing MAC packet headers
-
class
SimpleNetworkHeader(sourceMAC, destMAC)[source]¶ Bases:
gymwipe.networking.messages.TransmittableSince no network protocol is implemented in Gym-WiPE, there is a need for some interim way to specify source and destination addresses in packets that are passed to the
SimpleMAClayer. Therefore, aSimpleNetworkHeaderholds a source and a destination MAC address. The destination address is used by theSimpleMAClayer.
-
class
Message(type, args=None)[source]¶ Bases:
objectA class used for the exchange of arbitrary messages between components. A
Messagecan be used to simulate both asynchronous and synchronous function calls.-
eProcessed[source]¶ A SimPy event that is triggered when
setProcessed()is called. This is useful for simulating synchronous function calls and also allows for return values (an example is provided insetProcessed()).Type: Event
-
setProcessed(returnValue=None)[source]¶ Makes the
eProcessedevent succeed.Parameters: returnValue ( Optional[Any]) – If specified, will be used as the value of theeProcessedevent.Examples
If returnValue is specified, SimPy processes can use Signals for simulating synchronous function calls with return values like this:
signal = Signal(myType, {"key", value}) gate.output.send(signal) value = yield signal.eProcessed # value now contains the returnValue that setProcessed() was called with
-