[erlang-questions] low level packet access from erlang

Geoff Cant nem@REDACTED
Wed Apr 3 21:31:19 CEST 2013

It's a bit of a rewrite I think - you get a port program enet_tap that opens the tap device and then does {packet, 2} to/from erlang for forwarding the frames. It uses libevent, but I haven't worked out how fast/slow it goes. It works on OSX and linux.

enet_tap is the erlang module responsible for opening the port and decoding the 'running' vs {'frame', Data} messages. (The 'running' message lets you know when you can ifconfig the device).

enet_eth_iface is my current crazy attempt at representing an ethernet interface in erlang with pubsub for subscribing to ethernet frame types. You don't need to use it to send/receive frames. It's overly complicated right now imo.


On 2013-04-03, at 11:56 , Matthias Lang <matthias@REDACTED> wrote:

> I have a copy of Luke's TUN/TAP code. I successfully used it many
> years ago for some experiments, IIRC to study what TCP did on a lossy
> network. Worked fine for me.
> Luke's code is a thin layer over TUN/TAP, it's just one C file and one
> .erl file. It lets you do two things: receive all packets on an
> ethernet interface and send packets on an ethernet interface. It comes
> with an example to get you started.
> After a _quick_ look at Geoff's code, I think it's _functionally_ a
> superset of Luke's. Geoff's "enet_eth_iface.erl" does pretty much the
> same thing as Luke's "tuntap.erl". The rest of Geoff's code seems to
> be more of the IP stack to let you do more complicated decoding, e.g. TCP.
> Here's Luke's code, it'll be there until next time I clean up:
>  http://corelatus.se/~matthias/luke_tuntap.tgz
> Matt

More information about the erlang-questions mailing list