This project is read-only.

UDP to UdpClient

Aug 29, 2013 at 8:18 PM
I have created a class to send receive UDP based on, all is fine and this works, but I am trying to receive these UDP with UdpClient that comes with .net, and its not receving them. I can see the packets in wireshark, turn off the firewall, and nothing.

I am sending over Wifi card.
Aug 30, 2013 at 7:26 AM
Are you trying to receive the packets you send or other packets?
Aug 30, 2013 at 1:13 PM
Just receive packets only.
Aug 30, 2013 at 2:56 PM
What packets are you trying to receive?
Who sends the packets you're trying to receive?
Aug 30, 2013 at 3:38 PM
I have 2 programs.

1 sender based on

1 receiver based on .net UdpClient/Socket.

Now to test sender works, I use wireshark, plus a receiver based on This works.
So I know that UdpClient/Socket isn't picking up the message.

The packets are Udp and constructed this way:
public static Packet CreateUdpBroadcastPacket(byte[] payload, ushort destPort, LivePacketDevice device)
            MacAddress macAddress = GetDeviceMacAddress(device);            
            MacAddress broadcast = new MacAddress("FF:FF:FF:FF:FF:FF");

            EthernetLayer ethernetLayer =
                new EthernetLayer
                    Destination = broadcast,
                    Source = macAddress,                    
                    EtherType = EthernetType.None, // Will be filled automatically.

            IpV4Layer ipV4Layer =
                new IpV4Layer
                    Source = IpV4Address.AllHostsGroupAddress,
                    CurrentDestination = new IpV4Address(""),
                    Fragmentation = IpV4Fragmentation.None,
                    HeaderChecksum = null, // Will be filled automatically.
                    Identification = 123,
                    Options = IpV4Options.None,
                    Protocol = null, // Will be filled automatically.
                    Ttl = 100,
                    TypeOfService = 0,                    

            UdpLayer udpLayer =
                new UdpLayer
                    DestinationPort = destPort,
                    SourcePort = 4000,
                    Checksum = null, // Will be filled automatically.
                    CalculateChecksumValue = true,                    

            PayloadLayer payloadLayer =
                new PayloadLayer
                    Data = new Datagram(payload)

            //return PacketBuilder.Build(DateTime.Now, ipV4Layer, udpLayer, payloadLayer);
            return PacketBuilder.Build(DateTime.Now, ethernetLayer, ipV4Layer, udpLayer, payloadLayer);
Aug 31, 2013 at 8:31 AM
I believe the driver used by the UdpClient will not capture packets sent by the same device.
Sep 16, 2013 at 10:24 PM
No, at least this is not the reason. I have tried this on a seperate machine, I can see the data in wireshark but not on UdpClient. Have you ever tried UdpClient with
Sep 20, 2013 at 6:35 AM
I haven't.

I suggest you try and see what packets you manage to receive using UdpClient and then try and recreate these packets using Pcap.Net and see if you manage to receive them.

There's probably some difference.
If you can provide two .pcap files, one with packets sent and received when using UdpClient when it works and the other when using UdpClient with Pcap.Net, I can try and help you analyze them.