我正在尝试通过一个串行连接到wifi适配器。我正在使用Socat创建一个套接字来连接到pppd的连接。数据似乎是双向流动的,但是pppd似乎没有得到客户端的响应。Socat的调试输出显示传入/传出数据,客户端调试输出显示来自服务器的ACK‘’ing协商数据包,而服务器调试仅显示发送的数据包而不显示应答。我已经用头撞墙两周了,想弄清楚到底是怎么回事。
客户端是一个老式的DOS掌上电脑运行剂量,它完美地工作使用USB电缆。我怀疑它与Socat有关,但我不知道如何调试接收到的数据是否被传递给pppd。
我遗漏了什么?我怎么才能让这个起作用?
我使用的Socat命令是:
socat -d -d -v tcp-l:2323,fork,reuseaddr exec:'/usr/sbin/pppd notty',pty,rawer,nonblock=1,iexten=0,b19200
.ppprc
debug
nodetach
default-asyncmap
local
mtu 296
mru 296
noipv6
noauth
nottySocat输出:
root# socat -d -d -v tcp-l:2323,fork,reuseaddr exec:'/usr/sbin/pppd notty',pty,rawer,nonblock=1,iexten=0,b19200
2021/05/08 00:27:04 socat[1082] N listening on AF=2 0.0.0.0:2323
2021/05/08 00:27:20 socat[1082] N accepting connection from AF=2 10.0.10.46:26185 on AF=2 10.0.10.17:2323
2021/05/08 00:27:20 socat[1082] N forked off child process 1083
2021/05/08 00:27:20 socat[1082] N listening on AF=2 0.0.0.0:2323
2021/05/08 00:27:20 socat[1083] N forking off child, using pty for reading and writing
2021/05/08 00:27:20 socat[1083] N forked off child process 1084
2021/05/08 00:27:20 socat[1083] N forked off child process 1084
2021/05/08 00:27:20 socat[1083] N starting data transfer loop with FDs [6,6] and [5,5]
2021/05/08 00:27:20 socat[1084] N execvp'ing "/usr/sbin/pppd"
< 2021/05/08 00:27:20.122440 length=52 from=0 to=51
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~< 2021/05/08 00:27:23.117722 length=52 from=52 to=103
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~< 2021/05/08 00:27:26.122209 length=52 from=104 to=155
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:26.128144 length=41 from=0 to=40
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ > 2021/05/08 00:27:26.881958 length=50 from=41 to=90
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ < 2021/05/08 00:27:29.124308 length=52 from=156 to=207
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:29.504403 length=41 from=91 to=131
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ > 2021/05/08 00:27:30.154487 length=50 from=132 to=181
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ < 2021/05/08 00:27:32.127473 length=52 from=208 to=259
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:33.004495 length=50 from=182 to=231
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:33.329502 length=41 from=232 to=272
~.}#.!}!}!} }2}!}}!(}%}&}:}4@} }}"}(}"%.~ < 2021/05/08 00:27:35.130645 length=52 from=260 to=311
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:36.056441 length=50 from=273 to=322
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:36.679459 length=41 from=323 to=363
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ < 2021/05/08 00:27:38.133840 length=52 from=312 to=363
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:39.054527 length=50 from=364 to=413
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:39.655287 length=41 from=414 to=454
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ < 2021/05/08 00:27:41.137063 length=52 from=364 to=415
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:42.079453 length=50 from=455 to=504
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:43.029525 length=41 from=505 to=545
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ < 2021/05/08 00:27:44.140293 length=52 from=416 to=467
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:45.079471 length=50 from=546 to=595
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:46.279660 length=41 from=596 to=636
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ < 2021/05/08 00:27:47.143465 length=52 from=468 to=519
~.}#.!}!}!} }8}!}$}!(}"}&} } } } }%}&.sr.}'}"}(}">.~> 2021/05/08 00:27:48.054620 length=50 from=637 to=686
~.}#.!}"}!} }8}}$}!(}"}&} } } }%}&.sr.}'}"}(".} ~ > 2021/05/08 00:27:49.554776 length=41 from=687 to=727
~.}#.!}!}!} }2}}$}!(}%}&}:}4@}}'}"}(}"%.~ 2021/05/08 00:27:50 socat[1083] N read(5, 0x11f15c8, 8192): Input/output error (probably PTY closed)
2021/05/08 00:27:50 socat[1083] N socket 2 (fd 5) is at EOF
2021/05/08 00:27:50 socat[1083] E waitpid(): child 1084 exited with status 16
2021/05/08 00:27:50 socat[1083] N exit(1)
2021/05/08 00:27:50 socat[1082] N childdied(): handling signal 17
2021/05/08 00:27:50 socat[1082] N childdied(): handling signal 17
2021/05/08 00:28:42 socat[1082] N socat_signal(): handling signal 2
2021/05/08 00:28:42 socat[1082] N exiting on signal 2
2021/05/08 00:28:42 socat[1082] N socat_signal(): finishing signal 2
2021/05/08 00:28:42 socat[1082] N exit(130)赛斯洛
May 8 00:27:20 pppd[1084]: pppd 2.4.7 started by pi, uid 0
May 8 00:27:20 pppd[1084]: using channel 2
May 8 00:27:20 pppd[1084]: Using interface ppp0
May 8 00:27:20 pppd[1084]: Connect: ppp0 <--> /dev/pts/2
May 8 00:27:20 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:23 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:26 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:29 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:32 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:35 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:38 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:41 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:44 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:47 pppd[1084]: sent [LCP ConfReq id=0x1 ]
May 8 00:27:50 pppd[1084]: LCP: timeout sending Config-Requests
May 8 00:27:50 pppd[1084]: Connection terminated.
May 8 00:27:50 pppd[1084]: Modem hangup
May 8 00:27:50 pppd[1084]: Waiting for 1 child processes...
May 8 00:27:50 pppd[1084]: script pppd (charshunt), pid 1085
May 8 00:27:50 pppd[1084]: Script pppd (charshunt) finished (pid 1085), status = 0x0
May 8 00:27:50 pppd[1084]: Exit.客户端调试输出:
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
rcvd [LCP ConfReq id=0x1 ]
fsm_rconfreq(LCP): Rcvd id 1.
lcp_reqci: rcvd MRU (296) (ACK)
lcp_reqci: rcvd MAGICNUMBER (99ed93e8) (ACK)
lcp_reqci: rcvd PCOMPRESSION (ACK)
lcp_reqci: rcvd ACCOMPRESSION (ACK)
lcp_reqci: returning CONFACK.
sent [LCP ConfAck id=0x1 ]
fsm_sdata(LCP): Sent code 2, id 1.
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
calltimeout, calling 53ce:2a06.
sent [LCP ConfReq id=0x1 ]
fsm_sdata(LCP): Sent code 1, id 1.
Timeout 53ce:2a06 in 3 seconds.
LCP: sending Configure-Request, id 1
calltimeout, calling 53ce:2a06.
LCP: timeout sending Config-RequestsUpdate:我以前已经尝试过wireshark,除了挖掘数据包查看数据之外,其内容与带有-v选项的Socat输出相同。也试过
socat PTY,link=/tmp/ptya,rawer,nonblock=1,b19200,waitslave tcp-l:2323,fork,reuseaddr
od -ah `readlink /tmp/ptya`LCP数据包是正确的(每个PPP Design-Implementation-Debugging_James-Carlson). )。问题似乎仍然是pppd没有得到客户端数据包,但是它们是由socat接收的。我没有在服务器上启动ppp就这样做了。
root# od -h --endian=big `readlink /tmp/ptya`
# Every 7D XX sequence should be replaced with XX xor 20 (hex)
0000000 7eff 7d23 c021 7d21 7d21 7d20 7d32 7d7d
0000020 227d 287d 2256 6c7e 7eff 7d23 c021 7d21
0000040 7d21 7d20 7d32 7d7d 247d 2128 7d25 7d26
0000060 7d22 6791 2b7d 7d22 7d28 7d22 566c 7e7e
0000100 ff7d 23c0 217d 217d 217d 207d 327d 7d24
0000120 7d21 287d 257d 267d 2267 912b 7d7d 227d
0000140 287d 2256 6c7e 7eff 7d23 c021 7d21 7d21
0000160 7d20 7d32 7d7d 247d 2128 7d25 7d26 7d22
0000200 6791 2b7d 7d22 7d28 7d22 566c 7e7e ff7d
0000220 23c0 217d 217d 217d 207d 327d 7d24 7d21
0000240 287d 257d 267d 2267 912b 7d7d 227d 287d
0000260 2256 6c7e 7eff 7d23 c021 7d21 7d21 7d20
0000300 7d32 7d7d 247d 2128 7d25 7d26 7d22 6791
0000320 2b7d 7d22 7d28 7d22 566c 7e7e ff7d 23c0
0000340 217d 217d 217d 207d 327d 7d24 7d21 287d
0000360 257d 267d 2267 912b 7d7d 227d 287d 2256
0000400 6c7e 7eff 7d23 c021 7d21 7d21 7d20 7d32
0000420 7d7d 247d 2128 7d25 7d26 7d22 6791 2b7d
0000440 7d22 7d28 7d22 566c 7e7e ff7d 23c0 217d
0000460 217d 217d 207d 327d 7d24 7d21 287d 257d
0000500 267d 2267 912b 7d7d 227d 287d 2256 6c7e
0000520 7eff 7d23 c021 7d21 7d21 7d20 7d32 7d7d
0000540 247d 2128 7d25 7d26 7d22 6791 2b7d 7d22尝试使用kdebug选项,但是syslog没有显示ppp接收的任何数据包。
UPDATE 2:这个问题显然与socat有关。我可以直接用串行电缆连接,很快就能得到ppp连接,但是,如果我将PTY连接到串行端口,然后尝试使用PTY连接到ppp,它就会以完全相同的方式失败。PPP服务器只显示“发送”消息,没有收到任何消息。Socat阻止PPP服务器以某种方式从客户端获得答复,或者ppp希望从其他地方接收。这也有助于解释为什么kdebug没有显示ppp接收到的数据包,但也不能解释为什么其他应用程序通过socat连接显示接收到的数据。下面是我尝试失败的命令:
socat -d -d -v file:/dev/ttyUSB0,nonblock,rawer PTY,rawer,link=/tmp/ptya
pppd `readlink /tmp/ptya`发布于 2021-05-09 03:56:37
这并不是对实际问题的回答,但也许会有所帮助:
如果您只想让pppd使用PTY,为什么不直接在pppd命令中指定它呢?例如,当我在玩pppd时,以下内容对我起了作用:
socat PTY,link=/tmp/ptya PTY,link=/tmp/ptyb
sudo pppd `readlink /tmp/ptya` noauth nocrtscts xonxoff local maxfail 0 10.0.3.1:10.0.3.2 persist
sudo pppd `readlink /tmp/ptyb` noauth nocrtscts xonxoff local maxfail 0 10.0.3.2:10.0.3.1 persist在不看细节的情况下,我怀疑pppd notty与它的工作不正常有关。
需要PTY将Socat套接字连接到ppp的终端设备上。
是。也是如此。
socat -d -d -v tcp-l:2323,fork,reuseaddr PTY,link=/tmp/ptya
/usr/sbin/pppd `readlink /tmp/ptya` ...看看能不能更好点。
使用此选项,pppd将为自己分配一个伪主/从对,并使用从站作为其终端设备。
因此,如果socat分配一个PTY,而pppd也分配一个不同的PTY,如果socat使用第一个PTY,而pppd使用第二个PTY,那么它们如何能够相互通信呢?他们需要使用相同的PTY (嗯,不同的一面)。
我正在使用Socat创建一个套接字来连接到pppd的连接。这个客户端是一个老式的DOS掌上电脑,运行剂量are,它使用了我之前已经尝试过的USB电缆,除了挖掘数据包来查看数据外,它的内容与带有-v选项的Socat输出相同。
现在你必须解释谁连接到端口2323,这端是什么,以及它与一个老式DOS掌上电脑有什么关系,因为我真的不明白这部分。
从您的描述来看,pppd正在工作,socat正在工作,他们的共享PTY正在工作,某些东西(不管是什么)连接到2323,而socat正在向它发送数据,但是没有收到任何数据。
这是正确的吗?(如果您不知道详细信息,远程调试是非常困难的)。
https://unix.stackexchange.com/questions/648869
复制相似问题