Specifications

SLAA137A
16 MSP430 Internet Connectivity
Frame Was Received.
Individually Addressed? Broadcast?
ARP, Opcode REPLY? IP?
Process Frame. ICMP? TCP?
ProcessICMPFrame() ProcessTCPFrame()
Figure 8. Demultiplexing of Received Frames
If the frame was individually addressed, it is first checked to determine if it is an ARP answer
frame for a previously sent ARP request of the local TCP. In this case, the opponent’s MAC
address is extracted. This mechanism is used for performing an active open of a connection. For
the case that the received frame type is IP and its destination address matches the one of the
local TCP, a jump to the function ProcessICMPFrame() or ProcessTCPFrame() is executed,
depending on the IP protocol number.
The procedure ProcessICMPFrame() checks to determine if the frame is an ICMP echo request
and generates an ICMP echo reply. Other types of ICMP messages are ignored and discarded.
If the frame type is TCP, steps for processing incoming TCP segments recommended in RFC
793 are executed. First, the frame is checked to determine if a TCP session is active and
whether the frame belongs to this session, or if a request from another TCP for establishing a
connection was received (segment carries a SYN flag). Afterwards, the state of the variable
TCPStateMachine is changed according to the flags of the segment that arrived. When data is
sent along the segment and the receive buffer is empty, this data is copied to the RxTCPBuffer
memory space. Valid arriving segments are acknowledged by sending a TCP ACK segment.
The program only accepts incoming segments that correspond to the sequence number of the
last segment that was acknowledged. Due to the relatively small amount of memory, no
buffering can be done for segments that are delivered out of order. Preparing a non-data TCP
segment is done by using the PrepareTCPFrame() function. A valid combination of TCP flags is
passed as an argument. The whole frame (including its headers) is generated in the TxFrame2
buffer. For example, calling PrepareTCPFrame(TCP_CODE_ACK) creates an
acknowledgement segment.