10

For learning purposes I'm implementing TCP (for now just RFC 793) but I have no idea how to test it. Most TUN/TAP stuff on the internet are out of date (e.g. Linux API calls no longer work) and just doesn't explain enough. In addition, I feel like a creating a device and forwarding packages etc. are not the best way for learning purposes. For example, I'd rather only override socket(), listen(), connect(), accept(), send(), recv() etc. in a program rather than forwarding all ethernet traffic to a device/program that does the bookeeping for the whole system rather than for a single program.

I'm wondering if this is possible. If not, I'd like to know the simplest way to test a TCP implementation on Linux.

Because I'm following RFC 793, it'd be great if I could have an IP (Internet Protocol as mentioned in the RFC) API in my application. Is this possible or do I have to mess with TUN/TAP stuff?

Thanks..

1
  • I am trying to better understand your question. Do you have a TCP stack which you have implemented and you want to be able to test that? There are at-least two ways you can, you want to test your TCP stack as a server and then connect any 'standard' client (like telnet to it.). Some heavy lifting you have to do is - to be able to implement listen and accept like functionality yourself on the TCP stack - but that would be a starting point - Assume - you get input IP datagrams. The other way is to test it as a client, first. Commented Sep 1, 2017 at 17:57

3 Answers 3

2

If we talk about research I strongly recommend you read Engineering with Logic: Rigorous Test-Oracle Specification and Validation for TCP/IP and the Sockets API

It contains section about testing TCP/IP implementation: "EXPERIMENTAL VALIDATION: TESTING INFRASTRUCTURE"

Sign up to request clarification or add additional context in comments.

Comments

1
+200

You could try setting up two peers, one using a RAW socket and the other a TCP socket.

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

C sockets

C RAW sockets

C TCP implementation

Comments

0

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

enter image description here

It could simply be done with wireshark or other sniffer. When testing you will see all tcp packets with bits you've sent.

enter image description here

In order you want to see linux system calls which your application are calling, you can use GDB or any other debugger.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.