OSI Layer 2 Network Programming

6.4k views Asked by At

I've recently taken some classes in networking (CCNA 1 through 4), so I understand most of the theory behind it all. What I'd like to do now is take that knowledge I have and put it into practice in the form of some small applications.

I've been reading through some articles on MSDN on how to do this, but they seem to only cover network programming at layer 3 or 4 and upwards, IIRC. What I'm looking for is some simple examples of how to deal with layer two connectivity (ie. framing) between hosts, or even just something simple like how to perform an Ethernet broadcast.

I have a little experience with C# and C++, so examples which use either of those languages would be great.

Thanks.

3

There are 3 answers

0
cmeerw On BEST ANSWER

For Windows, have a look at WinPcap which provides low-level network access. The developer pack already contains some simple examples to get you started.

BTW, on Linux there are packet sockets.

0
Basile Starynkevitch On

Very probably, you could study low-level network utilities on GNU/Linux systems, or also look into the kernel TCP or UDP or IP layers. But for instance, doing an Ethernet broadcast is something very low level, and not very useful. And real examples (usually coded in C, not C++) probably can't be simple because they have to deal with error handling.

0
Emiswelt On

You could use the eEx Network Library to write small apps (I have done the same thing during my CCNA).

It is an easy-to-use and object-oriented .Net programming library, which lets you go down to layer 2 and send out custom frames via WinPcap.

Frame types like Ethernet, ARP, IP, UDP, TCP and RIP are implemented, and as far as I know, these are protocols which occur during CCNA.

Tutorials in C# are available here, and if you want look at something in depth, like address resolution, you can always have a look at the source code, since the library is open source.