LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to modify the TCP/IP mechanism? (https://www.linuxquestions.org/questions/programming-9/how-to-modify-the-tcp-ip-mechanism-590992/)

TimeSync 10-11-2007 03:05 AM

How to modify the TCP/IP mechanism?
 
Please help!

I am doing an experiment on client-server TCP socket mechanism. I wanted to modify how the client and server exchange messages. Is there anyone who can give me a hint on how to do it, what kernel module should modify and other related things.

Thank you very much.

AJ

theNbomr 10-11-2007 09:35 AM

Without knowing more about what sort of changes you intend to make, it is difficult to advise you. The Berkley sockets API is pretty standard and seems to have served most peoples' objectives over the years. Why do you need to do this?
Perhaps you simply need to use the 'raw packets', PF_PACKET, mode. This allows you to format and send raw ethernet packets in whatever way you choose. The downside is that you will have to design a lot of the functionality that the existing TCP & UDP methods provide, and that the application will need to run with root privileges.
--- rod.

TimeSync 10-11-2007 11:58 PM

How to modify the TCP/IP mechanism?
 
Thanks for the reply. What I really wanted to do is to modify the handshaking procedure in establishing a TCP connection, at the same time, be able to edit the header and do some functions. So do you think this would be possible? Could it be done in user space? connect() function is responsible for three-way handshaking, but I wanted to modify it. So I thought, I need to modify the kernel. I know this would be a deviation to the TCP protocol, but this experiment is only for my research project. I am not an expert linux kernel programmer, so I dont really know where to start.

Thanks again!

Mara 10-12-2007 03:04 PM

The question is if you can use a simulator, like ns-2 to test your machanisms or you need to use the 'live' system. The question is not trivial...

TCP is done in the kernel space and there are only limited points you can change the packets during their pass through the kernel code. Look for netfilter hooks. They allos you to use your own modules to deal with the packets. They are not TCP-specific and are run after the TCP header is already finished, what may be a plus.

The modification of the live Linux TCP implementation is rather hard, as it's complicated piece of code and every change requires extensive testing.

Note that connect() does not have the whole handshaking, only a part of it. The other part is run as a reaction to the received packets. Depending on your needs, you may need to change quite many places (especially the state machine).


All times are GMT -5. The time now is 03:41 PM.