How to check custom TCP implementation on Linux?

For training purposes, I implement TCP (currently only RFC 793), but I have no idea how to test it. Most TUN / TAP materials on the Internet are out of date (for example, the Linux API API no longer works) and simply does not explain enough. In addition, I feel like creating a device and forwarding packets, etc., is not the best way for training purposes. For example, I would prefer only to redefine socket() , listen() , connect() , accept() , send() , recv() , etc. in the program, rather than redirecting all network traffic to a device / program that performs accounting for the entire system, and not for one program.

I am wondering if this is possible. If not, I would like to find out the simplest way to test the TCP implementation on Linux.

Since I am following RFC 793, it would be great if I had the IP (Internet Protocol mentioned in RFC) API in my application. Is this possible or Do I need to tinker with TUN / TAP materials?

Thanks..

+8
linux networking tcp
source share
3 answers

If we talk about research, I highly recommend that you read Engineering with Logic: Rigorous Test-Oracle Specification and Verification for TCP / IP and Socket APIs

It contains a section on testing the TCP / IP implementation: "EXPERIMENTAL VALIDATION: TEST INFRASTRUCTURE"

+3
source share

You can try to configure two peers, one using a RAW socket and the other using TCP sockets.

If they can communicate and packets are actually delivered / recovered in the same way as TCP, you know that your custom implementation is successful.

C sockets

C RAW Sockets

C TCP implementation

+1
source share

All you need is to intercept all the tcp packets with bits (syn, ack, fin, etc.) sent by your application and see if it works correctly:

enter image description here

This can simply be done using a conductor or another sniffer. When testing, you will see all tcp packets with the bits that you sent.

enter image description here

In order for you to want to see the Linux system calls caused by your application, you can use GDB or any other debugger.

0
source share

All Articles