blob: 1e9dae1612d7b36c941ccd8bee05fc5d1659895d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/***************************************************************************
* Copyright (c) 2024 Microsoft Corporation
* Copyright (c) 2025-present Eclipse ThreadX Contributors
*
* This program and the accompanying materials are made available under the
* terms of the MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** NetX Component */
/** */
/** Transmission Control Protocol (TCP) */
/** */
/**************************************************************************/
/**************************************************************************/
#define NX_SOURCE_CODE
/* Include necessary system files. */
#include "nx_api.h"
#include "nx_ip.h"
#ifdef FEATURE_NX_IPV6
#include "nx_ipv6.h"
#endif /* FEATURE_NX_IPV6 */
#include "nx_packet.h"
#include "nx_tcp.h"
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _nx_tcp_socket_state_transmit_check PORTABLE C */
/* 6.4.3 */
/* AUTHOR */
/* */
/* Yuxin Zhou, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function determines if the new receive window value is large */
/* enough to satisfy a thread suspended trying to send data on the TCP */
/* connection. This is typically called from the ESTABLISHED state. */
/* */
/* INPUT */
/* */
/* socket_ptr Pointer to TCP socket */
/* */
/* OUTPUT */
/* */
/* None */
/* */
/* CALLS */
/* */
/* _nx_tcp_socket_thread_resume Resume suspended thread */
/* */
/* CALLED BY */
/* */
/* _nx_tcp_socket_packet_process Process TCP packet for socket */
/* */
/**************************************************************************/
VOID _nx_tcp_socket_state_transmit_check(NX_TCP_SOCKET *socket_ptr)
{
ULONG tx_window_current;
/* Now check to see if there is a thread suspended attempting to transmit. */
if (socket_ptr -> nx_tcp_socket_transmit_suspension_list)
{
/* Yes, a thread is suspended attempting to transmit when the transmit window
is lower than its request size. Determine if the current transmit window
size can now accommodate the request. */
/* Pick up the min(cwnd, swnd) */
if (socket_ptr -> nx_tcp_socket_tx_window_advertised > socket_ptr -> nx_tcp_socket_tx_window_congestion)
{
tx_window_current = socket_ptr -> nx_tcp_socket_tx_window_congestion;
/* On the first and second duplicate ACKs received, the total FlightSize would
remain less than or equal to cwnd plus 2*SMSS.
Section 3.2, Page 9, RFC5681. */
if ((socket_ptr -> nx_tcp_socket_duplicated_ack_received == 1) ||
(socket_ptr -> nx_tcp_socket_duplicated_ack_received == 2))
{
tx_window_current += (socket_ptr -> nx_tcp_socket_connect_mss << 1);
}
/* Make sure the tx_window_current is less or equal to swnd. */
if (tx_window_current > socket_ptr -> nx_tcp_socket_tx_window_advertised)
{
tx_window_current = socket_ptr -> nx_tcp_socket_tx_window_advertised;
}
}
else
{
tx_window_current = socket_ptr -> nx_tcp_socket_tx_window_advertised;
}
/* Substract any data transmitted but unacked (outstanding bytes) */
if (tx_window_current > socket_ptr -> nx_tcp_socket_tx_outstanding_bytes)
{
tx_window_current -= socket_ptr -> nx_tcp_socket_tx_outstanding_bytes;
}
else /* Set tx_window_current to zero. */
{
tx_window_current = 0;
}
/* Determine if the current transmit window (received from the connected socket)
is large enough to handle the transmit. */
if ((tx_window_current) &&
(socket_ptr -> nx_tcp_socket_transmit_sent_count < socket_ptr -> nx_tcp_socket_transmit_queue_maximum))
{
/* Is NetX set up with a windows update callback? */
if (socket_ptr -> nx_tcp_socket_window_update_notify)
{
/* Yes; Call this function when there is a change in transmit windows size. */
(socket_ptr -> nx_tcp_socket_window_update_notify)(socket_ptr);
}
/* Decrement the suspension count. */
socket_ptr -> nx_tcp_socket_transmit_suspended_count--;
/* Remove the suspended thread from the list. */
_nx_tcp_socket_thread_resume(&(socket_ptr -> nx_tcp_socket_transmit_suspension_list), NX_SUCCESS);
}
}
}
|