Search code examples
c#network-programmingtcpclientwinsockpcap.net

Why does a packet sent using PCap.NET not fill out the TCP options?


I am trying to use PCap.NET to send a SYN packet to a destination. When using the WinSock API I can see the TCP Options in Wireshark.... But when I use PCap.NET to build and send the packet, the options are not included. Here is the TCP layer I use to build the packet :

 TcpLayer tcpLayer = new TcpLayer
                {
                    SourcePort = _sourcePort,
                    DestinationPort = _destinationPort,
                    SequenceNumber = _seqNumber,
                    ControlBits = TcpControlBits.Synchronize,
                    Window = _windowSize,
                };

This is the a WireShark ScreenGrab for sending a SYN using WinSock, where the TCP options are visible.

enter image description here

And this is the Wireshark ScreenGrab sending a SYN using PCap.NET, where the TCP options are not visible.

enter image description here

I understand that when building a Pcap TCP layer you can set the options property to None.... I haven't done that, thinking that by leaving it as its default that the options would send the same way it does for WinSock. Can anybody provide any explanation or advice for this problem. Thanks in advance for the help!


Solution

  • If you create a new TcpLayer, you need to set the Options property in order to have options in the TCP layer. If you don't set the Options property, it will, by default, set to None.