Udp Send - double packet

75 views
Skip to first unread message

bjorn...@gmail.com

unread,
Nov 4, 2019, 3:12:22 PM11/4/19
to Pcap.Net Q&A
I have a C# program for sending UDP packets with a given interval, but it seems like I'm sending double packets. 

2019-11-04_20-53-16.jpg


The code I've used:

            using (var communicator = _selectedDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000))
           
{
               
PacketBuilder builder = new PacketBuilder(new EthernetLayer
               
{
                   
Source = new MacAddress("01:01:01:01:01:01"),
                   
Destination = new MacAddress("02:02:02:02:02:02"),
                   
EtherType = EthernetType.None, // Will be filled automatically.
               
}, new IpV4Layer
               
{
                   
Source = new IpV4Address(string.Join(".", _localIpAddress)),
                   
CurrentDestination = new IpV4Address(string.Join(".", _remoteIpAddress)),
                   
Fragmentation = IpV4Fragmentation.None,
                   
HeaderChecksum = null, // Will be filled automatically.
                   
Identification = 123,
                   
Options = IpV4Options.None,
                   
Protocol = null, // Will be filled automatically.
                   
Ttl = 100,
                   
TypeOfService = 0
               
}, new UdpLayer
               
{
                   
SourcePort = (ushort) localPort,
                   
DestinationPort = (ushort) remotePort,
                   
Checksum = null, // Will be filled automatically.
                   
CalculateChecksumValue = true,
               
}, new PayloadLayer
               
{
                   
Data = new Datagram(data),
               
});


               
// Build and send the packet
                communicator
.SendPacket(builder.Build(DateTime.Now));
           
}


Does anyone know why, and how I can resolve it? I'm not sure if it's relevant, but my _selectedDevice has two addresses (IPv4, and IPv6).

Hope you can help me, thanks!
Reply all
Reply to author
Forward
0 new messages