网络相关问题排查

Posted by shensunbo on April 17, 2026

最近在调试TBOX,遇到了一些网络相关的问题,记录一下排查过程和解决方案。

issues

  1. ping可以通,TBOX发送的someip offer消息主机可以收到,主机向TBOX发送握手消息没回复,TBOX端可以抓到握手消息,但TBOX没有回复。
    • ping走的是ICMP协议,不需要握手,ping可以通不代表TCP/UDP协议也能通。
    • 确认TBOX是否监听了对应的端口,确认协议栈是否正常工作。
    • 尝试编写一个测试bin,向不同的端口发送握手消息,看是否都没有回复
    • 关闭防火墙,关闭selinux权限,都没有用
    • TBOX端收到没有任何回复,说明消息本身有问题,checksum不对,导致直接被丢弃了。
      • 与应用无关
      • 检查协议栈网卡等,解决checksum问题
    • checksum不对对接收端的影响和对tcpdump抓包的影响:
      • 对接收端的影响:如果checksum不正确,接收端会认为数据包已经损坏,并且会丢弃这个数据包。这是因为checksum是用来验证数据包在传输过程中是否发生了错误的,如果checksum不匹配,接收端就无法确定数据包的完整性和正确性,因此会选择丢弃它。且不会有任何ACK回复。
    • 使用其他环境double check, 比如其他板子,或者直接连接到PC上,如果正常工作,说明问题出在环境上,可能是网卡驱动或者协议栈的问题。

tools

tcpdump

tcpdump基本指令,可以直接在终端查看也可以输出到文件

  • 查看某个端口的流量
    • tcpdump -i eth0 port 12345
    • tcpdump -i any
  • 指定ip
    • tcpdump -i eth0 host 192.168.1.1
  • 输出到文件
    • tcpdump -i eth0 port 12345 -w output.pcap
  • 直接在终端查看数据包内容()
    • tcpdump -i eth0 port 12345 -A -e:在输出中显示链路层头信息(MAC 地址、ethertype、VLAN 等)。 -n:不要解析主机名(显示数字 IP)
  • 输出详细程序
    • tcpdump -i eth0 port 12345 -v /-vv/-vvv
  • 指定协议
    • tcpdump -i eth0 udp port 12345
    • tcpdump -i eth0 tcp port 12345
    • tcpdump -i eth0 icmp
    • tcpdump -i eth0 arp

demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
shensunbo@DLFGVL3T3:~$ sudo tcpdump -i lo -nn -s 0 -c 50 tcp port 12345 -A
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:26:23.390606 IP 127.0.0.1.46470 > 127.0.0.1.12345: Flags [S], seq 4160873182, win 65495, options [mss 65495,sackOK,TS val 94209927 ecr 0,nop,wscale 7], length 0
E..<.}@.@.q<..........09.............0.........
............
11:26:23.390617 IP 127.0.0.1.12345 > 127.0.0.1.46470: Flags [S.], seq 2949431771, ack 4160873183, win 65483, options [mss 65495,sackOK,TS val 94209927 ecr 94209927,nop,wscale 7], length 0
E..<..@.@.<.........09...............0.........
............
11:26:23.390624 IP 127.0.0.1.46470 > 127.0.0.1.12345: Flags [.], ack 1, win 512, options [nop,nop,TS val 94209927 ecr 94209927], length 0
E..4.~@.@.qC..........09.............(.....
........
11:26:23.390660 IP 127.0.0.1.46470 > 127.0.0.1.12345: Flags [P.], seq 1:11, ack 1, win 512, options [nop,nop,TS val 94209927 ecr 94209927], length 10
E..>..@.@.q8..........09.............2.....
........hello tcp

11:26:23.390692 IP 127.0.0.1.12345 > 127.0.0.1.46470: Flags [.], ack 11, win 512, options [nop,nop,TS val 94209927 ecr 94209927], length 0
E..4E.@.@...........09...............(.....
........
11:27:08.566088 IP 127.0.0.1.46470 > 127.0.0.1.12345: Flags [F.], seq 11, ack 1, win 512, options [nop,nop,TS val 94253172 ecr 94209927], length 0
E..4..@.@.qA..........09.............(.....
..0t....
11:27:08.566154 IP 127.0.0.1.12345 > 127.0.0.1.46470: Flags [F.], seq 1, ack 12, win 512, options [nop,nop,TS val 94253172 ecr 94253172], length 0
E..4E.@.@...........09...............(.....
..0t..0t
11:27:08.566173 IP 127.0.0.1.46470 > 127.0.0.1.12345: Flags [.], ack 2, win 512, options [nop,nop,TS val 94253172 ecr 94253172], length 0
E..4..@.@.q@..........09.............(.....
..0t..0t


^C
8 packets captured
16 packets received by filter
0 packets dropped by kernel
shensunbo@DLFGVL3T3:~$ sudo tcpdump -i lo -n  -evv tcp port 12345
tcpdump: listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:28:07.942173 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 74: (tos 0x0, ttl 64, id 504, offset 0, flags [DF], proto TCP (6), length 60)
    127.0.0.1.41664 > 127.0.0.1.12345: Flags [S], cksum 0xfe30 (incorrect -> 0xb551), seq 4206673420, win 65495, options [mss 65495,sackOK,TS val 94308686 ecr 0,nop,wscale 7], length 0
11:28:07.942183 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 54: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 40)
    127.0.0.1.12345 > 127.0.0.1.41664: Flags [R.], cksum 0x260a (correct), seq 0, ack 4206673421, win 0, length 0
11:28:14.660441 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 74: (tos 0x0, ttl 64, id 21702, offset 0, flags [DF], proto TCP (6), length 60)
    127.0.0.1.41676 > 127.0.0.1.12345: Flags [S], cksum 0xfe30 (incorrect -> 0x7269), seq 3015650728, win 65495, options [mss 65495,sackOK,TS val 94315404 ecr 0,nop,wscale 7], length 0
11:28:14.660456 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 74: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    127.0.0.1.12345 > 127.0.0.1.41676: Flags [S.], cksum 0xfe30 (incorrect -> 0xec66), seq 1587215927, ack 3015650729, win 65483, options [mss 65495,sackOK,TS val 94315404 ecr 94315404,nop,wscale 7], length 0
11:28:14.660466 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 21703, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.41676 > 127.0.0.1.12345: Flags [.], cksum 0xfe28 (incorrect -> 0x1323), seq 1, ack 1, win 512, options [nop,nop,TS val 94315404 ecr 94315404], length 0
11:28:14.660542 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 76: (tos 0x0, ttl 64, id 21704, offset 0, flags [DF], proto TCP (6), length 62)
    127.0.0.1.41676 > 127.0.0.1.12345: Flags [P.], cksum 0xfe32 (incorrect -> 0xeaaf), seq 1:11, ack 1, win 512, options [nop,nop,TS val 94315405 ecr 94315404], length 10
11:28:14.660549 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 14014, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.12345 > 127.0.0.1.41676: Flags [.], cksum 0xfe28 (incorrect -> 0x1317), seq 1, ack 11, win 512, options [nop,nop,TS val 94315405 ecr 94315405], length 0
^C
7 packets captured
14 packets received by filter
0 packets dropped by kernel
shensunbo@DLFGVL3T3:~$ sudo tcpdump -i lo -n  -e tcp port 12345
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:29:55.115405 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 74: 127.0.0.1.59950 > 127.0.0.1.12345: Flags [S], seq 2116896596, win 65495, options [mss 65495,sackOK,TS val 94410072 ecr 0,nop,wscale 7], length 0
11:29:55.115415 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 74: 127.0.0.1.12345 > 127.0.0.1.59950: Flags [S.], seq 3888045621, ack 2116896597, win 65483, options [mss 65495,sackOK,TS val 94410072 ecr 94410072,nop,wscale 7], length 0
11:29:55.115421 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: 127.0.0.1.59950 > 127.0.0.1.12345: Flags [.], ack 1, win 512, options [nop,nop,TS val 94410072 ecr 94410072], length 0
11:29:55.115458 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 76: 127.0.0.1.59950 > 127.0.0.1.12345: Flags [P.], seq 1:11, ack 1, win 512, options [nop,nop,TS val 94410072 ecr 94410072], length 10
11:29:55.115461 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: 127.0.0.1.12345 > 127.0.0.1.59950: Flags [.], ack 11, win 512, options [nop,nop,TS val 94410072 ecr 94410072], length 0
^C
5 packets captured
10 packets received by filter
0 packets dropped by kernel
shensunbo@DLFGVL3T3:~$ sudo tcpdump -i lo -n  -ev tcp port 12345
tcpdump: listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
11:30:31.252594 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 45612, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.44044 > 127.0.0.1.12345: Flags [F.], cksum 0xfe28 (incorrect -> 0x0573), seq 422335109, ack 2476240385, win 512, options [nop,nop,TS val 94444283 ecr 94437753], length 0
11:30:31.252714 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 766, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.12345 > 127.0.0.1.44044: Flags [F.], cksum 0xfe28 (incorrect -> 0xebef), seq 1, ack 1, win 512, options [nop,nop,TS val 94444283 ecr 94444283], length 0
11:30:31.252735 00:00:00:00:00:00 > 00:00:00:00:00:00, ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 45613, offset 0, flags [DF], proto TCP (6), length 52)
    127.0.0.1.44044 > 127.0.0.1.12345: Flags [.], cksum 0xfe28 (incorrect -> 0xebef), ack 2, win 512, options [nop,nop,TS val 94444283 ecr 94444283], length 0