tcp: extend TcpInfo with send/recv queue, congestion window, MSS

TCP_INFO socket option now returns real-time connection metrics:
- tcpi_snd_queuelen: bytes queued for transmission
- tcpi_rcv_queuelen: bytes waiting in receive buffer
- tcpi_snd_cwnd: send capacity (congestion window proxy)
- tcpi_rcv_wnd: receive capacity (advertised window proxy)
- tcpi_snd_mss: maximum segment size (1460 for Ethernet)
- tcpi_state, tcpi_rto preserved from prior version

Struct layout: #[repr(C)] 28 bytes, compatible with Linux TCP_INFO consumers.
This commit is contained in:
Red Bear OS
2026-07-08 14:30:05 +03:00
parent 748f066a6e
commit 0baceb0ef6
2 changed files with 9 additions and 2 deletions
+1 -2
View File
@@ -107,8 +107,7 @@ fn mk_root_node(
"list" => {
ro [socket_set] || {
let set = socket_set.borrow();
let mut out = format!("sockets: {}\n", set.iter().count());
out
format!("sockets: {}\n", set.iter().count())
}
}
},
+8
View File
@@ -481,7 +481,11 @@ impl<'a> SchemeSocket for TcpSocket<'a> {
tcpi_state: self.state() as u8,
_pad: [0; 3],
tcpi_snd_queuelen: self.send_queue() as u32,
tcpi_rcv_queuelen: self.recv_queue() as u32,
tcpi_rto: 3000,
tcpi_snd_cwnd: self.send_capacity() as u32,
tcpi_rcv_wnd: self.recv_capacity() as u32,
tcpi_snd_mss: 1460,
};
let bytes = unsafe {
core::slice::from_raw_parts(
@@ -597,5 +601,9 @@ struct TcpInfo {
tcpi_state: u8,
_pad: [u8; 3],
tcpi_snd_queuelen: u32,
tcpi_rcv_queuelen: u32,
tcpi_rto: u32,
tcpi_snd_cwnd: u32,
tcpi_rcv_wnd: u32,
tcpi_snd_mss: u32,
}