= 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. [[Image(P2MP.png, align=centre, 500)]] == == == == == == == == 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: [[Image(BS.bmp, align=left, 400)]] 1) 2) 3) == == == == == == == == == == For the Subscriber Station, the states look like the following: [[Image(SS.bmp, align=right, 400)]] 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: [source:/ResearchApps/MAC/WANMAC/Basestation/basestation.c basestation.c] and [source:/ResearchApps/MAC/WANMAC/Subscriber/substation.c 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 ([source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@211#L890 Ethernet], [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@211#L1128 Radio and PHY], and [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@211#L1297 Automatic Gain Control]). == Typedefs == [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L175 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. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L191 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 [wiki:"Video Board" Video Board], or eventually the ethernet controller. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L206 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 == [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L1022 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. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L547 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). [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L629 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). [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L238 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. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L773 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. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L844 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. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L910 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). [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L968 writeMem2Mem] This is responsible for copying received packet structure into receive queue for higher layers to access. [source:/ResearchApps/MAC/ACKMAC/src/ackmac.c@91#L997 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.