0
我在C#中构建了一个win7程序,它充当一个数据包嗅探器,用于搜索特定数据包,并在收到数据包时执行traceroute。捕捉看起来如何,捕捉和使用wireshark的结果是一样的。数据包捕获没有收到直接发送到IP地址的数据
//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){
}
问题是它在执行方法上超时。服务器是我的电脑的外部IP地址(在这里更改)。这里有什么问题?
我建立了XAMPP Apache服务器。它适用于我使用内部IP并从同一个Wifi内发送。与外部它不。 – hubert
@hubert我假定内部和外部地址是指您的互联网路由器在WAN端(外部)使用的地址以及您在路由器(内部)后面的专用IP范围内使用的地址。您是否在路由器中配置了端口转发以将端口80转发到您的计算机?你可以从外面访问你的网络服务器(使用普通的浏览器,也许从你的移动设备)? –