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

Embedded Web Server for the CR16
National Semiconductor
Jeff Wright
17
second time TCP will infer that an error of some sort has occurred at the peer, and will
issue a RESET segment.  After sending the reset segment, TCP will revert to the listening
state and attempt to send the entire data again.   The timeout values used are fully flexible
and determined by macros in the TCP header file. 
 
2.
Transmitting Data.
An application wishing to transmit data must first determine whether TCP is available by
checking the TCP_SEND flag.  If TCP is available, the application must fill in the necessary
fields in TCP’s API (indicating for instance, the location(s) of the data buffers to transmit),
and then set the TCP_SEND flag.  When the TCP task next runs, it will check for any
commands from the application(s).  Upon noting that the TCP_SEND flag is set, TCP will:
1.
Use the *Socket (connection name) field to determine which TCP Control Block to
access…
2.
Determine whether the total data length exceeds that of the peer’s Maximum
Segment Size (MSS).  If it does exceed this limit, TCP will grab a “MSS-sized”
portion of the data, to ensure that the receiving TCP can handle the segment…
3.
Acquire a TCP segment (if one is available) from the TCP segment manager, who
places the segment in the XmitQList.  If no segments are available, TCP must wait…
4.
Compute the total segment length and record this number in the Length field…
5.
Transcribe the current Sequence numbers from the socket’s control structure…
6.
Compute the segment checksum and record it in the HdCkSum field…
7.
Record the segment’s timeout value in its SegTimer field…
8.
Fill the required pointer fields in IP’s interface with the appropriate buffer
addresses…
9.
Determine whether this is the final segment to send.  If so, set the FIN flag in the
TCP segment header.  Otherwise, only the PSH and ACK flags are set…
10.
After ensuring that IP is available (by checking IP’s DLSEND flag), signal the IP
layer to transmit this segment by setting the DLSEND flag in IP’s interface …
11.
Repeat steps two through nine above until all application data has been sent.
12.
Once all application data has been transmitted, TCP will await ACKnowledgement of
the FIN segment, as well as any other un-ACK’d segments…
13.
Upon receiving proper ACKnowledgements, the connection is closed.
This process is illustrated in Figure 10.  The application (HTTP in this case) collects the
various data and passes the relevant parameters on to TCP.   
3.
Receiving Data.
TCP monitors the DLRECV flag in the Cmd field of IP’s interface data structure for received
segments.  Upon receiving a segment from IP, TCP will:
1.
Confirm the segment’s checksum.  If incorrect, the segment is silently discarded (i.e.
ignored)…
2.
Compute the payload length (application data) for use by the application …
Microcontroller.com White Papers Previous page Top Next page