Specifications

SLAA137A
18 MSP430 Internet Connectivity
4.2.6 Closing a Connection
A TCP connection can be closed on different events. Normally this is done either locally by
calling the user function TCPClose() or remotely by the other TCP. During the termination of a
connection, segments carrying FIN flags are exchanged. If the retransmission counter exceeds
a limit or a segment with a RST (reset) flag is received, the connection is also closed. This is an
error situation that is indicated by an error code in the SocketStatus register.
4.2.7 Using of Timers
When implementing a TCP, different tasks must be performed with controlled timing. The stack
uses Timer_A of the MSP430, which is configured by the function TCPLowLevelInit(). The
protocol specification for TCP (RFC 793) demands a 32-bit wide, free-running counter with a
frequency of 250 kHz. It is used for getting the initial sequence number (ISN) needed for
opening a connection. An 8-MHz crystal drives the MSP430. This clock is divided by 32, down to
250 kHz, and sources a 16-bit wide, free-running counter (TAR). An interrupt is generated each
time the TAR register completes an interval (every 0.262s using an 8-MHz MCU clock). In this
case, the interrupt service routine TCPClockHandler() increments the 16-bit number
ISNGenHigh. This variable represents the upper word of the ISN. On each timer interrupt event,
the variable TCPTimer is also incremented. It is used to generate the timer events needed for a
TCP. For example, if the other TCP does not acknowledge a segment sent within a specific time
interval, a retransmission is triggered. Also, on closing a connection, the TCP has to wait before
another TCP connection can be opened.
4.2.8 Retransmission of Data
In order to avoid a breakdown of the TCP connection caused by loss of transmitted data, a time-
controlled mechanism for retransmitting of data is implemented. The TCP stack writes the type
of every frame sent to the LastFrameSent register. When the time counter exceeds the
RETRY_TIMEOUT (symbolic constant, tcpip.h) limit, the frame is resent using the function
TCPHandleRetransmission(). The maximum count of retransmissions per segment is defined in
the constant MAX_RETRYS. If this count is exceeded, the current TCP session is closed and an
error is indicated. This mechanism is not used for sent segments that only contain an ACK flag
because they are not acknowledged and therefore need no retransmission.
4.2.9 Summary
In spite of the fact that during software development many compromises were made [6], the
compatibility of the stack in communicating with other TCPs is very good. No other TCP had
problems establishing a connection during the software evaluation. Table 5 gives a list of several
computers and operating systems where data exchange over TCP/IP is possible.