Browse Source

add traffic debug: PROXY RECV/SEND/FEED for full DATA path tracing on client

congestion
Evgeny 4 months ago
parent
commit
c4e80e6fd7
  1. 11
      src/tcp_proxy.c

11
src/tcp_proxy.c

@ -89,6 +89,7 @@ static int send_connect(struct proxy_conn* pc) {
static int send_data(struct proxy_conn* pc, const uint8_t* data, uint16_t len) { static int send_data(struct proxy_conn* pc, const uint8_t* data, uint16_t len) {
if (!pc->connected) return -1; if (!pc->connected) return -1;
DEBUG_INFO(DEBUG_CATEGORY_TRAFFIC, "PROXY SEND sid=%08x seq=%u len=%u", pc->stream_id, pc->send_seq, len);
int ret = proxy_send_msg(pc->proxy->inst, pc->proxy->via_node_id, int ret = proxy_send_msg(pc->proxy->inst, pc->proxy->via_node_id,
TCP_PROXY_SUBCMD_DATA, pc->stream_id, pc->send_seq, data, len); TCP_PROXY_SUBCMD_DATA, pc->stream_id, pc->send_seq, data, len);
if (ret == 0) pc->send_seq++; if (ret == 0) pc->send_seq++;
@ -162,6 +163,7 @@ static int tcp_proxy_handle_non_tcp(struct tcp_proxy* p, uint8_t* buf, size_t le
static void proxy_feed_from_transport(struct proxy_conn *pc) { static void proxy_feed_from_transport(struct proxy_conn *pc) {
if (!pc->to_lwip || !pc->pcb) return; if (!pc->to_lwip || !pc->pcb) return;
int sent_any = 0; int sent_any = 0;
uint32_t q_pre = queue_entry_count(pc->to_lwip);
while (1) { while (1) {
uint16_t space = tcp_sndbuf(pc->pcb); uint16_t space = tcp_sndbuf(pc->pcb);
if (space < TCP_MSS / 2) break; if (space < TCP_MSS / 2) break;
@ -178,7 +180,13 @@ static void proxy_feed_from_transport(struct proxy_conn *pc) {
queue_resume_callback(pc->to_lwip); queue_resume_callback(pc->to_lwip);
} }
queue_resume_callback(pc->to_lwip); queue_resume_callback(pc->to_lwip);
if (sent_any) tcp_output(pc->pcb); if (sent_any) {
uint32_t unsent = 0; struct tcp_seg* s;
for (s = pc->pcb->unsent; s; s = s->next) unsent++;
DEBUG_DEBUG(DEBUG_CATEGORY_TRAFFIC, "PROXY FEED exit->client sid=%08x fed=%u q=%u->%u snd_wnd=%u cwnd=%u unsent=%u",
pc->stream_id, sent_any, q_pre, queue_entry_count(pc->to_lwip), pc->pcb->snd_wnd, pc->pcb->cwnd, unsent);
tcp_output(pc->pcb);
}
} }
// ==================================================================== // ====================================================================
@ -257,6 +265,7 @@ static err_t proxy_recv_cb(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t
if (send_data(pc, data, len) < 0) DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "PROXY recv send_data failed sid=%08x len=%u", pc->stream_id, len); if (send_data(pc, data, len) < 0) DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "PROXY recv send_data failed sid=%08x len=%u", pc->stream_id, len);
u_free(data); u_free(data);
} else DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "PROXY recv malloc(%u) failed sid=%08x", len, pc->stream_id); } else DEBUG_ERROR(DEBUG_CATEGORY_SOCKET, "PROXY recv malloc(%u) failed sid=%08x", len, pc->stream_id);
DEBUG_INFO(DEBUG_CATEGORY_TRAFFIC, "PROXY RECV client->exit sid=%08x len=%u connected=%d", pc->stream_id, len, pc->connected);
} else { } else {
uint16_t new_len = pc->send_len + len; uint16_t new_len = pc->send_len + len;
uint8_t *new_buf = u_realloc(pc->send_buf, new_len); uint8_t *new_buf = u_realloc(pc->send_buf, new_len);

Loading…
Cancel
Save