Event: Packet received at an MSMethod: ms_recv()
Comment: It can be a packet from the IFQ to be sent to the BS
or a packet from the Air Interface to be sent up the stack.
The latter case occurs only at the start of a down-slot.
Action: Check direction in packet header
If packet direction == UP
Check mac_source and mac_destination
If mac_source == BS and mac_destination == (self or broadcast)
Stop the Release timer if it is On
Restart Release Timer if the IFQ is empty.
Store packet in pktRx_[downslot]. (see Note)
Switch the radio On.
Pass pktRx_[downslot] to rx_from_phy().
Else ignore packet.
Else if packet direction == DOWN
If packet is a broadcast
Stamp it to be transmitted on upslot0, frequency0.
Else
check tx_chan[] for slot/frequency to transmit packet.
If no slot-frequency found
Store packet in p_temp
Call send_resource_request().
Else
If Release Timer is ON, stop it.
Stamp frequency channel onto packet header
Store packet in pktTx[up_slot alloted]. (see Note)
Pass pktTx[up_slot alloted] to rx_from_ll()
Note : In the case where the MS receives two packets on concurrent slots, the packet received later will over-write the previous packet, at the instance at the end of the old slot and start of the new one. At this instance, the pktRxTimer is not yet done with the old packet and still requires the pointer. It triggers an error. To avoid this, we use an array (could also use a linked list), that stores pointers to packets received in each slot. The array entry is cleared by the recvHandler after the packet reception is over.
A similar situation holds for the pktTx[]. We use an array to avoid over-writing and thus loosing packets to be transmitted in adjacent slots.
Note that this structure would also suffice for multi-slot operation.