我正在用 C# 构建一个 win7 程序,它充当数据包嗅探器,用于搜索特定数据包,并在接收到它后对数据包源执行跟踪路由。这是捕获的外观,它捕获和使用wireshark的结果是相同的。
//Start capture
startStop.Text = "Stop";
capture = true;
socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);
info.Text = "Capturing on: " + ifaces.SelectedItem.ToString();
socket.Bind(new IPEndPoint(ifs[ifaces.SelectedIndex], 0));
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
byte[] byTrue = new byte[4] { 1, 0, 0, 0 };
byte[] byOut = new byte[4];
socket.IOControl(IOControlCode.ReceiveAll, byTrue, byOut);
socket.BeginReceive(data, 0, data.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
发送特定数据包的程序是一个将数据发送到 IP 地址的 Android 应用程序。
try{
string server="http://32.32.32.32/"
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(server);
httppost.setEntity(new StringEntity("TRACERT"));
HttpResponse response = httpclient.execute(httppost);
}catch(Exception e){
}
问题是它在执行方法上超时。服务器是我的 PC 的外部 IP(在此处更改)。这里有什么问题?