*BSD News Article 93843


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!sol.ctr.columbia.edu!startide.ctr.columbia.edu!wpaul
From: wpaul@ctr.columbia.edu (Bill Paul)
Newsgroups: comp.unix.bsd.freebsd.misc,comp.protocols.tcp-ip
Subject: Re: Q: Raw sockets to buypass tcp/udp?
Followup-To: comp.unix.bsd.freebsd.misc,comp.protocols.tcp-ip
Date: 18 Apr 1997 14:10:10 GMT
Organization: Columbia University Center for Telecommunications Research
Lines: 41
Message-ID: <5j7vc3$1es$1@sol.ctr.columbia.edu>
References: <33551811.6113@snads.lkg.dec.com>
NNTP-Posting-Host: startide.ctr.columbia.edu
X-Newsreader: TIN [version 1.2 PL2]
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:39286 comp.protocols.tcp-ip:53124


Daring to challenge the will of the almighty Leviam00se, Michael C. Cambria
(cambria@snads.lkg.dec.com) had the courage to say:

: Hi,

: I need to prototype sone networking software.  Since I can pick how
: and where this is done, I'm choosing FreeBSD 2.2.1

: First, I need to be able to send and receive my own "layer 3" packets
: but continue to use the FreeBSD IP.  Put simply, I want to replace
: TCP and UDP with my own.  What is the proper way to do this?  Is it
: even possible?

: Second, I need to put my own 802.2 packets (ie. no IP layer) for my
: own "layer 2" on the LAN.  What is the proper way to do this?

I think the answer to both these questions is: the Berkeley Packet Filter
(BPF). If you have a) an ethernet card that supports it, and b) have it
configured into your kernel, BPF will let you read raw frames right off
the ethernet card and transmit them as well. I would also look at libpcap,
which uses BPF internally (libpcap is used by tcpdump). One example program
that uses BPF for receiving and tranmitting is rarpd; it needs to receive
and send ETHERTYPE_REVARP frames directly.

The only problem with BPF is that programming it can be tricky; you can
set up instructions to have BPF capture only certain packets with features
that you're interested in. This will cut down on the amount of processing
your program has to do: you can receive all packets that arrive at the
interface if you want, but then your own program will have to analyze them
and decide whether or not they're important.

-Bill

--
=============================================================================
-Bill Paul            (212) 854-6020 | System Manager, Master of Unix-Fu
Work:         wpaul@ctr.columbia.edu | Center for Telecommunications Research
Home:  wpaul@skynet.ctr.columbia.edu | Columbia University, New York City
=============================================================================
  "Now, that's "Open" as used in the sentence "Open your wallet", right?"
=============================================================================