|

楼主 |
发表于 2021-12-19 09:19:40
|
显示全部楼层
TCP包的结构体定义如下:
- /* Define the basic TCP socket structure. This structure is used to manage all information
- necessary to manage TCP transmission and reception. */
- typedef struct NX_TCP_SOCKET_STRUCT
- {
- /* Define the TCP identification that is used to determine if the TCP socket has
- been created. */
- ULONG nx_tcp_socket_id;
- /* Define the Application defined name for this TCP socket instance. */
- CHAR *nx_tcp_socket_name;
- /* Define the socket type flag. If true, this socket is a client socket. */
- UINT nx_tcp_socket_client_type;
- /* Define the TCP port that was bound to. */
- UINT nx_tcp_socket_port;
- /* Define the TCP socket's maximum segment size (mss). By default, this is setup to the
- IP's MTU less the size of the IP and TCP headers. */
- ULONG nx_tcp_socket_mss;
- /* Define the connected IP and port information. */
- NXD_ADDRESS nx_tcp_socket_connect_ip;
- UINT nx_tcp_socket_connect_port;
- ULONG nx_tcp_socket_connect_mss;
- ULONG nx_tcp_socket_peer_mss;
- struct NX_INTERFACE_STRUCT
- *nx_tcp_socket_connect_interface;
- ULONG nx_tcp_socket_next_hop_address;
- /* mss2 is the holding place for the smss * smss value.
- It is computed and stored here once for later use. */
- ULONG nx_tcp_socket_connect_mss2;
- ULONG nx_tcp_socket_tx_slow_start_threshold;
- /* Define the state of the TCP connection. */
- UINT nx_tcp_socket_state;
- /* Define the receive and transmit sequence numbers. */
- ULONG nx_tcp_socket_tx_sequence;
- ULONG nx_tcp_socket_rx_sequence;
- ULONG nx_tcp_socket_rx_sequence_acked;
- ULONG nx_tcp_socket_delayed_ack_timeout;
- ULONG nx_tcp_socket_fin_sequence;
- USHORT nx_tcp_socket_fin_received;
- USHORT nx_tcp_socket_fin_acked;
- /* Track the advertised window size */
- ULONG nx_tcp_socket_tx_window_advertised;
- ULONG nx_tcp_socket_tx_window_congestion;
- ULONG nx_tcp_socket_tx_outstanding_bytes; /* Data transmitted but not acked. */
- /* Define the transmit sequence that enters fast transmit. */
- ULONG nx_tcp_socket_tx_sequence_recover;
- /* Define the previous cumulative acknowledgment. */
- ULONG nx_tcp_socket_previous_highest_ack;
- /* Counter for "ack-N-packet" */
- ULONG nx_tcp_socket_ack_n_packet_counter;
- /* Counter for duplicated ACK */
- UINT nx_tcp_socket_duplicated_ack_received;
- /* Define the window size fields of the TCP socket structure. */
- ULONG nx_tcp_socket_rx_window_default;
- ULONG nx_tcp_socket_rx_window_current;
- ULONG nx_tcp_socket_rx_window_last_sent;
- /* Define the statistic and error counters for this TCP socket. */
- ULONG nx_tcp_socket_packets_sent;
- ULONG nx_tcp_socket_bytes_sent;
- ULONG nx_tcp_socket_packets_received;
- ULONG nx_tcp_socket_bytes_received;
- ULONG nx_tcp_socket_retransmit_packets;
- ULONG nx_tcp_socket_checksum_errors;
- /* Define data for zero window probe. */
- ULONG nx_tcp_socket_zero_window_probe_failure;
- ULONG nx_tcp_socket_zero_window_probe_sequence;
- UCHAR nx_tcp_socket_zero_window_probe_has_data;
- UCHAR nx_tcp_socket_zero_window_probe_data;
- /* Define whether or not TCP socket is in fast recovery procedure. */
- UCHAR nx_tcp_socket_fast_recovery;
- /* Reserved to four bytes alignment. */
- /*lint -esym(768,NX_TCP_SOCKET_STRUCT::nx_tcp_socket_reserved) suppress member not referenced. It is reserved for future use. */
- UCHAR nx_tcp_socket_reserved;
- /* Define the entry that this TCP socket belongs to. */
- struct NX_IP_STRUCT
- *nx_tcp_socket_ip_ptr;
- /* Define the type of service for this TCP instance. */
- ULONG nx_tcp_socket_type_of_service;
- /* Define the time-to-live for this TCP instance. */
- UINT nx_tcp_socket_time_to_live;
- /* Define the fragment enable bit for this TCP instance. */
- ULONG nx_tcp_socket_fragment_enable;
- /* Define the TCP receive packet queue pointers, queue counter, and
- the maximum queue depth. */
- ULONG nx_tcp_socket_receive_queue_count;
- NX_PACKET *nx_tcp_socket_receive_queue_head,
- *nx_tcp_socket_receive_queue_tail;
- /* Define the TCP packet sent queue. This queue is used to keep track of the
- transmit packets already send. Before they can be released we need to receive
- an ACK back from the other end of the connection. If no ACK is received, the
- packet(s) need to be re-transmitted. */
- ULONG nx_tcp_socket_transmit_queue_maximum;
- ULONG nx_tcp_socket_transmit_sent_count;
- NX_PACKET *nx_tcp_socket_transmit_sent_head,
- *nx_tcp_socket_transmit_sent_tail;
- /* Define the maximum TCP packet receive queue. */
- #ifdef NX_ENABLE_LOW_WATERMARK
- ULONG nx_tcp_socket_receive_queue_maximum;
- #endif /* NX_ENABLE_LOW_WATERMARK */
- /* Define the TCP transmit timeout parameters. If the socket timeout is non-zero,
- there is an active timeout on the TCP socket. Subsequent timeouts are derived
- from the timeout rate, which is adjusted higher as timeouts occur. */
- ULONG nx_tcp_socket_timeout;
- ULONG nx_tcp_socket_timeout_rate;
- ULONG nx_tcp_socket_timeout_retries;
- ULONG nx_tcp_socket_timeout_max_retries;
- ULONG nx_tcp_socket_timeout_shift;
- #ifdef NX_ENABLE_TCP_WINDOW_SCALING
- /* Local receive window size, when user creates the TCP socket. */
- ULONG nx_tcp_socket_rx_window_maximum;
- /* Window scale this side needs to offer to the peer. */
- ULONG nx_tcp_rcv_win_scale_value;
- /* Window scale offered by the peer. 0xFF indicates the peer does not support window scaling. */
- ULONG nx_tcp_snd_win_scale_value;
- #endif /* NX_ENABLE_TCP_WINDOW_SCALING */
- /* Define the TCP keepalive timer parameters. If enabled with NX_ENABLE_TCP_KEEPALIVE,
- these parameters are used to implement the keepalive timer. */
- #ifdef NX_ENABLE_TCP_KEEPALIVE
- ULONG nx_tcp_socket_keepalive_timeout;
- ULONG nx_tcp_socket_keepalive_retries;
- #endif /* NX_ENABLE_TCP_KEEPALIVE */
- /* Define the TCP socket bound list. These pointers are used to manage the list
- of TCP sockets on a particular hashed port index. */
- struct NX_TCP_SOCKET_STRUCT
- *nx_tcp_socket_bound_next,
- *nx_tcp_socket_bound_previous;
- /* Define the TCP socket bind suspension thread pointer. This pointer points
- to the thread that that is suspended attempting to bind to a port that is
- already bound to another socket. */
- TX_THREAD *nx_tcp_socket_bind_in_progress;
- /* Define the TCP receive suspension list head associated with a count of
- how many threads are suspended attempting to receive from the same TCP port. */
- TX_THREAD *nx_tcp_socket_receive_suspension_list;
- ULONG nx_tcp_socket_receive_suspended_count;
- /* Define the TCP transmit suspension list head associated with a count of
- how many threads are suspended attempting to transmit from the same TCP port. */
- TX_THREAD *nx_tcp_socket_transmit_suspension_list;
- ULONG nx_tcp_socket_transmit_suspended_count;
- /* Define the TCP connect suspension pointer that contains the pointer to the
- thread suspended attempting to establish a TCP connection. */
- TX_THREAD *nx_tcp_socket_connect_suspended_thread;
- /* Define the TCP disconnect suspension pointer that contains the pointer to the
- thread suspended attempting to break a TCP connection. */
- TX_THREAD *nx_tcp_socket_disconnect_suspended_thread;
- /* Define the TCP bind suspension list head associated with a count of
- how many threads are suspended attempting to bind to the same TCP port. The
- currently bound socket will maintain the head pointer. When a socket unbinds,
- the head of the suspension list is given the port and the remaining entries
- of the suspension list are transferred to its suspension list head pointer. */
- TX_THREAD *nx_tcp_socket_bind_suspension_list;
- ULONG nx_tcp_socket_bind_suspended_count;
- /* Define the link between other TCP structures created by the application. This
- is linked to the IP instance the socket was created on. */
- struct NX_TCP_SOCKET_STRUCT
- *nx_tcp_socket_created_next,
- *nx_tcp_socket_created_previous;
- /* Define the callback function for urgent data reception. This is for future use. */
- VOID (*nx_tcp_urgent_data_callback)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT
- /* Define the callback function for notifying an incoming SYN request. */
- UINT (*nx_tcp_socket_syn_received_notify)(struct NX_TCP_SOCKET_STRUCT *socket_ptr, NX_PACKET *packet_ptr);
- /* Define the callback function for notifying the host application of a connection handshake completion
- with a remote host. */
- VOID (*nx_tcp_establish_notify)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- /* Define the callback function for notifying the host application of disconnection completion
- with a remote host. */
- VOID (*nx_tcp_disconnect_complete_notify)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- /* Define the callback function for notifying the host application to set the socket
- state in the timed wait state. */
- VOID (*nx_tcp_timed_wait_callback)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- #endif
- /* Define the callback function for disconnect detection from the other side of
- the connection. */
- VOID (*nx_tcp_disconnect_callback)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- /* Define the callback function for receive packet notification. If specified
- by the application, this function is called whenever a receive packet is
- available on for the socket. */
- VOID (*nx_tcp_receive_callback)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- /* Define the callback function for receive packet notification. If specified
- by the application, this function is called whenever a receive packet is
- available on for the socket. */
- VOID (*nx_tcp_socket_window_update_notify)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- #ifdef NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY
- VOID (*nx_tcp_socket_queue_depth_notify)(struct NX_TCP_SOCKET_STRUCT *socket_ptr);
- #endif
- /* This pointer is reserved for application specific use. */
- /*lint -esym(768,NX_TCP_SOCKET_STRUCT::nx_tcp_socket_reserved_ptr) suppress member not referenced. It is reserved for application specific use. */
- void *nx_tcp_socket_reserved_ptr;
- /* Define the default maximum queue size. This is necessary to dynamically
- change the maximum queue size dynamically. */
- ULONG nx_tcp_socket_transmit_queue_maximum_default;
- /* Define a flag for enabling the keepalive feature per TCP socket. */
- #ifdef NX_ENABLE_TCP_KEEPALIVE
- UINT nx_tcp_socket_keepalive_enabled;
- #endif /* NX_ENABLE_TCP_KEEPALIVE */
- #ifdef FEATURE_NX_IPV6
- struct NXD_IPV6_ADDRESS_STRUCT *nx_tcp_socket_ipv6_addr;
- #endif /* FEATURE_NX_IPV6 */
- #ifdef NX_IPSEC_ENABLE
- /* Stores a pointer to the SA, if the traffic needs to be protected. */
- VOID *nx_tcp_socket_egress_sa;
- /* Number of bytes to offset from IP header. This offset is needed to accommondate security header. */
- UINT nx_tcp_socket_egress_sa_data_offset;
- #endif /* NX_IPSEC_ENABLE */
- /* Define the port extension in the TCP socket control block. This
- is typically defined to whitespace in nx_port.h. */
- NX_TCP_SOCKET_MODULE_EXTENSION
-
- } NX_TCP_SOCKET;
复制代码
|
|