need help with sending UDP package

Jun 19, 2012 at 10:59 AM
Edited Jun 19, 2012 at 11:01 AM

I want to send a UDP package to my powerline modem. My code is similar to the example. I have tried BuildIPv4Packet. It only works when I tried to send 3 bytes. If it is more than 3 bytes, the sending is not working, cannot be seen in Wireshark. For UDP, it never works.

Please help me. Thanks in advance.

 

 

 

 //////////////////////////////////////////////////////////////

 

using (PacketCommunicator communicator = selectedDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000))

{

communicator.SendPacket(BuildUdpPacket());

}

 

private static Packet BuildUdpPacket()
{
            byte[] temp = new byte[] {0x61,0x53,0xd6,0x15, 1,0,0,0,3,0,0,0,9,0,0,0};

 

            EthernetLayer ethernetLayer = new EthernetLayer
            {
                Source = new MacAddress("F4:6D:04:EC:E8:71"),
                Destination = new MacAddress("38:72:C0:F6:F4:25"),
                EtherType = EthernetType.None, 

            };

            IpV4Layer ipV4Layer = new IpV4Layer
            {
                Source = new IpV4Address("10.10.1.8"),
                CurrentDestination = new IpV4Address("10.10.1.70"),
                Fragmentation = IpV4Fragmentation.None,
                HeaderChecksum = null,                

                Identification = 10,
                Options = IpV4Options.None,
                Protocol = null, // Will be filled automatically.
                Ttl = 124,
                TypeOfService = 0,
            };

            UdpLayer udpLayer = new UdpLayer
            {
                SourcePort = 33595,
                DestinationPort = 40004,
                Checksum = null, // Will be filled automatically.
                CalculateChecksumValue = true,
            };

            PayloadLayer payloadLayer = new PayloadLayer
            {
                Data = new Datagram(temp),
            };

            PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, payloadLayer);

            return builder.Build(DateTime.Now);
        }

///////////////////////////////////////////////

Coordinator
Jun 22, 2012 at 6:22 AM

Hi manchester1981,

 

Can you give an example of a pcap file containing a packet similar to what you want to send?

 

It's best if you can use Wireshark to capture the most similar packet to the packet you want to send and then start by imitating it.

 

I hope this helps,

 

Boaz.

Jun 22, 2012 at 7:02 AM

Thanks for your reply.

I found out the problem. It is the firewall blocking the packets I send:)