Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define NX_SOURCE_CODE
#include "nx_api.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
#include "nx_packet.h"
#include "nx_tcp.h"
...
...
_nx_tcp_socket_state_transmit_check(NX_TCP_SOCKET *)
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocommon/src/nx_tcp_socket_state_transmit_check.c
 
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
143
144
145
146
147
148
149
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** 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.1 */ /* 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 */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ /* 09-30-2020 Yuxin Zhou Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ 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); }if ((socket_ptr -> nx_tcp_socket_duplicated_ack_received == 1) || (socket_ptr -> nx_tcp_socket_duplicated_ack_received == 2)) { ... } /* 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; }if (tx_window_current > socket_ptr -> nx_tcp_socket_tx_window_advertised) { ... } }if (socket_ptr -> nx_tcp_socket_tx_window_advertised > socket_ptr -> nx_tcp_socket_tx_window_congestion) { ... } else { tx_window_current = socket_ptr -> nx_tcp_socket_tx_window_advertised; }else { ... } /* 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; }if (tx_window_current > socket_ptr -> nx_tcp_socket_tx_outstanding_bytes) { ... } else /* Set tx_window_current to zero. */ { tx_window_current = 0; }else { ... } /* 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); }if (socket_ptr -> nx_tcp_socket_window_update_notify) { ... } /* 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); }if ((tx_window_current) && (socket_ptr -> nx_tcp_socket_transmit_sent_count < socket_ptr -> nx_tcp_socket_transmit_queue_maximum)) { ... } }if (socket_ptr -> nx_tcp_socket_transmit_suspension_list) { ... } }{ ... }