?? algo.tex
字號:
%\documentclass[12pt,openany]{report}%\begin{document} \section{Psuedocode for Packet Processing at MAC}The psuedocode for packet processing at the MAC is described below.\subsection{Packet at MS MAC}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\= xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill {\bf Event:}\> Packet received at an MS\\ \\{\bf Method:}\> ms\_recv()\\ \\{\bf 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.\\ \\{\bf 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()\\ \end{tabbing}Note : In the case where the MS receives two packets on concurrent slots, thepacket received later will over-write the previouspacket, at the instance at the end of the old slot and start of thenew one. At this instance, the {\tt pktRxTimer} is not yet done withthe old packet and still requires the pointer. It triggers an error.To avoid this, we use an array (could also use a linked list), thatstores pointers to packets received in each slot. The array entry iscleared by the {\tt recvHandler} after the packet reception is over. A similar situation holds for the {\tt pktTx[]}. We use an array toavoid over-writing and thus loosing packets to be transmitted inadjacent slots.Note that this structure would also suffice for multi-slot operation.\subsection{Packet received at an BS}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\= xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill {\bf Method:}\> bs\_recv()\\ \\{\bf Comment:}\> It can be a packet from the IFQ to be sent to an MS \\ \>or a packet from an MS at the Air Interface.\\ \> The latter case occurs only at the start of an up-slot.\\ \\{\bf Action:}\>Check direction in packet header\\ \>If packet direction == UP\\ \>\>Check mac\_destination\\\>\>If mac\_destination == (self or Broadcast)\\\>\>\>Extract the frequency channel the packet was sent on from its header\\.\>\>\>Store packet in rxQ[freq][upslot]. (see Note)\\\>\>\>Switch the radio On.\\\>\>\>Pass rxQ\_[freq][upslot] to rx\_from\_phy().\\\>\>Else ignore packet.\\ \\ \>Else if packet direction == DOWN\\ \>\>If packet is a broadcast \\\>\>\>Stamp it to be transmitted in downslot0, frequency0.\\\>\>Else \\\>\>\>Look up slot reserved for this destination from thevlr\_downtable[][] \\\>\>\>If no slot reserved for destination\\\>\>\>\> Mark packet as waiting. \\\>\>\>\> Call slot\_allot()\\\>\>\>\> Call send\_resource\_reply()\\\>\>\>Else \\\>\>\>\>If {\em resource\_reply} not yet received by MS\\\>\>\>\>\> Mark packet as waiting.\\ \>\>\>\>Stamp frequency channel onto packet header\\\>\>\>\>Store packet in txQ[freq][downslot]. (see Note)\\\>\>\>\>Pass txQ[freq][downslot] to rx\_from\_ll()\\\end{tabbing} Note: The situation here is similar to that at the MS. There is also theadded complexity that the BS may have to transmit/receive packets meant for/fromdifferent MS at a time; and that it can transmit/receive on manyfrequencies at a time. We sort and store all packets to betransmitted, and those received, in a two-dimensional array, in orderto keep track of all the packets. Again, the entries are cleared afterthe packets have been fully processed.\subsection{Accepting a packet from the IFQ }\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt rx\_from\_ll ()} \\ \\{\bf Comment:}\> This is where the MAC header is added and its valuesset\\ \\{\bf Action:}\> Add MAC header subtype\\\> Configure the other MAC header fields\\\> Set the wait flag to zero, unless the packet has already beenmarked waiting\\\end{tabbing} \subsection{End of a Down Slot}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> downslotHandler(Event *e)\\ \\{\bf Comment:}\> It is the BS' turn to transmit. See if it has anypacket \\\> scheduled to be transmitted in this slot. All frequencies needed to bechecked.\\ \\{\bf Action:}\> Restart downslot timer to clock the next slot.\\\>Start the Upslot Timer if this downslot 3 in the first TDMA frame.\\\>Compare node\_address with the BS\_address\\\> If node is a BS\\\>\> Check {\tt txQ[freq][downslot]} for all frequencies\\\>\> If {\tt txQ[freq][downslot]} !=NULL (see Note)\\\>\>\> Check if the packet has been marked as waiting\\\>\>\> If not, then pass packet to tx\_onto\_PHY() \\\> Else do nothing \\\> Increment downslot counter. Take care of wrap around.\\\end{tabbing} Note: {\tt txQ[freq\_][downslot\_]} stores a pointer to the packet to betransmitted by the BS in downslot in {\tt downslot\_} on frequency{\tt freq\_}.\subsection{End of a Up Slot}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> upslotHandler(Event *e)\\ \\{\bf Comment:}\> An MS can transmit a packet if it has one scheduledfor transmission.\\ \\{\bf Action:}\> Restart upslot timer to clock the next slot\\\>Compare node\_address with the BS\_address\\ \> If node is an MS\\ \>\> Check if it has a packet to transmit in {\tt pktTx[up\_slot\_]}\\\>\> if {\tt pktTx[up\_slot\_]} is not NULL \\\>\>\> Start slot release timer, if IFQ is empty\\\>\>\> Switch the radio ON \\\>\>\> Pass the packet in {\tt pktTx[up\_slot\_]} to {\tt tx\_onto\_PHY ()}\\\>\>\> Free {\tt pktTx[up\_slot\_] }\\\> Else do nothing \\\> Increment upslot counter. Take care of wrap around.\\\end{tabbing}\subsection{Packet to be transmitted onto the Air-Interface }\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt tx\_onto\_PHY ()} \\ \\{\bf Comment:}\> This is where the packet is actually passed down tothe physical layer. \\ \\{\bf Action:}\> Find packet transmission time \\\> Assert that it is non-negative but less than {\tt slot\_time\_} \\ \>Check if this is the PRACH and this is an MS \\\>If yes, check for collision on {\tt chan0\_0} \\\>If collision\\\>\> Change {tt chan0\_0} to {\sc coll}\\\>\> Increment {\tt coll\_count}\\\>\> Mark error in packet header \\\> Check the MAC header subtype \\\> If it is a {\em resource\_request}\\\>\> Schedule the {\tt Wait timer} for 1 TDMA frame \\\> Start the {\tt pktTxTimer} \\\> Pass the packet to {\tt downtarget\_} \\\end{tabbing} \subsection{Packet to be received from the Air-Interface}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt rx\_from\_PHY ()} \\ \\{\bf Comment:}\> This is where a packet is received from theAir-Interface by the receiver. \\ \\ {\bf Action:}\> Check if this is the PRACH and this is the BS \\\> If yes, check for collision on {\tt chan0\_0} \\\> If collision\\\>\> Drop the colliding packets\\\>\> Decrement the {\tt coll\_count}\\ \>\> Change the {tt chan0\_0} to {\sc idle} when all collidingpackets have been dropped\\\> Else \\\>\> Drop packet header if marked in error \\\>\> Find packet reception interval \\\>\> Assert that it is non-negative but less than {\tt slot\_time\_} \\ \>\> Start the {\tt pktRxTimer} \\ \end{tabbing} \subsection{Packet send completed}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt sendHandler ()} \\ \\{\bf Comment:}\> Simply winds up the transmission \\ \\{\bf Action:}\> Free the packet \\\> Switch the radio OFF \\\> Unlock the IFQ if the {\tt wait timer} is not busy\\\end{tabbing} \subsection{Packet receive completed}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt sendHandler ()} \\ \\{\bf Comment:}\> Wind up reception and pass the packet onto higher layers\\ \\ {\bf Action:}\> Switch the radio OFF \\ \> Double check whether I should receive the packet\\\> If not, drop the packet\\\> Pass the packet to {\tt fwd\_DATA\_to\_LL()}\end{tabbing} \subsection{A packet has to be passed to the RLC}\begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt fwd\_DATA\_to\_LL()} \\ \\{\bf Comment:}\> The packet can be either a MAC control packet or data packet\\\> It has to be handled accordingly.\\ \\{\bf Action:}\> Check MAC type\\\> If MAC type == DATA\\\>\> Remove MAC header\\\>\> Increment hop count in the packet's common header \\\>\> Pass it on to the {\tt uptarget}, the RLC in this case\\\> If MAC type == Control, check for subtype\\\> If MAC sub type == {\em res\_request}\\\>\> Allot a slot to the source MS, through {\tt slot\_allot()}\\\>\> Schedule a {\em res\_reply} to be sent\\\> If MAC sub type == {\em res\_reply}\\\>\> Stop the {\tt wait timer}\\\>\> Obtain the slot and frequency reserved for me from the {\emres\_reply} header \\ \>\> Set {\tt tx\_chan[slot]=rx\_chan[slot] = frequency}\\\>\> Unmark the waiting packet at the BS\\\>\> Move the packet buffered at the MS to {\tt pktTx[slot]}\\\>\> Pass the {\tt pktTx[slot]} to {\tt rx\_from\_ll()}\\\>\> Unlock the IFQ\\\> If MAC sub type == {\em tx\_end}\\\>\> Clear the corresponding MS' entry from the {\tt vlr\_.down\_table}and {\tt vlr\_.up\_table}\\\end{tabbing} \subsection{Resources have to be alloted to an MS} \begin{tabbing}{\bf Comment:} \= xxxx\= xxxx\= xxxx\=xxxx\=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kill{\bf Method:}\> {\tt slot\_allot (int ms\_, int \&freq, int \&slot)}\\ \\{\bf Comment:}\> A slot has to be alloted to the mobile from the poolof GPRS\\\>and GSM slots depending on which type the mobile is. \\ \\{\bf Action:}\> Check if this is a GPRS mobile \\\> If it is a GPRS MS \\\>\> Find the first available GPRS slot in the {\tt vlr\_.up\_table}\\\>\> Refuse connection if no GPRS slot- frequency available\\\> Else if it is a GSM MS\\\>\> Find the first available GSM slot in the {\tt vlr\_.up\_table}\\ \>\> Refuse connection if no GSM slot- frequency available\\ \> Enter the MS' MAC {\tt index\_} into the {\tt vlr\_.up\_table} and{\tt vlr\_.down\_table}\\\> Return the value of the frequency and slot to the caller \\\end{tabbing} This completes the description of the psuedocode for packet processing at the MAC.%\end{document}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -