This a summary of the question I posted few days ago regarding the
usage of SOCK_RAW provided in BSD socket to implement a new transport protocol
on top of IP. First, below are the partial text of the question posed:
> I would like to use SOCK_RAW provided in BSD socket to implement a new
>transport protocol on top of IP. Regretably, the documentation of SOCK_RAW
>usage is very scare, it is not clearly discussed in BSD documantation, nor the
>two precious books - The design and implementation of 4.3BSD OS (published by
>Addsion-Wesley), and Unix Network Programming (published by Prentice-Hall).
The solution is simple. All u have to do is to specify the
transport layer protocol that you're interested in as the third argument to
socket() -- that's what will be used on input to determine that your user
process is to receive the packets with this protocol value. Also, on output,
IP automatically puts this protocol value into the outgoing IP header.
If the protocol value isn't in in.h, just put in the actual value
you want as the third argument in the socket() call. I have done a testing
on SunOS4.1, it works. However, one of respondent doubt the feasibility of
using SOCK_RAW to implement new transport on top of IP in BSD4.2. Here is
the extract from the mail:
>My experience with BSD 4.1, some derivatives of it, and BSD 4.2, is that
>SOCK_RAW is not completely implemented and in fact cannot be used to develop
>a new protocol despite what the man-pages seem to say. Maybe it's been
>"fixed" since I last looked, but I doubt it...
Using a protocol of 255 (IPPROTO_RAW) lets you build the entire
IP header on output, which is what traceroute does. You have to
be careful with this, as you have to build a correct IP header,
checksum and all. The outcome of specifying a protocol value of 0
is not sure, but it definitely does not achieve thr purpose here.
It seems to be a dummy protocol (see the in.h).
The specific example of using socket (SOCK_RAW) to implement a new protocol
is the gated program. Gated can be ftped from:
Read the source code and enjoy hacking!!
I would to to thank the following people for their help:
Rich Stevens (email@example.com)
Steve D. Miller (steve@umiacs.UMD.EDU)
chuck kollars <ckollars@East.Sun.COM>
Specifically I would like to thank Rich Stevens (firstname.lastname@example.org). He
provides an accurate account of the usage of SOCK_RAW, and the summary is
based on his response and my own testing on SunOS4.1. Again, thanks a lot
for all those who helps.
- Beng Hang (EMAIL: email@example.com)
Dept of Information Systems and Computer Science
National University of Singapore
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:11 CDT