Ip tunnelling

Asked by Bins

Dear Didier,

I used your tunnel.c as a basis for doing my IP header compression. I tried with transport layer tunelling too...
Could you please tell me how I can do IP layer tunnelling. Once I get the data on to the tunnel from the IP layer, I compress it and then I want to send it to IP layer instead of UDP layer.

Could you please tell me how I can achieve it. How do I write the data to IP layer.

Regards,
Bindhia

Question information

Language:
English Edit question
Status:
Solved
For:
rohc Edit question
Assignee:
No assignee Edit question
Solved by:
Didier Barvaux
Solved:
Last query:
Last reply:
Revision history for this message
Didier Barvaux (didier-barvaux) said :
#1

Hello,

To write the data to IP layer you have to create a RAW socket instead of the INET one. Read the man page raw(7) for details [1]. If the man page is not enough, you may easily find tutorials for using RAW sockets on the web.

Regards,
Didier

[1] http://linux.die.net/man/7/raw

Revision history for this message
Bins (bindhia-komath) said :
#2

Thanks Didier.
So what I understand is once the data is available on the tunnel , I compress it and then create an IP Header of my own and then write it back to the raw socket. Once the write on raw socket happens, it actually write to the IP layer... and then the kernel will take care of transmitting the packet out of the machine....

Am I right Didier ?

Thanks in advance.

Revision history for this message
Best Didier Barvaux (didier-barvaux) said :
#3

Re,

You're right, except that you do not need to create a IP header. Without the IP_HDRINCL option (the default), the IP header is built automatically by the kernel. The man page says "The IPv4 layer generates an IP header when sending a packet unless the IP_HDRINCL socket option is enabled on the socket".

Regards,
Didier

Revision history for this message
Bins (bindhia-komath) said :
#4

Thanks a lot Didier.
Will try it out.

Revision history for this message
Bins (bindhia-komath) said :
#5

Thanks Didier Barvaux, that solved my question.