sockets - 服务器不接受UDP数据包?
问题描述
包#1:
0000 08 00 27 7f 25 ae 08 00 27 2d 93 13 08 00 45 00 ..'.%®..'-....E.
0010 00 22 ab cd 40 00 40 11 00 00 0a 00 00 e8 0a 00 ."«Í@.@......è..
0020 00 87 22 b8 22 b8 00 0e 00 00 48 65 6c 6c 6f 0a .."¸"¸....Hello.
Frame 1692: 48 bytes on wire (384 bits), 48 bytes captured (384 bits) on interface 0
Interface id: 0 (eth0)
Encapsulation type: Ethernet (1)
Arrival Time: Aug 18, 2020 22:47:52.475803259 EDT
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1597805272.475803259 seconds
[Time delta from previous captured frame: 0.198748689 seconds]
[Time delta from previous displayed frame: 35.744487538 seconds]
[Time since reference or first frame: 507.094545999 seconds]
Frame Number: 1692
Frame Length: 48 bytes (384 bits)
Capture Length: 48 bytes (384 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:udp:data]
[Coloring Rule Name: UDP]
[Coloring Rule String: udp]
Ethernet II, Src: PcsCompu_2d:93:13 (08:00:27:2d:93:13), Dst: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
Destination: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
Address: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: PcsCompu_2d:93:13 (08:00:27:2d:93:13)
Address: PcsCompu_2d:93:13 (08:00:27:2d:93:13)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 10.0.0.232, Dst: 10.0.0.135
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Total Length: 34
Identification: 0xabcd (43981)
Flags: 0x4000, Don't fragment
Time to live: 64
Protocol: UDP (17)
Header checksum: 0x0000 [validation disabled]
[Header checksum status: Unverified]
Source: 10.0.0.232
Destination: 10.0.0.135
User Datagram Protocol, Src Port: 8888, Dst Port: 8888
Data (6 bytes)
Data: 48656c6c6f0a
[Length: 6]
包#2:
0000 08 00 27 7f 25 ae 08 00 27 2d 93 13 08 00 45 00 ..'.%®..'-....E.
0010 00 22 fa 39 40 00 40 11 2b 23 0a 00 00 e8 0a 00 ."ú9@.@.+#...è..
0020 00 87 cd 36 22 b8 00 0e 15 8e 48 65 6c 6c 6f 0a ..Í6"¸....Hello.
Frame 2078: 48 bytes on wire (384 bits), 48 bytes captured (384 bits) on interface 0
Interface id: 0 (eth0)
Encapsulation type: Ethernet (1)
Arrival Time: Aug 18, 2020 22:50:12.624196163 EDT
[Time shift for this packet: 0.000000000 seconds]
Epoch Time: 1597805412.624196163 seconds
[Time delta from previous captured frame: 0.804243424 seconds]
[Time delta from previous displayed frame: 140.148392904 seconds]
[Time since reference or first frame: 647.242938903 seconds]
Frame Number: 2078
Frame Length: 48 bytes (384 bits)
Capture Length: 48 bytes (384 bits)
[Frame is marked: False]
[Frame is ignored: False]
[Protocols in frame: eth:ethertype:ip:udp:data]
[Coloring Rule Name: UDP]
[Coloring Rule String: udp]
Ethernet II, Src: PcsCompu_2d:93:13 (08:00:27:2d:93:13), Dst: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
Destination: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
Address: PcsCompu_7f:25:ae (08:00:27:7f:25:ae)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Source: PcsCompu_2d:93:13 (08:00:27:2d:93:13)
Address: PcsCompu_2d:93:13 (08:00:27:2d:93:13)
.... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit: Individual address (unicast)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 10.0.0.232, Dst: 10.0.0.135
0100 .... = Version: 4
.... 0101 = Header Length: 20 bytes (5)
Differentiated Services Field: 0x00 (DSCP: CS0, ECN: Not-ECT)
Total Length: 34
Identification: 0xfa39 (64057)
Flags: 0x4000, Don't fragment
Time to live: 64
Protocol: UDP (17)
Header checksum: 0x2b23 [validation disabled]
[Header checksum status: Unverified]
Source: 10.0.0.232
Destination: 10.0.0.135
User Datagram Protocol, Src Port: 52534, Dst Port: 8888
数据(6 字节) 数据:48656c6c6f0a [长度:6]
注意:数据包是由wireshark捕获的。
工具源代码:https ://github.com/MrMindKeeper/tcpf/blob/master/crafty.py
我用来生成数据包的参数: python3 packetP.py -s="10.0.0.232" -d="10.0.0.135" -dmac="08:00:27:7f:25:ae" -smac="08:00:27:2d:93:13" -sp="8888" -dp="8888" -ch="0" -tl="34" -flag="4" -hc="0"
如果您没有注意到两个数据包之间的唯一区别是 IP 标头校验和和 IP 标头标识字节或(字节 19-20 和 25-26)。
包 #1 是由我个人开发的工具生成的,包 #2 是由netcat
两者在同一台 linux 机器上生成的。
服务器正在侦听端口 8888。服务器接收到两个数据包,但仅响应数据包 #2 或由 生成的数据包netcat
。
我还尝试了一堆其他随机IP Header Identification
值,将 Header Checksum 设置为00 00
,但它仍然不起作用。有人能告诉我这里有什么问题吗?为什么我的工具生成的数据包不被接受?
我想,你不需要我的工具代码来解决这个问题,因为数据包是发送和接收的。因此,该工具不会有问题。
解决方案
推荐阅读
- javascript - 在 React 中使用变量渲染组件
- excel - 嵌套 For 循环停止中游
- android - Anroid RxJava2 从方法返回值
- graalvm - 如何使用 GraalVM 原生镜像编译多个 JAR
- c# - Azure LUIS API 话语 ID 太大
- org-mode - 在时钟表报告中包含日期或时间
- python-3.x - 您如何从输入按钮中找到网址(网络抓取)
- java - Comparator.comparing(...).thenComparing(...) 找出哪些字段不匹配
- go - 如何在 Gin 的 url 中添加语言前缀?
- r - R kknn 包和加权 k 最近邻计算