Lwip里的tcp的Protocol Control Block
2021/9/12 6:05:12
本文主要是介绍Lwip里的tcp的Protocol Control Block,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 /** the TCP protocol control block */ 2 struct tcp_pcb { 3 /** common PCB members */ 4 IP_PCB; 5 /** protocol specific PCB members */ 6 TCP_PCB_COMMON(struct tcp_pcb); 7 8 /* ports are in host byte order */ 9 u16_t remote_port; 10 11 tcpflags_t flags; 12 #define TF_ACK_DELAY 0x01U /* Delayed ACK. */ 13 #define TF_ACK_NOW 0x02U /* Immediate ACK. */ 14 #define TF_INFR 0x04U /* In fast recovery. */ 15 #define TF_CLOSEPEND 0x08U /* If this is set, tcp_close failed to enqueue the FIN (retried in tcp_tmr) */ 16 #define TF_RXCLOSED 0x10U /* rx closed by tcp_shutdown */ 17 #define TF_FIN 0x20U /* Connection was closed locally (FIN segment enqueued). */ 18 #define TF_NODELAY 0x40U /* Disable Nagle algorithm */ 19 #define TF_NAGLEMEMERR 0x80U /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ 20 #if LWIP_WND_SCALE 21 #define TF_WND_SCALE 0x0100U /* Window Scale option enabled */ 22 #endif 23 #if TCP_LISTEN_BACKLOG 24 #define TF_BACKLOGPEND 0x0200U /* If this is set, a connection pcb has increased the backlog on its listener */ 25 #endif 26 #if LWIP_TCP_TIMESTAMPS 27 #define TF_TIMESTAMP 0x0400U /* Timestamp option enabled */ 28 #endif 29 #define TF_RTO 0x0800U /* RTO timer has fired, in-flight data moved to unsent and being retransmitted */ 30 #if LWIP_TCP_SACK_OUT 31 #define TF_SACK 0x1000U /* Selective ACKs enabled */ 32 #endif 33 34 /* the rest of the fields are in host byte order 35 as we have to do some math with them */ 36 37 /* Timers */ 38 u8_t polltmr, pollinterval; 39 u8_t last_timer; 40 u32_t tmr; 41 42 /* receiver variables */ 43 u32_t rcv_nxt; /* next seqno expected */ 44 tcpwnd_size_t rcv_wnd; /* receiver window available */ 45 tcpwnd_size_t rcv_ann_wnd; /* receiver window to announce */ 46 u32_t rcv_ann_right_edge; /* announced right edge of window */ 47 48 #if LWIP_TCP_SACK_OUT 49 /* SACK ranges to include in ACK packets (entry is invalid if left==right) */ 50 struct tcp_sack_range rcv_sacks[LWIP_TCP_MAX_SACK_NUM]; 51 #define LWIP_TCP_SACK_VALID(pcb, idx) ((pcb)->rcv_sacks[idx].left != (pcb)->rcv_sacks[idx].right) 52 #endif /* LWIP_TCP_SACK_OUT */ 53 54 /* Retransmission timer. */ 55 s16_t rtime; 56 57 u16_t mss; /* maximum segment size */ 58 59 /* RTT (round trip time) estimation variables */ 60 u32_t rttest; /* RTT estimate in 500ms ticks */ 61 u32_t rtseq; /* sequence number being timed */ 62 s16_t sa, sv; /* @see "Congestion Avoidance and Control" by Van Jacobson and Karels */ 63 64 s16_t rto; /* retransmission time-out (in ticks of TCP_SLOW_INTERVAL) */ 65 u8_t nrtx; /* number of retransmissions */ 66 67 /* fast retransmit/recovery */ 68 u8_t dupacks; 69 u32_t lastack; /* Highest acknowledged seqno. */ 70 71 /* congestion avoidance/control variables */ 72 tcpwnd_size_t cwnd; 73 tcpwnd_size_t ssthresh; 74 75 /* first byte following last rto byte */ 76 u32_t rto_end; 77 78 /* sender variables */ 79 u32_t snd_nxt; /* next new seqno to be sent */ 80 u32_t snd_wl1, snd_wl2; /* Sequence and acknowledgement numbers of last 81 window update. */ 82 u32_t snd_lbb; /* Sequence number of next byte to be buffered. */ 83 tcpwnd_size_t snd_wnd; /* sender window */ 84 tcpwnd_size_t snd_wnd_max; /* the maximum sender window announced by the remote host */ 85 86 tcpwnd_size_t snd_buf; /* Available buffer space for sending (in bytes). */ 87 #define TCP_SNDQUEUELEN_OVERFLOW (0xffffU-3) 88 u16_t snd_queuelen; /* Number of pbufs currently in the send buffer. */ 89 90 #if TCP_OVERSIZE 91 /* Extra bytes available at the end of the last pbuf in unsent. */ 92 u16_t unsent_oversize; 93 #endif /* TCP_OVERSIZE */ 94 95 tcpwnd_size_t bytes_acked; 96 97 /* These are ordered by sequence number: */ 98 struct tcp_seg *unsent; /* Unsent (queued) segments. */ 99 struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ 100 #if TCP_QUEUE_OOSEQ 101 struct tcp_seg *ooseq; /* Received out of sequence segments. */ 102 #endif /* TCP_QUEUE_OOSEQ */ 103 104 struct pbuf *refused_data; /* Data previously received but not yet taken by upper layer */ 105 106 #if LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG 107 struct tcp_pcb_listen* listener; 108 #endif /* LWIP_CALLBACK_API || TCP_LISTEN_BACKLOG */ 109 110 #if LWIP_CALLBACK_API 111 /* Function to be called when more send buffer space is available. */ 112 tcp_sent_fn sent; 113 /* Function to be called when (in-sequence) data has arrived. */ 114 tcp_recv_fn recv; 115 /* Function to be called when a connection has been set up. */ 116 tcp_connected_fn connected; 117 /* Function which is called periodically. */ 118 tcp_poll_fn poll; 119 /* Function to be called whenever a fatal error occurs. */ 120 tcp_err_fn errf; 121 #endif /* LWIP_CALLBACK_API */ 122 123 #if LWIP_TCP_TIMESTAMPS 124 u32_t ts_lastacksent; 125 u32_t ts_recent; 126 #endif /* LWIP_TCP_TIMESTAMPS */ 127 128 /* idle time before KEEPALIVE is sent */ 129 u32_t keep_idle; 130 #if LWIP_TCP_KEEPALIVE 131 u32_t keep_intvl; 132 u32_t keep_cnt; 133 #endif /* LWIP_TCP_KEEPALIVE */ 134 135 /* Persist timer counter */ 136 u8_t persist_cnt; 137 /* Persist timer back-off */ 138 u8_t persist_backoff; 139 /* Number of persist probes */ 140 u8_t persist_probe; 141 142 /* KEEPALIVE counter */ 143 u8_t keep_cnt_sent; 144 145 #if LWIP_WND_SCALE 146 u8_t snd_scale; 147 u8_t rcv_scale; 148 #endif 149 };
这篇关于Lwip里的tcp的Protocol Control Block的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-25【机器学习(二)】分类和回归任务-决策树(Decision Tree,DT)算法-Sentosa_DSML社区版
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享