Browse Source

add lwIP state diagnostics: tcp_alloc cwnd/sndbuf, proxy_poll_cb cwnd/unsent/unacked, active_pcbs counter

congestion
Evgeny 4 months ago
parent
commit
7c668b5d6c
  1. 1
      src/lwip_tcp/lwip_tcp.c
  2. 20
      src/tcp_proxy.c
  3. 4
      tests/tcp_proxy_full/client.conf
  4. 4
      tests/tcp_proxy_full/exit.conf

1
src/lwip_tcp/lwip_tcp.c

@ -1084,6 +1084,7 @@ struct tcp_pcb *tcp_alloc(struct lwip_tcp_ctx *ctx, uint8_t prio)
pcb->sv = 3000 / TCP_SLOW_INTERVAL;
pcb->rtime = -1;
pcb->cwnd = 1;
DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "tcp_alloc: cwnd=%u snd_buf=%u mss=%u snd_wnd=%u", pcb->cwnd, pcb->snd_buf, pcb->mss, pcb->snd_wnd);
pcb->tmr = ctx->ticks;
pcb->last_timer = ctx->slowtmr_ctr;
pcb->ssthresh = TCP_SND_BUF;

20
src/tcp_proxy.c

@ -314,14 +314,16 @@ static err_t proxy_poll_cb(void *arg, struct tcp_pcb *pcb) {
int done = (pending == 0 && pc->pcb->unsent == NULL && pc->pcb->unacked == NULL);
uint32_t sndbuf = tcp_sndbuf(pc->pcb);
if (done || sndbuf == 0) {
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLOSE stream=%016llx tun=1 pending=%u done=%d sndbuf=%u",
(unsigned long long)pc->remote_stream_id, pending, done, sndbuf);
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLOSE stream=%016llx tun=1 pending=%u done=%d sndbuf=%u cwnd=%u unsent=%p unacked=%p",
(unsigned long long)pc->remote_stream_id, pending, done, sndbuf,
pc->pcb->cwnd, (void*)pc->pcb->unsent, (void*)pc->pcb->unacked);
pc->transport->ops->close(pc->transport);
}
}
if (pc->closing_tun && (pc->closing_rem || pc->closing_sent) && pc->pcb) {
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLEANUP stream=%016llx tun=1 rem=%d sent=%d",
(unsigned long long)pc->remote_stream_id, pc->closing_rem, pc->closing_sent);
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLEANUP stream=%016llx tun=1 rem=%d sent=%d cwnd=%u sndbuf=%u unsent=%p unacked=%p",
(unsigned long long)pc->remote_stream_id, pc->closing_rem, pc->closing_sent,
pc->pcb->cwnd, pc->pcb->snd_buf, (void*)pc->pcb->unsent, (void*)pc->pcb->unacked);
struct tcp_pcb *save = pc->pcb;
tcp_arg(save, NULL); pc->pcb = NULL; tcp_close(save);
struct tcp_proxy *proxy = pc->proxy;
@ -728,7 +730,15 @@ void tcp_proxy_etcp_recv_cb(struct ETCP_CONN* conn, struct ll_entry* entry) {
if (delta > 1) {
DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "TCP proxy: seq gap seq=%u last=%u stream=%016llx, tearing down", seq, et->recv_last_seq, (unsigned long long)stream_id);
pc->closing_rem = 1;
if (pc->transport) { pc->transport->ops->destroy(pc->transport); pc->transport = NULL; }
if (pc->transport) { pc->transport->ops->destroy(pc->transport); pc->transport = NULL; }
{
int n_active = 0, n_tw = 0;
struct tcp_pcb* pcb2;
for (pcb2 = proxy->lwip->active_pcbs; pcb2; pcb2 = pcb2->next) n_active++;
for (pcb2 = proxy->lwip->tw_pcbs; pcb2; pcb2 = pcb2->next) n_tw++;
DEBUG_INFO(DEBUG_CATEGORY_SOCKET, "PROXY CLEANUP done stream=%016llx active_pcbs=%d tw_pcbs=%d",
(unsigned long long)pc->remote_stream_id, n_active, n_tw);
}
queue_dgram_free(entry); queue_entry_free(entry); return;
}
et->recv_last_seq = seq;

4
tests/tcp_proxy_full/client.conf

@ -25,5 +25,5 @@ via_node=0xAAAA000000000001
connection=info
socket=info
general=info
traffic=info
tun=info
traffic=debug
tun=debug

4
tests/tcp_proxy_full/exit.conf

@ -20,5 +20,5 @@ enabled=yes
connection=info
socket=info
general=info
traffic=info
tun=info
traffic=debug
tun=debug

Loading…
Cancel
Save