public void Run() { if (selectedDevice != null) { using (PacketCommunicator communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { // Check the link layer. We support only Ethernet for simplicity. if (communicator.DataLink.Kind != DataLinkKind.Ethernet) { CLI.PrintQueueLog(Channel.Zero, "이더넷 프로토콜에서만 작동합니다..", ConsoleColor.White); return; } // Compile the filter using (BerkeleyPacketFilter filter = communicator.CreateFilter("ip and tcp and (port 80 or portrange 8000-9000)")) { // Set the filter communicator.SetFilter(filter); } CLI.PrintQueueLog(Channel.Zero, "패킷 읽기 시작!", ConsoleColor.Yellow); CLI.ShowToast("PCAP", "통발 블랙박스", "패킷 파싱을 시작합니다.", ""); // start the capture communicator.ReceivePackets(0, PacketHandler); } } else { CLI.PrintQueueLog(Channel.Zero, "장치가 선택되지 않았습니다.", ConsoleColor.White); } }
private void DoWork(object sender, DoWorkEventArgs e) { using (PacketCommunicator communicator = _device.Open()) { //add static arp-entry for gateway StaticARP.AddEntry(_gateway.IP, _gateway.PMAC, _device.GetNetworkInterface().Name); while (!_bgWorker.CancellationPending) { foreach (var target in _targets) { communicator.SendPacket(BuildPoisonArpPacketReply(target, _gateway)); //Packet which gets sent to the victim communicator.SendPacket(BuildPoisonArpPacketReply(_gateway, target)); //Packet which gets sent to the gateway } Thread.Sleep(1000); } //antidote foreach (var target in _targets) { communicator.SendPacket(BuildAntidoteArpPacketReply(target, _gateway)); communicator.SendPacket(BuildAntidoteArpPacketReply(_gateway, target)); } //remove static arp-entry for gateway StaticARP.RemoveEntry(_gateway.IP, _gateway.PMAC, _device.GetNetworkInterface().Name); } }
protected void StartCapture(LivePacketDevice dev) { if (dev == null) { return; } ExtraInfos[dev.Name].BackgroundThreadStop = false; ExtraInfos[dev.Name].BackgroundThread = new Thread(BackgroundThread); ExtraInfos[dev.Name].BackgroundThread.Start(dev); ExtraInfos[dev.Name].BackgroundThread.IsBackground = true; ExtraInfos[dev.Name].CaptureCancellation = new CancellationTokenSource(); ThreadPool.QueueUserWorkItem(new WaitCallback(state => { CancellationToken token = (CancellationToken)state; // Open device using (PacketCommunicator communicator = dev.Open( 65535, PacketDeviceOpenAttributes.Promiscuous, 250 )) { while (!token.IsCancellationRequested) { communicator.ReceivePackets(200, packet => { OnPacketArrivaled(packet, dev); }); } } }), ExtraInfos[dev.Name].CaptureCancellation.Token); }
private void DoWork(object sender, DoWorkEventArgs e) { using (PacketCommunicator communicator = _device.Open()) { while (true) { var watch = Stopwatch.StartNew(); foreach (var senderEntry in _entries) { communicator.SendPacket(GeneratePacket(senderEntry)); } watch.Stop(); var timeToSleep = _timePerRun - watch.ElapsedMilliseconds; if (timeToSleep < 0) { throw new Exception("Cannot send the requested amount of packets in " + _timePerRun + " milliseconds"); } else { //waiting loop, check for a possible pending cancelation for (int i = 0; i < 100; i++) { if (_bgWorker.CancellationPending) { return; } Thread.Sleep((int)timeToSleep / 100); } } } } }
public PacketCommunicator OpenPcapDevice(string deviceId, int timeout) { LivePacketDevice selectedDevice = this.allinterfaces.Where(elem => elem.Name.Contains(deviceId)).First(); PacketCommunicator communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, timeout); return(communicator); }
public void SendUDP() { EthernetLayer ethernetLayer = CreateEthernetLayer(); IpV4Layer ipV4Layer = CreateIpV4Layer(); UdpLayer udpLayer = CreateUdpLayer(); PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer); using (PacketCommunicator communicator = _device.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000)) { communicator.SendPacket(builder.Build(DateTime.Now)); } }
// Filter syntax: https://www.winpcap.org/docs/docs_40_2/html/group__language.html public void Listen(LivePacketDevice adapter, String filter, int count) { this.adapter = adapter; using (PacketCommunicator communicator = adapter.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { try { communicator.SetFilter(filter); } catch (Exception e) { MessageBox.Show(null, e.Message, "Filter Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } communicator.ReceivePackets(count, PacketHandler); } }
private static void InterceptDevice(object data) { LivePacketDevice device = (LivePacketDevice)data; using (PacketCommunicator communicator = device.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { using (BerkeleyPacketFilter filter = communicator.CreateFilter("udp port 14001")) { communicator.SetFilter(filter); communicator.ReceivePackets(int.MaxValue, PacketHandler); } } }
public CDPWorkerObject(LivePacketDevice sd, CALLBACK cb) { try { selectedDevice = sd; callBack = cb; communicator = selectedDevice.Open(512, PacketDeviceOpenAttributes.Promiscuous, 1000); capturedPacket = null; } catch (Exception) { } }
private void DoWork(object sender, DoWorkEventArgs e) { if (_device == null) { throw new Exception("The capturing device must be set before starting the capture"); } using (PacketCommunicator communicator = _device.Open()) { if (_filter != null) { communicator.SetFilter(_filter); } communicator.ReceivePackets(0, _packetHandler); } }
static void notifySpoof(LivePacketDevice selectedDevice, string notifyString, string sourceIP, ushort sourcePort, string destIP, ushort destPort) { byte[] temp = System.Text.Encoding.ASCII.GetBytes(notifyString); EthernetLayer ethernetLayer = new EthernetLayer { Source = LivePacketDeviceExtensions.GetMacAddress(selectedDevice), Destination = new MacAddress("01:00:5E:7F:FF:FA"), EtherType = EthernetType.None, }; IpV4Layer ipV4Layer = new IpV4Layer { Source = new IpV4Address(sourceIP), CurrentDestination = new IpV4Address(destIP), Fragmentation = IpV4Fragmentation.None, HeaderChecksum = null, Identification = 1, Options = IpV4Options.None, Protocol = null, Ttl = 64, TypeOfService = 0, }; UdpLayer udpLayer = new UdpLayer { SourcePort = sourcePort, DestinationPort = destPort, Checksum = null, CalculateChecksumValue = true, }; PayloadLayer payloadLayer = new PayloadLayer { Data = new Datagram(temp), }; PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, payloadLayer); using (PacketCommunicator communicator = selectedDevice.Open(69559, PacketDeviceOpenAttributes.Promiscuous, 1000)) // read timeout { communicator.SendPacket(builder.Build(DateTime.Now)); } }
private void button4_Click(object sender, EventArgs e) { int selectedIndex = this.comboBoxNetworkAdapter.SelectedIndex; if (selectedIndex >= 0 && selectedIndex <= (this._networkAdapters.Count - 1)) { DisableLivePcapParsingButton(); DisablePcapButton(); labelCapturingIndication.Visible = true; comboBoxNetworkAdapter.Enabled = false; Task.Factory.StartNew(() => { LivePacketDevice selectedDevice = this._networkAdapters[selectedIndex]; // 65536 guarantees that the whole packet will be captured on all the link layers using (PacketCommunicator communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { using (BerkeleyPacketFilter filter = communicator.CreateFilter("tcp dst port 9295 or tcp src port 9295")) { // Set the filter communicator.SetFilter(filter); } // start the capture communicator.ReceivePackets(0, PacketHandlerTcp); } }); Task.Factory.StartNew(() => { LivePacketDevice selectedDevice = this._networkAdapters[selectedIndex]; // 65536 guarantees that the whole packet will be captured on all the link layers using (PacketCommunicator communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { using (BerkeleyPacketFilter filter = communicator.CreateFilter("udp dst port 9296 or udp src port 9296")) { // Set the filter communicator.SetFilter(filter); } // start the capture communicator.ReceivePackets(0, PacketHandlerUdp); } }); } }
private void DoWork(object sender, DoWorkEventArgs e) { var scanlist = _device.getNetworkIpList(); List <Packet> packetList = new List <Packet>(); foreach (var packet in scanlist) { packetList.Add(BuildArpPacketRequest(new IpV4Address(packet))); } using (PacketCommunicator communicator = _device.Open()) { foreach (var packet in packetList) { communicator.SendPacket(packet); } } }
private void _ReadPacketLoop() { while (true) // crete infinite loop { using (var communicator = _device.Open(ushort.MaxValue, PacketDeviceOpenAttributes.Promiscuous, 500)) { if (communicator.DataLink.Kind != DataLinkKind.Ethernet) { return; } // setup packet filter using (var filter = communicator.CreateFilter("udp")) communicator.SetFilter(filter); // begin receive packets communicator.ReceivePackets(0, _PacketHandler); } } }
/* * broadcasts are annoying and let targets find the real router * so this will instantly send arp spoofed replay insted of the timed attack * and hopefully target is not lost for long time */ private void FightBackAnnoyingBroadcasts(LivePacketDevice nic) { var ether = new EthernetLayer { Source = new MacAddress(_myMac), Destination = new MacAddress("FF:FF:FF:FF:FF:FF"), EtherType = EthernetType.None }; Task.Run(() => { PacketCommunicator communicator = nic.Open(500, PacketDeviceOpenAttributes.None, 50); communicator.SetFilter("arp && ether dst ff:ff:ff:ff:ff:ff"); while (_status == Status.Started || _status == Status.Starting || _status == Status.Paused) { communicator.ReceivePackets(0, arp => { var sourceIp = arp.Ethernet.IpV4.Source.ToString(); if (sourceIp.Equals(_gatewayIp)) { var arplayer = new ArpLayer { ProtocolType = EthernetType.IpV4, Operation = ArpOperation.Request, SenderHardwareAddress = ether.Source.ToBytes(), SenderProtocolAddress = new IpV4Address(_gatewayIp).ToBytes(), TargetHardwareAddress = MacAddress.Zero.ToBytes(), TargetProtocolAddress = arp.Ethernet.IpV4.Destination.ToBytes() }; var packet = new PacketBuilder(ether, arplayer).Build(DateTime.Now); communicator.SendPacket(packet); } else if (KvStore.IpMac.ContainsKey(sourceIp)) { SpoofGateway(communicator, sourceIp); } }); } communicator.Dispose(); }); }
void tsbStart_Click(object sender, EventArgs e) { stop = false; tsbStart.Enabled = tscbNet.Enabled = false; tsbPause.Enabled = tsbStop.Enabled = true; this.Text = "Ostara - Logging"; if (paused) { paused = false; return; } if (Settings.I.ClearOnStart) { flvPackets.ClearObjects(); } packets = new Queue <PacketClass>(); clientCrypt = new Dictionary <ushort, Cryption.Client>(); serverCrypt = new Dictionary <ushort, Cryption.Server>(); int ni = tscbNet.SelectedIndex; device = LivePacketDevice.AllLocalMachine[ni]; comm = device.Open(65536, PacketDeviceOpenAttributes.None, 500); comm.SetFilter(Ports.I.Filter); foreach (var a in device.Addresses) { if (a.Address.Family == SocketAddressFamily.Internet) { address = ((IpV4SocketAddress)a.Address).Address.ToValue(); break; } } Task.Run(() => { GetPackets(); }); }
public LivePacketProducer(LivePacketDevice device, string filter = "ip and tcp") { if (device == null) { throw new ArgumentException("Device must not be null"); } _device = device; _comminicator = _device.Open(65536, PacketDeviceOpenAttributes.MaximumResponsiveness | PacketDeviceOpenAttributes.Promiscuous, 0); if (_comminicator.DataLink.Kind != DataLinkKind.Ethernet) { throw new ArgumentException("Only Ethernet devices are supported for live packet production."); } _filter = _comminicator.CreateFilter(filter); if (_filter != null) { _comminicator.SetFilter(_filter); } }
internal void Start() { var devices = LivePacketDevice.AllLocalMachine; //get all the connected wifi devices LivePacketDevice xboneAdapter = null; try { xboneAdapter = devices.FirstOrDefault(x => x.Description.ToLower().Contains("rpcap")) ?? devices.FirstOrDefault(x => x.Description.ToLower().Contains("MT7612US_RL".ToLower())); //get the wifi device with name 'rpcap' (usb adapter) MT7612US_RL if (xboneAdapter != null) { Console.WriteLine("Xbox One Adapter found!"); } } catch (Exception) { if (MessageBox.Show("Please plug in the Xbox One Adapter!") == MessageBoxResult.OK) { Environment.Exit(-1); } } try { using (PacketCommunicator communicator = xboneAdapter.Open(45, PacketDeviceOpenAttributes.Promiscuous, 50)) { while (true) { try { communicator.ReceiveSomePackets(out int packetsSniffed, 5, PacketServer.Instance.AddPacket); } catch (Exception ex) { // looks like this can throw if you plug a controller in via usb Debug.WriteLine(ex.Message); } } } } catch (NullReferenceException ex) { if (MessageBox.Show(ex.Message, "Please plug in the Xbox One Adapter!") == MessageBoxResult.OK) { Environment.Exit(-1); } } }
} // Select device public static List <string> ListenFromDevice(LivePacketDevice device, int port) { using (PacketCommunicator communicator = device.Open(65535, PacketDeviceOpenAttributes.Promiscuous, 1000)) { using (BerkeleyPacketFilter filter = communicator.CreateFilter(filterString)) { communicator.SetFilter(filter); } Console.WriteLine("Listening on " + device.Description + "..."); Console.WriteLine("Press any key to exit..."); bool iskeyPress = true; do { communicator.ReceivePackets(0, PacketHandler); var keyPressed = Console.ReadKey(); iskeyPress = keyPressed.Key == ConsoleKey.Enter; } while (iskeyPress); return(auctionList); } }
public static PacketCommunicator OpenLiveDevice() { NetworkInterface networkInterface = NetworkInterface.GetAllNetworkInterfaces().FirstOrDefault( ni => !ni.IsReceiveOnly && ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet && ni.OperationalStatus == OperationalStatus.Up); LivePacketDevice device = networkInterface.GetLivePacketDevice(); MoreAssert.IsMatch(@"Network adapter '.*' on local host", device.Description); Assert.AreEqual(DeviceAttributes.None, device.Attributes); Assert.AreNotEqual(MacAddress.Zero, device.GetMacAddress()); Assert.AreNotEqual(string.Empty, device.GetPnpDeviceId()); MoreAssert.IsBiggerOrEqual(1, device.Addresses.Count); foreach (DeviceAddress address in device.Addresses) { if (address.Address.Family == SocketAddressFamily.Internet) { MoreAssert.IsMatch("Address: " + SocketAddressFamily.Internet + @" [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ " + "Netmask: " + SocketAddressFamily.Internet + @" 255\.[0-9]+\.[0-9]+\.[0-9]+ " + "Broadcast: " + SocketAddressFamily.Internet + @" 255.255.255.255", address.ToString()); } else { Assert.AreEqual(SocketAddressFamily.Internet6, address.Address.Family); MoreAssert.IsMatch("Address: " + SocketAddressFamily.Internet6 + @" (?:[0-9A-F]{4}:){7}[0-9A-F]{4} " + "Netmask: " + SocketAddressFamily.Unspecified + @" " + IpV6Address.Zero + " " + "Broadcast: " + SocketAddressFamily.Unspecified + @" " + IpV6Address.Zero, address.ToString()); } } PacketCommunicator communicator = device.Open(); try { MoreAssert.AreSequenceEqual(new[] { DataLinkKind.Ethernet, DataLinkKind.Docsis }.Select(kind => new PcapDataLink(kind)), communicator.SupportedDataLinks); PacketTotalStatistics totalStatistics = communicator.TotalStatistics; Assert.AreEqual <object>(totalStatistics, totalStatistics); Assert.AreNotEqual(null, totalStatistics); Assert.AreEqual(totalStatistics.GetHashCode(), totalStatistics.GetHashCode()); Assert.IsTrue(totalStatistics.Equals(totalStatistics)); Assert.IsFalse(totalStatistics.Equals(null)); Assert.AreNotEqual(null, totalStatistics); Assert.AreNotEqual(totalStatistics, 2); MoreAssert.IsSmallerOrEqual <uint>(1, totalStatistics.PacketsCaptured, "PacketsCaptured"); Assert.AreEqual <uint>(0, totalStatistics.PacketsDroppedByDriver, "PacketsDroppedByDriver"); Assert.AreEqual <uint>(0, totalStatistics.PacketsDroppedByInterface, "PacketsDroppedByInterface"); MoreAssert.IsSmallerOrEqual <uint>(1, totalStatistics.PacketsReceived, "PacketsReceived"); Assert.IsNotNull(totalStatistics.ToString()); communicator.SetKernelBufferSize(2 * 1024 * 1024); // 2 MB instead of 1 communicator.SetKernelMinimumBytesToCopy(10); // 10 bytes minimum to copy communicator.SetSamplingMethod(new SamplingMethodNone()); Assert.AreEqual(DataLinkKind.Ethernet, communicator.DataLink.Kind); communicator.DataLink = communicator.DataLink; Assert.AreEqual("EN10MB (Ethernet)", communicator.DataLink.ToString()); Assert.AreEqual(communicator.DataLink, new PcapDataLink(communicator.DataLink.Name)); Assert.IsTrue(communicator.IsFileSystemByteOrder); Assert.AreEqual(PacketCommunicatorMode.Capture, communicator.Mode); Assert.IsFalse(communicator.NonBlocking); Assert.AreEqual(PacketDevice.DefaultSnapshotLength, communicator.SnapshotLength); return(communicator); } catch (Exception) { communicator.Dispose(); throw; } }
/// <summary> /// Begins packet injection with user defined parameters /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOk_Click(object sender, EventArgs e) { lblResult.Text = ""; bool srcPortFlag = Int32.TryParse(txtSrcPort.Text, out int srcPort); bool dstPortFlag = Int32.TryParse(txtDestPort.Text, out int dstPort); //Console.WriteLine(sourceMac); //Console.WriteLine(GetMacAddress(gatewayAddy).ToString()); // if condtions are met, attempt to build the packet from lower layer up, using user input if (srcPortFlag && dstPortFlag && srcPort <= 65535 && srcPort > 0 && dstPort <= 65535 && dstPort > 0) { try { // build packet and initiate communicator PacketBuilder builder = buildLayers(srcPort, dstPort); PacketCommunicator communicator = selectedDevice.Open(100, PacketDeviceOpenAttributes.Promiscuous, 1000); // send packet bool repeatFlag = Int32.TryParse(txtNumPackets.Text, out int repeat); bool intervalFlag = Int32.TryParse(txtInterval.Text, out int interval); if (intervalFlag && !repeatFlag) { timer = new Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = interval; timer.Enabled = true; timer.Start(); } /*if (repeatFlag) * { * if (repeat > 1000) * repeat = 1000; * else if (repeat < 1) * repeat = 1; * txtNumPackets.Text = repeat.ToString(); * }*/ /*btnOk.Enabled = false; * btnReset.Enabled = false; * Cursor = Cursors.WaitCursor;*/ if (repeatFlag && repeat > 0 && !intervalFlag) { /*for (int i = 0; i < repeat; i++) * { * communicator.SendPacket(builder.Build(DateTime.Now)); * count++; * lblResult.Text = "SUCCESS!: " + count; * } * count = 0;*/ new System.Threading.Thread(new System.Threading.ThreadStart(sendNewThread)) { IsBackground = true }.Start(); } else { communicator.SendPacket(builder.Build(DateTime.Now)); count++; lblResult.Text = "SUCCESS!: " + count; } /*Cursor = Cursors.Default; * btnOk.Enabled = true; * btnReset.Enabled = true;*/ } catch (Exception) { lblResult.Text = "FAIL!"; MessageBox.Show("Invalid Input!"); count = 0; btnOk.Enabled = true; btnReset.Enabled = true; } } }
private void CapturePackets() // captures live packets coming OTA or OTW { // Take the selected adapter selectedDevice = allLivePacketDevices[this.deviceIndex]; // Detect the correct sensor address foreach (DeviceAddress address in selectedDevice.Addresses) { if (!address.Address.ToString().Contains("Internet6")) { string[] ipv4addy = address.Address.ToString().Split(); sensorAddress = ipv4addy[1]; } } // Open the device using (PacketCommunicator communicator = selectedDevice.Open(65536, // portion of the packet to capture // 65536 guarantees that the whole packet will be captured on all the link layers PacketDeviceOpenAttributes.Promiscuous, // promiscuous mode 1000)) // read timeout { if (communicator.DataLink.Kind != DataLinkKind.Ethernet) { Console.WriteLine("This program works only on Ethernet networks."); return; } try { // Try to set the capture filter communicator.SetFilter(filter); } catch (Exception e) { MessageBox.Show("Improper filter syntax!\nError info:\n" + e.Message, "Error!"); this.Invoke((MethodInvoker)(() => { txtFilterField.Text = ""; txtIpOne.Text = ""; txtIpTwo.Text = ""; txtPortOne.Text = ""; txtPortTwo.Text = ""; })); ResetNecessaryProperties(); captFlag = false; } // Capture Loop while (captFlag) { // Try to get the next packet PacketCommunicatorReceiveResult result = communicator.ReceivePacket(out Packet packet); // Determine the result switch (result) { case PacketCommunicatorReceiveResult.Timeout: // Timeout elapsed break; case PacketCommunicatorReceiveResult.Ok: PrintPacket(packet); // call the main packet handler break; default: throw new InvalidOperationException("The result " + result + " should never be reached here"); } } // save packets after capture if requested if (captureAndDumpRequested) { this.Invoke((MethodInvoker)(() => { Tools.FileHandler.SavePackets(packets, packetBytes, maxFilePackets, sensorAddress); })); } } }
void tsbStart_Click(object sender, EventArgs e) { stop = false; tsbStart.Enabled = tscbNet.Enabled = false; tsbPause.Enabled = tsbStop.Enabled = true; this.Text = "Ostara - Logging"; if (paused) { paused = false; return; } if (Settings.I.ClearOnStart) flvPackets.ClearObjects(); packets = new Queue<PacketClass>(); clientCrypt = new Dictionary<ushort, Cryption.Client>(); serverCrypt = new Dictionary<ushort, Cryption.Server>(); int ni = tscbNet.SelectedIndex; device = LivePacketDevice.AllLocalMachine[ni]; comm = device.Open(65536, PacketDeviceOpenAttributes.None, 500); comm.SetFilter(Ports.I.Filter); foreach (var a in device.Addresses) { if (a.Address.Family == SocketAddressFamily.Internet) { address = ((IpV4SocketAddress)a.Address).Address.ToValue(); break; } } Task.Run(() => { GetPackets(); }); }
public PacketCommunicator GetCommunicator() { return(device.Open(65536, PacketDeviceOpenAttributes.Promiscuous | PacketDeviceOpenAttributes.MaximumResponsiveness | PacketDeviceOpenAttributes.NoCaptureLocal, 1000)); }
static void msearch_response_spoof(LivePacketDevice selectedDevice, string msearch_string, string sourceIP, ushort sourcePort, string destIP, ushort destPort, string destMac) { byte[] temp = System.Text.Encoding.ASCII.GetBytes(msearch_string); EthernetLayer ethernetLayer = new EthernetLayer { Source = LivePacketDeviceExtensions.GetMacAddress(selectedDevice), Destination = new MacAddress(destMac), EtherType = EthernetType.None, }; var options = IpV4FragmentationOptions.DoNotFragment; IpV4Layer ipV4Layer = new IpV4Layer { Source = new IpV4Address(sourceIP), CurrentDestination = new IpV4Address(destIP), Fragmentation = new IpV4Fragmentation(options,0), HeaderChecksum = null, Identification = 0, Options = IpV4Options.None, Protocol = null, Ttl = 64, TypeOfService = 0, }; UdpLayer udpLayer = new UdpLayer { SourcePort = sourcePort, DestinationPort = destPort, Checksum = null, CalculateChecksumValue = true, }; PayloadLayer payloadLayer = new PayloadLayer { Data = new Datagram(temp), }; PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, udpLayer, payloadLayer); using (PacketCommunicator communicator = selectedDevice.Open(69559, PacketDeviceOpenAttributes.Promiscuous, 1000)) // read timeout { communicator.SendPacket(builder.Build(DateTime.Now)); } }