smoltcp icon indicating copy to clipboard operation
smoltcp copied to clipboard

Undertanding TCP Implementation

Open rvbcldud opened this issue 1 year ago • 1 comments
trafficstars

Hello! I am rather new to the code base and am interested in using smoltcp. I am, however, having a hard time seeing at how some of it works when I am looking through the code base. Bare in mind that I am not an expert at Rust or networking, but I want to learn more!

More specifically... https://github.com/smoltcp-rs/smoltcp/blob/23697fa766d899fd30241aaf02c4a67efbccd204/src/socket/tcp.rs#L906 I have been looking through the examples. When a socket seeks to establish a connection it calls socket.connect() which should initiate the handshake with a SYN. In connect it seems that the state of the socket is set to SynSent, but I am failing to see where the actual transmission of a SYN occurs. Please help me understand. In general, any advice on better understanding smoltcp would be a huge help. Thank you!

rvbcldud avatar Jul 01 '24 23:07 rvbcldud

here

https://github.com/smoltcp-rs/smoltcp/blob/23697fa766d899fd30241aaf02c4a67efbccd204/src/socket/tcp.rs#L2301-L2310

The TcpSocket methods just get/set state in the struct, and it's fn dispatch that sends packets that need to be sent based on the state.

Dirbaio avatar Jul 02 '24 00:07 Dirbaio