Navigation bar
  Start Previous page  16 of 35  Next page End Home  6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  

 Figure 9.  TCP Segment Queues
Embedded Web Server for the CR16
National Semiconductor
Jeff Wright
16
*NULL
XMITQ_T *XmitQFreeList
XMITQ_T  XmitQTbl
[MAX_SEGMENTS] =
XMITQ_T  *
XmitQList =
PSEUDO_T
PHdr;
TCP_T     
TCPHdr;
UWORD     
SegTimer;
UWORD      
Status;
CRSOCK_T    *Socket;TCPHdr;
UBYTE      
*TxStart;
UWORD      
TxCount;
const UBYTE
*html;
UWORD      
HtmLen;
struct xmitq_t
*XmitQNext;
struct xmitq_t
*XmitQPrev;
PSEUDO_T
PHdr;
TCP_T     
UWORD           
SegTimer;
UWORD      
Status;
CRSOCK_T    *Socket;
UBYTE      
*TxStart
;
UWORD      
TxCount;
const UBYTE
*html;
UWORD      
HtmLen;
struct xmitq_t
*XmitQNext
;
struct xmitq_t
*XmitQPrev;
PSEUDO_T
PHdr;
TCP_T     
TCPHdr;
UWORD     
SegTimer;
UWORD      
Status;
CRSOCK_T    *Socket;
UBYTE      
*TxStart;
UWORD      
TxCount;
const UBYTE
*html;
UWORD      
HtmLen;
struct xmitq_t
*XmitQNext;
struct xmitq_t
*XmitQPrev;
PSEUDO_T
PHdr;
TCP_T     
TCPHdr;
UWORD     
SegTimer;
UWORD      
Status;
CRSOCK_T    *Socket;
UBYTE      
*TxStart
;
UWORD      
TxCount;
const UBYTE
*html;
UWORD      
HtmLen;
struct xmitq_t
*XmitQNext
;
struct xmitq_t
*XmitQPrev
;
PSEUDO_T
PHdr;
TCP_T     
TCPHdr;
UWORD     
SegTimer;
UWORD      
Status;
CRSOCK_T    *Socket;
UBYTE      
*TxStart
;
UWORD      
TxCount;
const UBYTE
*html;
UWORD      
HtmLen;
struct xmitq_t
*XmitQNext
;
struct xmitq_t
*XmitQPrev
;
*NULL
void 
TCPDeleteSeg (XMITQ_T *)
XMITQ_T  *TCPCreateSeg ( )
Figure 9. Segment Queues
Each queued segment holds only those parameters necessary to ensure that the segment
can be accurately retransmitted in the event it is not properly acknowledged.  The segment
data itself is not queued, since this would require enormous amounts of RAM.  Only the
segment’s relevant parameters are queued.  Upon creation, each segment is timestamped
with the current OS time.  When the TCP has sent all available segments, it periodically
updates and checks the timer field of every “unACK’d” segment on the queue.  If any or all
of the segments awaiting acknowledgment on the queue timeout, they will be retransmitted
once.  If the same segment times out again, a reset is sent to the peer, and the TCP closes.   
Again, due to the RAM consumption of the HTTP layer, this implementation creates only a
few such segments (4-6) before having to wait upon an ACKnowledgement from the peer. 
Upon receiving data bearing or certain other control segments, the receiving TCP is required
to inform the sending TCP that it has successfully received these segments.  This is
accomplished by sending ACKnowledge segments whose Acknowledgement Number field
indicates the Sequence Number of the last byte successfully received.  This permits the
sending TCP to continue sending segments unabated.  Should a segment not be acknowledged
by the peer in a timely fashion (due to some error or other damnable event), the sending
TCP will take note and resend this segment.  Upon receiving an “ACK” segment from the
peer, the previously transmitted segments sitting on the XmitQList queue are checked
against the received Acknowledgement number to determine whether this ACK affects
them.  If it does, they are removed and returned to the XmitQFreeList queue, making them
available for reuse.  If it does not, they remain on the queue until they are acknowledged, or
they timeout and are resent.
In the event that all segments have been allocated and yet more application data remains to
be sent, TCP must wait for the peer to ACKnowledge all/any of the previously sent
segments.  During this time, TCP updates the SegTimer fields of the segments awaiting
ACKnowledgement.  Should a segment timeout it will be retransmitted.  Should it timeout a
Microcontroller.com White Papers Previous page Top Next page