0

I know this is vague but even just referring me elsewhere would be much appreciated.

I am trying to write a program with C#. I want to manually collect any data packets off of an Ethernet cable with my program. Is there some driver in the .NET framework for this? Where can I start? I don't know much about this so any guidance would be appreciated.

Thanks! Evan

Evan L
  • 37
  • 1
  • 12

2 Answers2

3

Have a look at Pcap.Net. Documentation with examples is here.

If you are interested in packet sniffing, you must have worked with Wireshark which uses WinPcap library for live packet capture. Pcap.Net is a C# wrapper for WinPcap.

Bojan Komazec
  • 9,216
  • 2
  • 41
  • 51
  • I have heard of wire shark but I haven't used it. I'm very new to this but I will read through this. I really appreciate the reply. – Evan L Apr 27 '15 at 23:42
  • @EvanL Then, downloading and playing a bit with Wireshark is time well invested. It is one of the "must haves", once you dabble in networking. – BitTickler Apr 28 '15 at 01:10
2

Maybe this can help you a bit : Similar question

Are you sure you need/want to pick up raw ethernet data packets? I don't really see the point of trying to reimplement protocols like udp and others.

enter image description here

Like you see there are layers above you can use, which are much less complicated.

Community
  • 1
  • 1
Kevin
  • 2,813
  • 3
  • 20
  • 30
  • Maybe he has to build a test system for some layer 2 protocol. Usually, questioning the motivation for a question does not really carry far. – BitTickler Apr 27 '15 at 23:17
  • That's why I linked the other similar question if he really wants to do so. If that's not the case he can have a look at higher layers like udp or tcp/ip. – Kevin Apr 27 '15 at 23:29
  • 1
    I am actually really glad you asked this. This is my basic system: an FPGA is handling data and using a ADC to make packets. That half of the system should be irrelevant. The Ethernet cable is connected directly from the FPGA to the host PC. I am working with the host PC to receive and display this data. Does this now make more sense? I like hearing what people think because this doesn't seem to be done often. If a protocol is more convenient, how do I use such a protocol? I know embarrassingly little about this. – Evan L Apr 27 '15 at 23:36
  • Ideally, I want to use the Ethernet cable as a high speed serial cable. – Evan L Apr 27 '15 at 23:44
  • I found an article about making up such a communication protocol based on FPGA. Maybe that can be useful. But I can't help you more with this. http://www.ijera.com/papers/Vol3_issue2/IK3215041509.pdf – Kevin Apr 28 '15 at 00:20
  • Depending on whether it is a lab-project or some product to be sold to customers, I would evaluate existing options differently. It also might depend on the size/type of FPGA you use. The lowest level would be to create Eternet frames with a dedicated ether-type. But this will bear integration problems and possibly wonky drivers on the PCs as a consequence. So, if your FPGA allows for a soft CPU core, I would probably opt to go to layer 3 and use UDP or something, which eases PC integration up A LOT. – BitTickler Apr 28 '15 at 00:57
  • For a product, the overall usability should be the focus. Often, it is a trade-off where you spend the working time. If you manage to provide a FPGA solution with ether-frames to the software developer team, the FPGA part is done quickly and pandoras box is opened on the PC side. (overstating a little). Then, typically products evolve once they are in the hands of customers: Customer A has a switch. Customer B wants to run the device remotely from their PC. Customer C works in a company which disallows driver installations.... – BitTickler Apr 28 '15 at 01:05
  • I am using an Artix 7. I require very high speeds. Can layer 3 handle this? And do you have any resources for me to learn about UDP? – Evan L Apr 29 '15 at 22:23
  • You have to know UDP is unreliable. This means you can not be sure a packet arrives, you also can't be sure of the order in which the packets arrive and if the content wasn't changed. So you will have to implement some mechanism to check these things. Which could maybe slow down your program a bit.Tcp/ip instead is reliable. – Kevin Apr 29 '15 at 22:28