标签:name install win catch out any ddr this exce
安装nc工具
yum install nc
发送UDP到指定ip port
nc -4u 101.69.229.4 7709
发送udp数据包到指定的ip port
echo "pengsn hello word" |nc -4u 101.69.229.4 1001
发送数据包
try(DatagramSocket ds = new DatagramSocket()){
byte[] data = "This is a Message send by UDP.".getBytes("utf-8");
DatagramPacket dp = new DatagramPacket(data, data.length, InetAddress.getByName("ip"), port);
ds.send(dp);
}catch(Exception e) {
}
接收数据包
try(DatagramSocket ds = new DatagramSocket(1001)){
byte[] buf = new byte[1024];
DatagramPacket dp = new DatagramPacket(buf, buf.length);
ds.receive(dp);
String ip = dp.getAddress().getHostAddress();
System.out.println(ip);
System.out.println("dd:" + new String(dp.getData(), 0, dp.getLength()));
}catch(Exception e) {
}
windows 下wireshark工具抓取
linux 下通过tcpdump命令抓包
tcpdump -i any -s 0 udp port xx -w save.pcap
标签:name install win catch out any ddr this exce
原文地址:https://www.cnblogs.com/pengsn/p/12712824.html