Reputation: 5167
I want to simulate a simple TDMA protocol for underwater communication networks, where each node transmits at a regular intervals. How do I implement this in UnetStack?
The UnetStack document on MAC gives examples of Simple and Throttled MAC protocols, but how can I get the nodes to transmit at a regular interval?
Upvotes: 2
Views: 253
Reputation: 1137
A typical agent written using UnetStack can add new behaviors to itself.
In order to transmit at regular intervals as required by a node in TDMA like protocol, your agent can instruct the PHY agent to transmit regularly. This can be implemented using ticker behaviour.
A TickerBehavior runs repeatedly with a specified delay between invocations. A TickerBehavior can be added to your agent with this code:
add new TickerBehavior(1000*slotlength, {
phy << new TxFrameReq(to: nodeAddress, type: Physical.DATA)
})
where slotlength
is in seconds and nodeAddress
is the address of the node you are trying to transmit the information to. For more information on TxFrameReq you can check out the documentation.
Upvotes: 2