Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSI Layer 2 Network Programming

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.

like image 308
daniel Avatar asked Oct 16 '11 09:10

daniel


2 Answers

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.

like image 170
cmeerw Avatar answered Sep 20 '22 05:09

cmeerw


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.

like image 40
Emiswelt Avatar answered Sep 19 '22 05:09

Emiswelt