I am trying to implement a simple turn taking (TTP) MAC protocol based upon the csma-net-device.cc. Each node takes turns to transmit data. Turn order is pre-determined and a station only transmits when it receives(hears) a packet from its predecessor in that order list. However, when I compare my TTP flowmon results to the example csma flowmon results, there is no significant difference between the two protocols in throughput or average delay. I have tried many simulations with a range of nodes (2, 5, 10,15, 20, 30). Is my implementation correct?
The topology is:
-------------------------------------------------------
| | | | |
n1 n2 n3 n4 n5
Assumptions are that the network is fully connected (all stations can hear each other's transmissions, whether they are intended destination or not) and equidistant from each other (propagation delay is the same for all paths).
For simplicity, I have assigned n1 to n5 IP addresses 10.0.0.1 to 10.0.0.5 respectively. I also assume that the MAC address of these nodes will be 00:00:00:00:00:01 to 00:00:00:00:00:05 respectively.
The protocol (for 5 nodes) is such that:
10.0.0.1 transmits a queued packet to 10.0.0.2;
Once 10.0.0.2 receives from 10.0.0.1, it transmits a queued packet to 10.0.0.3
Once 10.0.0.3 receives from 10.0.0.2, it transmits a queued packet to 10.0.0.4
...
Once 10.0.0.5 receives from 10.0.0.4, it transmits queued packets to 10.0.0.1
If a station does not have a queued packet and its turn arrives, a dummy packet based on the last queued packet is sent instead to the correct MAC address to continue the circle.
The question is, is my pseudocode implementation correct?
SendFrom()
...
enqueue packet passed by ipv4 interface
if (first packet in simulation)
...
TransmitStart()
return;
TransmitStart() etc. unchanged. Only TransmitReadyEvent() changed. Removed code that retrieves next packet in queue and transmits.
Receive()
...
if (current device address == destination address on header)
if (queue is empty)
create dummy packet with suitable header
send dummy packet
else
dequeue next packet and transmit (just like the TransmitReady Event)
return;
I will upload the source code and results later. Any insight would be helpful. Thanks.