This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

nwk Q-mangment function question

Hi ,

 

Can someone please explain the nwk_Qfindoldest?

1) whats the logic flow inside this?

2) whats the purpose and usage of this function?

3) whats the relationship beteween it and nwk_findslot?

 

Thanks,

 

  • The purpose of this function is to locate the oldest received frame for the given link ID.  If there are no frames in the receive queue for this link or the queue is empty, then a null pointer is returned.

    The flow is as follows

    1. check to make sure we are looking in the input (receive) queue
      1. if not, return null.  This is because it turned out not to be necessary to do this for the output queue.
    2. check the type of packet being looked for
      1. if looking for a packet destined for a user app
        1. get port and peer address associated with the LID
      2. else if looking for a packet destined for a network app
        1. retrieve the destination port directly from the packet data
      3. else if we are an access point and this is a poll receive frame from a sleeping end device
        1. get port and peer addresses directly from packet data
      4. else request not understood
        1. return null (failure)
    3. get the type of packet to retrieve (i.e. in use until deleted or in use until forwarded)
    4. Loop through all packets in the input queue
      1. if this packet in the input queue is marked as in use for the type of use indicated
        1. and if the destination port for this packet is the port we are looking for
          1. get the address the packet is directed to
          2. if this matches the address of the expected peer address
            1. if this is the oldest packet in the queue so far
              1. update the oldest packet pointer
    5. return oldest packet in receive queue destined for the connection requested.

     

    The purpose of the function is to manage the order in which packets are given to a connection end (i.e. the LID requesting the packet).  There is additional work here because the nwk applications do not create links but work on an effective static link implied by the port addressed.  In either case, we want to make sure the packets are retrieved in the order received and the oldest packet in the queue (for the requested LID/Port) will be the first one passed back to the application.  This is necessary as there is no guarantee only one packet will be received on a given connection before the destination application can retrieve it.  i.e. there can be multiple packets in the queue for a single destination.

     

    The find slot function locates a free entry in the receive queue so the current message being received by the radio can be placed in the queue.  the relationship of this function to the find oldest function is roughly similar to a head and tail pointer in a ring buffer.  However, since the receive queue handles packets for all links/ports, and there is no restriction of the order in which links/ports retrieve packets from the frame, the single receive queue effectively operates as multiple ring buffers in parallel but by combining them all into a single queue maximizes memory usage in general.

     

    Jim Noxon