Send/Receive Packet

Mar 20, 2011 at 4:03 AM

I just started using PCapDotNet.  I am developing an application that tries to recognize a manufacturers cameras connected within a network.  This program needs to send out a broadcast on ethernet protocol 0x8033 every 15 seconds.  Once this happens, any camera should reply back with specific information about that camera.  The raw packet to be sent is 80 bytes in length, 14bytes for destination mac, source mac, protocol and 66 data bytes that contain various information.  The initial send is just a broadcast, but then subsequent packets could possible be sent to that specific destination mac, to change the camera's IP, device port, subnet mask, etc.  My question is, how can I use PCapDotNet to build that raw packet to send it out.  Do I use a timer and use the send single packet or will the send buffer work in this instance.  Also, once the packet is received (246 byte packet with camera info), what's the best way to parse that individual data out of that byte array.  I appreciate any help you could give me on this.

Coordinator
Mar 20, 2011 at 10:03 AM

Hi mkrei,

In order to build the packet, the simplest way would be to create an EthernetLayer and a PayloadLayer and use them in PacketBuilder.

In order to send the packets, you can use either the SendBuffer (which is more efficient but a little trickier to use) or just SendPacket(). I'm not sure what would suit you better, but I think starting with SendPacket() will be easier.

In order to parse the packet you can just parse the bytes.

 

In order to make building and parsing the packets easier, you can add a new Datagram and a Layer to PcapDotNet.Packets project.

If you want to do that, you can follow the Pcap.Net Developer's guide.

 

Boaz.

Mar 22, 2011 at 5:34 AM

What is the easiest way to find the IP address of the selected device?  Do I have to loop through the addresses to find the family type of "Internet", or is their an easier way?

Coordinator
Apr 16, 2011 at 8:21 PM

Hi mkrei,


I see that you've opened a discussion specifically regarding this question so I've answered you there.

 

Boaz.