Webserver+3d print
tcp_fsm.c File Reference
TCP finite state machine. More...
Go to the source code of this file.
Functions | |
void | tcpProcessSegment (NetInterface *interface, IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset) |
Incoming TCP segment processing. | |
void | tcpStateClosed (NetInterface *interface, IpPseudoHeader *pseudoHeader, TcpHeader *segment, size_t length) |
CLOSED state. | |
void | tcpStateListen (Socket *socket, NetInterface *interface, IpPseudoHeader *pseudoHeader, TcpHeader *segment, size_t length) |
LISTEN state. | |
void | tcpStateSynSent (Socket *socket, TcpHeader *segment, size_t length) |
SYN-SENT state. | |
void | tcpStateSynReceived (Socket *socket, TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length) |
SYN-RECEIVED state. | |
void | tcpStateEstablished (Socket *socket, TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length) |
ESTABLISHED state. | |
void | tcpStateCloseWait (Socket *socket, TcpHeader *segment, size_t length) |
CLOSE-WAIT state. | |
void | tcpStateLastAck (Socket *socket, TcpHeader *segment, size_t length) |
LAST-ACK state. | |
void | tcpStateFinWait1 (Socket *socket, TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length) |
FIN-WAIT-1 state. | |
void | tcpStateFinWait2 (Socket *socket, TcpHeader *segment, const NetBuffer *buffer, size_t offset, size_t length) |
FIN-WAIT-2 state. | |
void | tcpStateClosing (Socket *socket, TcpHeader *segment, size_t length) |
CLOSING state. | |
void | tcpStateTimeWait (Socket *socket, TcpHeader *segment, size_t length) |
TIME-WAIT state. |
Detailed Description
TCP finite state machine.
License
Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Description
The TCP state machine progresses from one state to another in response to events (user calls, incoming segments and timeouts). This file describes the state transitions caused by incoming segments. Refer to the following RFCs for complete details:
- RFC 793: Transmission Control Protocol
- RFC 1122: Requirements for Internet Hosts - Communication Layers
- Version:
- 1.7.6
Definition in file tcp_fsm.c.
Function Documentation
void tcpProcessSegment | ( | NetInterface * | interface, |
IpPseudoHeader * | pseudoHeader, | ||
const NetBuffer * | buffer, | ||
size_t | offset | ||
) |
void tcpStateClosed | ( | NetInterface * | interface, |
IpPseudoHeader * | pseudoHeader, | ||
TcpHeader * | segment, | ||
size_t | length | ||
) |
CLOSED state.
This is the default state that each connection starts in before the process of establishing it begins
- Parameters:
-
[in] interface Underlying network interface [in] pseudoHeader TCP pseudo header [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateCloseWait | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
CLOSE-WAIT state.
The device has received a close request (FIN) from the other device. It must now wait for the application to acknowledge this request and generate a matching request
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateClosing | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
CLOSING state.
The device has received a FIN from the other device and sent an ACK for it, but not yet received an ACK for its own FIN message
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateEstablished | ( | Socket * | socket, |
TcpHeader * | segment, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
size_t | length | ||
) |
ESTABLISHED state.
Data can be exchanged freely once both devices in the connection enter this state. This will continue until the connection is closed
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] buffer Multi-part buffer containing the incoming TCP segment [in] offset Offset to the first data byte [in] length Length of the segment data
void tcpStateFinWait1 | ( | Socket * | socket, |
TcpHeader * | segment, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
size_t | length | ||
) |
FIN-WAIT-1 state.
A device in this state is waiting for an ACK for a FIN it has sent, or is waiting for a connection termination request from the other device
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] buffer Multi-part buffer containing the incoming TCP segment [in] offset Offset to the first data byte [in] length Length of the segment data
void tcpStateFinWait2 | ( | Socket * | socket, |
TcpHeader * | segment, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
size_t | length | ||
) |
FIN-WAIT-2 state.
A device in this state has received an ACK for its request to terminate the connection and is now waiting for a matching FIN from the other device
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] buffer Multi-part buffer containing the incoming TCP segment [in] offset Offset to the first data byte [in] length Length of the segment data
void tcpStateLastAck | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
LAST-ACK state.
A device that has already received a close request and acknowledged it, has sent its own FIN and is waiting for an ACK to this request
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateListen | ( | Socket * | socket, |
NetInterface * | interface, | ||
IpPseudoHeader * | pseudoHeader, | ||
TcpHeader * | segment, | ||
size_t | length | ||
) |
LISTEN state.
A device (normally a server) is waiting to receive a synchronize (SYN) message from a client. It has not yet sent its own SYN message
- Parameters:
-
[in] socket Handle referencing the current socket [in] interface Underlying network interface [in] pseudoHeader TCP pseudo header [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateSynReceived | ( | Socket * | socket, |
TcpHeader * | segment, | ||
const NetBuffer * | buffer, | ||
size_t | offset, | ||
size_t | length | ||
) |
SYN-RECEIVED state.
The device has both received a SYN from its partner and sent its own SYN. It is now waiting for an ACK to its SYN to finish connection setup
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] buffer Multi-part buffer containing the incoming TCP segment [in] offset Offset to the first data byte [in] length Length of the segment data
void tcpStateSynSent | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
SYN-SENT state.
The device (normally a client) has sent a synchronize (SYN) message and is waiting for a matching SYN from the other device (usually a server)
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] length Length of the segment data
void tcpStateTimeWait | ( | Socket * | socket, |
TcpHeader * | segment, | ||
size_t | length | ||
) |
TIME-WAIT state.
The device has now received a FIN from the other device and acknowledged it, and sent its own FIN and received an ACK for it. We are done, except for waiting to ensure the ACK is received and prevent potential overlap with new connections
- Parameters:
-
[in] socket Handle referencing the current socket [in] segment Incoming TCP segment [in] length Length of the segment data
Generated on Tue Jul 12 2022 17:10:22 by
