0xTCP is an experimental transport-layer engine [RFC-793] written from scratch in Rust. It focuses on robustness and RFC compliance, supporting selective acknowledgments, D-SACK, timestamp options, reassembly queuing, fast recovery, and async integrations for real-world performance testing.
- Sequence & Acknowledgment Number Tracking
- Data Transmission + ACK Handling
- Retransmission Timer
- Duplicate ACK & Fast Retransmit
- Out-of-Order Segments & Reassembly Queue
- Flow Control
- Window Scaling Option (RFC 7323)
- Congestion Control -- Reno, NewReno, Tahoe
- Selective Acknowledgment (SACK) — RFC 2018
- Duplicate SACK (D-SACK) — RFC 2883
- Timestamp Option — RFC 7323
- TCP Fast Open (TFO) — RFC 7413
- Delayed ACKs
- Nagle’s Algorithm
- TCP Keep-Alive
- Asynchronous Runtime Integration
- Packet Reception: Listens on
tun0interface for incoming packets - Parsing: Parses IPv4 and TCP headers from raw packet data
- State Detection: Identifies TCP control flags (SYN, ACK, FIN, RST)
- Response Generation: Creates appropriate TCP responses (currently SYN-ACK for SYN packets)
- Packet Transmission: Frames and sends response packets back through the TUN interface
Client TUN Interface This Program
| | |
|-------- SYN -------->| |
| |-------- SYN ------------->|
| | |
| |<------- SYN-ACK ----------|
|<----- SYN-ACK -------| |
| | |
|-------- ACK -------->| |
| |-------- ACK ------------->|
| | |
tcp/
├── src/
│ ├── main.rs # Main loop and packet reception
│ ├── parser.rs # IPv4 and TCP header parsing
│ ├── tcp.rs # TCP state machine and connection handling
│ ├── packet_sender.rs # Packet framing and checksum calculation
│ ├── sniffer.rs # Packet logging and sniffing
│ └── tcb.rs # Transmission Control Block (placeholder)
├── run.sh # Build and run script with proper setup
└── README.md
- Rust (latest stable version)
- Linux operating system
- Root privileges (for TUN interface and network capabilities)
- Dependencies:
tun-tapcrateetherparsecrate
- Clone the repository:
git clone https://github.com/SWASTIC-7/0xtcp
cd tcp- Build the project:
cargo build --releasechmod +x run.sh
./run.shThe script will:
- Build the project in release mode
- Set network admin capabilities
- Assign IP address
192.168.0.1/24totun0 - Bring up the TUN interface
- Run the TCP implementation
cargo build --release
sudo setcap cap_net_admin=eip ./target/release/tcp
./target/release/tcp &
sudo ip addr add 192.168.0.1/24 dev tun0
sudo ip link set up dev tun0In another terminal, you can test the TCP connection:
# Send a SYN packet
nc 192.168.0.2 80You should see logs showing:
- Incoming SYN packet
- Sequence and acknowledgment numbers
- Outgoing SYN-ACK packet