wiki:WANMAC

Version 9 (modified by varunnayyar, 18 years ago) (diff)

--

Description

The WANMAC is a TDM MAC that serves as a framework for all Scheduled Access MACs. In this scheme, their is one Base Station (BS) and many Subscriber Stations (SS) forming a Star Topology. The BS broadcasts downlink and uplink maps periodically which tells a SS when would be its turn to send and receive data, as is done in 802.16 or Wimax. For the first implementation we have assumed the system to be in equilbrium i.e. no new SS`s are added to the system. Their is no notion of an ACK here and no contention issues.

This behavioral description of both BS and SS can be transformed to state-machines, which in turn can be transformed to C-code. A few typical transitions through states are numbered. For the Base Station, we have the following states:

No image "BS.bmp" attached to WANMAC

1)

2)

3)

For the Subscriber Station, the states look like the following:

No image "SS.bmp" attached to WANMAC

1)

2)

3)

The behavior described above is a small subset of that which is implemented in the attached code. Here, we bridge that state machine to a source and a sink (ethernet and OFDM physical layer respectively for a transmitter, and vice versa for a receiver). In that way, we have a project that creates a virtual wire between three WARP node, one BS and two SS. Any ethernet and higher layer traffic will be forwarded across the wireless medium.

Code

Latest Revision: basestation.c and substation.c

Note: This code relies on many external dependencies and will not compile on traditional architectures.

Documentation

When the MAC program is executed, it sets up the external devices that must be used (Ethernet, Radio and PHY, and Automatic Gain Control).

Typedefs

frameStruct

The frameStruct type is the internal representation of what information is included in the frame sent to the PHY. There is a one to one conversion between this struct and array of bytes interpreted by the PHY. This allows us to abstract away from this array structure, making our MAC's behavior independent of the header format.

pktQueueStruct

The pktQueueStruct is a structure containing an array of frameStructs and a few control bytes to keep track of indices, and the length of the queue. This queue can serve two purposes. The first use is during the receive phase of the MAC. When the MAC receives a packet from another node, it needs to put the payload somewhere. Because the specification of the connection between our MAC and higher networking layers is still in the process of being defined, we need a method of abstracting our layer away from this future glue layer. An acceptable solution is to simply copy packets from the PHY's memory space into a queue. It is assumed that another in the xilkernel will be taking these packets and giving them to higher layers. The other use of this queue is on the transmit side of the MAC. Again, the connection to the higher layer is still being defined, so we need a way of getting packets to send in the meantime. You can think of the transmit queue as analogous to the receive queue, in that some process somewhere gives us packets to send. This could be the Video Board, or eventually the ethernet controller.

dataStruct

The dataStruct contains miscellaneous control bytes for proper MAC behavior. These tell the MAC its own address, whether or not to sniff other node's packets, and whether to send and receive negative acknowledgements. Additionally, it is in this struct that the MAC keeps track of re-sends and backoff timers.

Functions

ackmac_main

This function is the primary thread spawned by the xilkernel via the shell. It really has two purposes: during startup it must initialize memory spaces and do general set-up tasks such as setting up interrupts, and during all other times, it polls over status bytes that determine if the node is ready and able to transmit a new packet, and if so, it calls the tx function.

tx

The transmitter can send new packets, resend old packets, send ACKs and send nACKs, depending on what state the machine is in when it is called. To help abstraction, the transmitter does not directly send packets. Instead, it passes them off to a dedicated function that interfaces directly with the PHY layer (see mem2ifc).

rx

The receiver gets called by the PHY receiver whenever it has received a packet. The receiver has different behavior depending on whether the packet received was destined for itself or another node. Also, it sets the state machine appropriately depending on what was received (ACK, nACK, or data).

timer_a_int_handler

This is the interrupt handler for the first timer peripheral. It updates the number of dropped packets and number of timeouts, then sets the backoff timer before attempting to resend.

setTimer

The setTimer function allows the use of software timers for the MAC. Currently, the two types of timers needed are timeouts and backoffs. The timeout is a preset amount of time that the node is willing to wait for an ACK before retransmitting. The backoff occurs whenever a collision is inferred. The backoff is an exponential uniformly distributed random variable.

writeMem2Ifc

This function is responsible for converting the frameStruct type into an array of bytes to be sent in the PHY layer. Because this conversion effectively defines the frame format, placing this into its own function allows us to upgrade frame formats without affecting the behavior of the MAC itself.

writeIfc2Mem

This is the inverse process of the previous function. This converts the array of bytes back into something that the MAC can understand (the frameStruct type).

writeMem2Mem

This is responsible for copying received packet structure into receive queue for higher layers to access.

checkSum

The checksum is used to infer corrupted data upon receipt of a packet. This checksum is a very simple addition of bytes. If we choose to implement other checksum algorithms, we can replace this function without the MAC even knowing.

Attachments (7)

Download all attachments as: .zip