1
10
13
14
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
106
107
108
109
110
111
112
118
124
125
126
127
128
129
130
131
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
190
191
192
193
194
195
196
197
198
199
200
201
207
208
209
210
211
212
213
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#ifdef FEATURE_NX_IPV6
#include "nx_ipv6.h"
#endif
#include "nx_packet.h"
#include "nx_tcp.h"
...
...
VOID _nx_tcp_fast_periodic_processing(NX_IP *ip_ptr)
{
NX_TCP_SOCKET *socket_ptr;
ULONG sockets;
ULONG timer_rate;
timer_rate = _nx_tcp_fast_timer_rate;
sockets = ip_ptr -> nx_ip_tcp_created_sockets_count;
socket_ptr = ip_ptr -> nx_ip_tcp_created_sockets_ptr;
while (sockets--)
{
/* ... */
if ((socket_ptr -> nx_tcp_socket_state >= NX_TCP_ESTABLISHED) &&
((socket_ptr -> nx_tcp_socket_rx_sequence != socket_ptr -> nx_tcp_socket_rx_sequence_acked) ||
(socket_ptr -> nx_tcp_socket_rx_window_last_sent < socket_ptr -> nx_tcp_socket_rx_window_current)))
{
if (socket_ptr -> nx_tcp_socket_delayed_ack_timeout <= timer_rate)
{
_nx_tcp_packet_send_ack(socket_ptr, socket_ptr -> nx_tcp_socket_tx_sequence);
}if (socket_ptr -> nx_tcp_socket_delayed_ack_timeout <= timer_rate) { ... }
else
{
socket_ptr -> nx_tcp_socket_delayed_ack_timeout -= timer_rate;
}else { ... }
}if ((socket_ptr -> nx_tcp_socket_state >= NX_TCP_ESTABLISHED) && ((socket_ptr -> nx_tcp_socket_rx_sequence != socket_ptr -> nx_tcp_socket_rx_sequence_acked) || (socket_ptr -> nx_tcp_socket_rx_window_last_sent < socket_ptr -> nx_tcp_socket_rx_window_current))) { ... }
if (socket_ptr -> nx_tcp_socket_timeout)
{
if (socket_ptr -> nx_tcp_socket_timeout > timer_rate)
{
socket_ptr -> nx_tcp_socket_timeout -= timer_rate;
}if (socket_ptr -> nx_tcp_socket_timeout > timer_rate) { ... }
else if (((socket_ptr -> nx_tcp_socket_timeout_retries >= socket_ptr -> nx_tcp_socket_timeout_max_retries) &&
(socket_ptr -> nx_tcp_socket_zero_window_probe_has_data == NX_FALSE)) ||
((socket_ptr -> nx_tcp_socket_zero_window_probe_failure >= socket_ptr -> nx_tcp_socket_timeout_max_retries) &&
(socket_ptr -> nx_tcp_socket_zero_window_probe_has_data == NX_TRUE))
)
{
_nx_tcp_socket_connection_reset(socket_ptr);
}else if (((socket_ptr -> nx_tcp_socket_timeout_retries >= socket_ptr -> nx_tcp_socket_timeout_max_retries) && (socket_ptr -> nx_tcp_socket_zero_window_probe_has_data == NX_FALSE)) || ((socket_ptr -> nx_tcp_socket_zero_window_probe_failure >= socket_ptr -> nx_tcp_socket_timeout_max_retries) && (socket_ptr -> nx_tcp_socket_zero_window_probe_has_data == NX_TRUE))) { ... }
else if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_SYN_SENT) ||
(socket_ptr -> nx_tcp_socket_state == NX_TCP_SYN_RECEIVED))
{
socket_ptr -> nx_tcp_socket_timeout_retries++;
socket_ptr -> nx_tcp_socket_timeout = socket_ptr -> nx_tcp_socket_timeout_rate <<
(socket_ptr -> nx_tcp_socket_timeout_retries * socket_ptr -> nx_tcp_socket_timeout_shift);
/* ... */
_nx_tcp_packet_send_syn(socket_ptr, (socket_ptr -> nx_tcp_socket_tx_sequence - 1));
}else if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_SYN_SENT) || (socket_ptr -> nx_tcp_socket_state == NX_TCP_SYN_RECEIVED)) { ... }
else if (socket_ptr -> nx_tcp_socket_transmit_sent_head ||
((socket_ptr -> nx_tcp_socket_tx_window_advertised == 0) &&
(socket_ptr -> nx_tcp_socket_state <= NX_TCP_CLOSE_WAIT)))
{
socket_ptr -> nx_tcp_socket_tx_sequence_recover = socket_ptr -> nx_tcp_socket_tx_sequence - 1;
_nx_tcp_socket_retransmit(ip_ptr, socket_ptr, NX_FALSE);
socket_ptr -> nx_tcp_socket_fast_recovery = NX_FALSE;
socket_ptr -> nx_tcp_socket_tx_window_congestion = socket_ptr -> nx_tcp_socket_tx_slow_start_threshold;
}else if (socket_ptr -> nx_tcp_socket_transmit_sent_head || ((socket_ptr -> nx_tcp_socket_tx_window_advertised == 0) && (socket_ptr -> nx_tcp_socket_state <= NX_TCP_CLOSE_WAIT))) { ... }
else if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_FIN_WAIT_1) ||
(socket_ptr -> nx_tcp_socket_state == NX_TCP_CLOSING) ||
(socket_ptr -> nx_tcp_socket_state == NX_TCP_LAST_ACK))
{
/* ... */
socket_ptr -> nx_tcp_socket_timeout_retries++;
socket_ptr -> nx_tcp_socket_timeout = socket_ptr -> nx_tcp_socket_timeout_rate <<
(socket_ptr -> nx_tcp_socket_timeout_retries * socket_ptr -> nx_tcp_socket_timeout_shift);
_nx_tcp_packet_send_fin(socket_ptr, (socket_ptr -> nx_tcp_socket_tx_sequence - 1));
}else if ((socket_ptr -> nx_tcp_socket_state == NX_TCP_FIN_WAIT_1) || (socket_ptr -> nx_tcp_socket_state == NX_TCP_CLOSING) || (socket_ptr -> nx_tcp_socket_state == NX_TCP_LAST_ACK)) { ... }
else if (socket_ptr -> nx_tcp_socket_state == NX_TCP_TIMED_WAIT)
{
_nx_tcp_socket_block_cleanup(socket_ptr);
}else if (socket_ptr -> nx_tcp_socket_state == NX_TCP_TIMED_WAIT) { ... }
}if (socket_ptr -> nx_tcp_socket_timeout) { ... }
socket_ptr = socket_ptr -> nx_tcp_socket_created_next;
}while (sockets--) { ... }
}{ ... }