PcapDotNet / Pcap.Net

.NET wrapper for WinPcap written in C++/CLI and C#, which features almost all WinPcap features and includes a packet interpretation framework.
BSD 3-Clause "New" or "Revised" License
564 stars 167 forks source link

Capture packet from another IP within the same network #122

Open a6datta opened 2 years ago

a6datta commented 2 years ago

I am trying to get the details when a VOIP phone rings. The hardware phone is connected to the same network.

With softphone I can get the device details as per the example IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;

and get the SIP header

private static void PacketHandler(Packet packet)
        {
            IpV4Datagram ip = packet.Ethernet.IpV4;
            UdpDatagram udp = ip.Udp;9
            Datagram datagram = null;

            if (ip.Protocol == IpV4Protocol.Udp)
            {
                datagram = udp.Payload;

                if (null != datagram)
                {
                    var decoded = datagram.Decode(System.Text.Encoding.UTF8);
                    //i can get the SIP header here
                }
            }
        }

How do I get the same with another IP within the same network?