TCP
[TCP/IP Base Protocols]


Files

file  tcp.h
 TCP Module for Modtronix TCP/IP Stack.

Detailed Description

The TCP layer of the Modtronix TCP/IP stack is implemented by the file "tcp.c". The header file "tcp.h" defines the services provided by the layer. In this stack architecture, TCP is an active layer. It fetches TCP packets and responds to the remote host according to the TCP state machine. The TCP module is also implemented as a cooperative task, performing automatic operations without the knowledge of the main application.

"tcp.h" provides TCP socket services and hides all TCP packet handling from the caller. The layer allows from 2 to 253 TCP sockets, the number limited only by available memory and compiler used. With more than one socket, higher level applications can maintain multiple simultaneous TCP connections and there could be more than one application using this layer. This facility is useful when HTTP Server is used. It is important to know that each socket consumes approximately 36 bytes (check source file for actual consumption) and increases overall TCP processing time.

Unlike other TCP/IP implementations, all sockets in the Modtronix TCP/IP Stack share one or more common transmit buffers. This approach reduces overall RAM requirements, but it may create a potential problem, where a few sockets reserve all available transmit buffers and do not release them on time for other sockets to use. Under these circumstances, remote hosts and/or local applications would not be able to contact the stack. To avoid this, users must make sure that there are enough transmit buffers for all sockets. On the receive side, there is only one receive buffer. If a socket receives its data, the owner of that socket must fetch and discard the receive buffer in one task time in order for the other sockets to receive their data. This design mandates that once a task detects a packet it is interested in, it must consume the complete packet in one task time. A task cannot fetch part of a packet during one task time and expect to fetch the rest of the packet later.

As required by TCP specifications, each TCP segment contains a checksum that covers the entire TCP packet, including the data area. To reduce RAM requirements, the TCP layer uses the MAC buffer in the NIC as storage and performs the checksum calculation in the MAC buffer itself. If the NIC is used as a MAC, the NIC SRAM is used as a buffer space. But if SLIP is used as a MAC, the microcontrollerÆs internal data RAM is used.

The TCP layer of the Modtronix TCP/IP Stack implements most of the TCP state machine states proposed by RFC793. It also implements automatic retry and timed operations, which users can enable or disable by the compile time definition TCP_NO_WAIT_FOR_ACK. When automatic retry is enabled, each socket transmit buffer is reserved until an acknowledgement from the remote host is received. This design effectively creates a transmit window of one TCP segment. Thus, data throughput would be considerably lower than that in "No Retry" mode. If only the HTTP Server application is used, the user may disable automatic retry and effectively increase throughput. If the main applicationÆs logic requires that each packet be acknowledged before a new one can be transmitted, the user should enable the "Automatic Retry" mode. With Automatic Retry enabled, some opened connections may not get served on time, and the remote host may get time-out or RESET errors.

Configuration

For details on configuring this module, see Configuration section of tcp.h file.

Generated on Wed Feb 3 12:45:36 2010 for SBC65EC Web Server by  doxygen 1.5.8