#include <uan-mac.h>
Inheritance diagram for UanMac:
Public Member Functions | |
UanMac () | |
Creates UAN Mac. | |
virtual void | recv (Packet *p, Handler *h) |
Standard NS2 recv method. | |
virtual void | send (Packet *p, Handler *h) |
Starts send algorithm for packet p. | |
virtual int | command (int argc, const char *const *argv) |
NS2 command method. | |
virtual void | transStateChange (int s) |
Reports change of phy to new state s, which is of type UanPhy::TransState. | |
double | bw () |
Returns bandwidth. | |
Protected Member Functions | |
void | startSendTimer (void) |
Randomly picks slot inside CW and starts sendTimer. | |
void | debugf (char *fmt,...) |
Method to output debug messages to stderr. | |
Static Protected Member Functions | |
static void | sendHandler (void *) |
Method that is called when timer sendTimer expires. Sends packet pktTx. | |
Protected Attributes | |
int | CW |
The Contention window. | |
double | slotSize |
Slot time in seconds. | |
double | bandwidth |
Bandwidth in bits/second. | |
bool | useCS |
Boolean wether to use carrier sensing. | |
UanEventTimer * | sendTimer |
Timer used to count down backoff time until send. | |
double | sendTime |
Member used to save send time when timer is paused (-1 if no time saved). | |
Packet * | pktTx |
Pointer to packet awaiting transmission. | |
Handler * | hanTx |
Handler to call when pktTx is transmitted (notifies queue that we are done with pktTx). | |
UanPhy * | phy |
Link to UanPhy. | |
Friends | |
class | UanEventTimer |
Structure: In the UAN framwork the MAC only receives complete packets. Unlike standard NS2, collisions are detected and handled in the PHY layer. This is designed to allow for easier MAC development and simulation.
This is a simple but complete MAC class that uses a backoff algorithm similar (but much simpler) to IEEE 802.11. When there is a packet to send, a node chooses a slot, S between 0 and CW-1. A counter is then set to S*SlotSize. Whenever the channel is perceived to be idle, the counter runs. If the channel is perceived to be busy (either Carrier sensed busy or this node is currently in the RX state), the counter is paused. When the counter reaches 0, the node transmits.
This class depends on the PHY layer being a UanPhy class
void UanMac::recv | ( | Packet * | p, | |
Handler * | h | |||
) | [virtual] |
Standard NS2 recv method.
p | Packet being received at layer | |
h | Handler to call if packet is moving down the stack when MAC is done with packet |
Reimplemented in UanMacPAloha.
void UanMac::send | ( | Packet * | p, | |
Handler * | h | |||
) | [virtual] |
Starts send algorithm for packet p.
p | Pointer to Packet to send | |
h | Pointer to Handler to call handle function of when packet is sent This MAC only has a single packet buffer, so if a packet is already waiting to be sent, then the new packet p will be freed and the handler h called. |
Reimplemented in UanMacPAloha.
int UanMac::command | ( | int | argc, | |
const char *const * | argv | |||
) | [virtual] |
NS2 command method.
argc | Number of arguments | |
argv | Array of C String commands/arguments |