在C#上嗅探ipv6地址时无法获取网络层头

问题描述 投票:0回答:0

当我嗅探 ipv6 地址时,我只能得到传输层标头。但是,我在嗅探 ipv4 地址时得到了网络层标头。

这是我的设置:

socket = new System.Net.Sockets.Socket(AddressFamily.InterNetworkV6, SocketType.Raw, ProtocolType.IP);
byteBufferData = new byte[1024 * 64];
socket.Bind(new IPEndPoint(IP, 0)); // a certain address
socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.HeaderIncluded, true);
byte[] byteTrue = new byte[4] { 1, 0, 0, 0 };
byte[] byteOut = new byte[4];
socket.IOControl(IOControlCode.ReceiveAll, byteTrue, byteOut);
socket.BeginReceive(byteBufferData, 0, byteBufferData.Length, SocketFlags.None, new AsyncCallback(this.ReceiveData), null);

我监听ipv4地址时,参数分别是

AddressFamily.InterNetwork
SocketOptionLevel.IP

c# sockets ipv6
© www.soinside.com 2019 - 2024. All rights reserved.