5G网卡network connection: disconnected
日志
5G流程中没有报任何错误,但是重新拿地址了,感觉像是驱动层连接断开了,dmesg中日志如下:
[ 1526.558377] ippassthrough:set [ ip=10.108.40.47 mask=27 ip_net=10.108.40.32 router=10.108.40.33 dns=221.12.1.227 221.12.33.227] br-lan
[ 1526.611901] paranum:3, print all para:10.108.40.47 27 10.108.40.33
[ 1526.624461] 00-ip_forward trace: ACTION=ifup INTERFACE=usb0
[ 1526.642179] ippassthrough:24 uci config network.usb0.ippassthrough=0
[ 1526.752928] 00-ip_forward:13 enable=0 ipaddr= wanip=10.108.40.47
[ 1526.790193] 00-ip_forward:17 enable=0 forwarding=1
[33074.341964] cdc_ncm 1-1:2.0 usb0: network connection: disconnected
[33074.409453] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[33074.431074] 00-ip_forward trace: ACTION=ifdown INTERFACE=usb0
[33074.482347] 00-ip_forward:13 enable=0 ipaddr= wanip=
[33074.500230] 00-ip_forward:17 enable=0 forwarding=1
[33077.638013] cdc_ncm 1-1:2.0 usb0: 350 mbit/s downlink 350 mbit/s uplink
[33077.670000] cdc_ncm 1-1:2.0 usb0: network connection: connected
[33077.682119] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
[33077.877715] deconfig
[33078.419726] ippassthrough:set [ ip=10.120.73.215 mask=28 ip_net=10.120.73.208 router=10.120.73.209 dns=221.12.1.227 221.12.33.227] br-lan
[33078.480873] 00-ip_forward trace: ACTION=ifup INTERFACE=usb0
[33078.508550] paranum:3, print all para:10.120.73.215 28 10.120.73.209
[33078.529942] ippassthrough:24 uci config network.usb0.ippassthrough=0
[33078.673876] 00-ip_forward:13 enable=0 ipaddr= wanip=10.120.73.215
[33078.711189] 00-ip_forward:17 enable=0 forwarding=1
[90870.526202] br-lan: port 2(lan) neighbor 7fff.2a:3b:a1:3e:9a:a2 lost
[90870.538872] br-lan: topology change detected, propagating
[90870.550102] br-lan: port 2(lan) received tcn bpdu
[90870.559459] br-lan: topology change detected, propagating
关键日志:
[33074.341964] cdc_ncm 1-1:2.0 usb0: network connection: disconnected---断开
[33077.638013] cdc_ncm 1-1:2.0 usb0: 350 mbit/s downlink 350 mbit/s uplink
[33077.670000] cdc_ncm 1-1:2.0 usb0: network connection: connected-----恢复
查后台代码如下:
重点看下注释:说是根据CDC NCM规范,说是当通信速率变化时,由设备侧发出的事件。
USB接口虚拟网卡
ECM
- 驱动文件路径drivers/net/usb/cdc_ether.c;
- 包含MAC头,需要MAC地址,由eth_random_addr(u8 *addr)产生;
- ECM虚拟网卡host和device端的MAC地址,都由device端生成,并且host_mac通过USB字符串描述符(字符串索引是iMACAddress)传给host;
- 传输的是纯粹的以太网包,一次USB传输只包含一个以太网帧。
MBIM
不包含MAC头,Raw IP mode。
NCM
USB_CDC_NOTIFY_NETWORK_CONNECTION
driver/net/usb/cdc_ncm.c
给通知USB_CDC_NOTIFY_NETWORK_CONNECTION加个log,判断网络接口断开是软件断开,还是物理断开。如果看到USB host端网络节点disconnect,并且这个log也打印了,那么说明从interrupt IN端点收到了断开通知,这个断开是由USB gadget端ifconfig down导致的,如果看到USB host端网络节点disconnect,并且没有log打印,那么就是物理断开。
- 包含MAC头,需要MAC地址,由eth_random_addr(u8 *addr)产生;
- NCM虚拟网卡host和device端的MAC地址,都由device端生成,并且host_mac通过USB字符串描述符(字符串索引是iMACAddress)传给host;
每一个USB NCM报文从偏移字节20开始(第一个字节偏移为0)的每4个字节为1组,前2个字节(小端模式)表示Ethernet帧的在该NCM中的偏移字节,后2个字节(小端模式)表示该Ethernet帧的长度。每个以太网帧头有14个字节,如果看到EtherType等于86 DD表示该帧为IPv6。
Table 3-1: Sixteen Bit NCM Transfer Header (NTH16)
Table 3-3: Sixteen-bit NCM Datagram Pointer Table (NDP16)
RNDIS
- 包含MAC头,需要MAC地址,由eth_random_addr(u8 *addr)产生;
- RNDIS虚拟网卡host和device端的MAC地址,都由device端生成,并且host_mac通过控制传输传给host;
- 每个RNDIS报文有RNDIS报头,每个RNDIS报文可以包含多个以太网帧(MaxPacketsPerTransfer),这种特性称为报文聚合,即调用一次URB可以发送或者接收多个IP报文。
RMNET
7.1 RMNET
- 不包含MAC头,Raw IP mode;
- device端MAC地址由eth_random_addr(u8 *addr)产生;host端的MAC地址由host端驱动指定;
- 每个RMNET报文有RMNET报头,每个RMNET报文可以包含多个以太网帧,这种特性称为报文聚合,即调用一次URB可以发送或者接收多个IP报文。
7.2 IPA
ETH_P_MAP: 0x00F9, Qualcomm multiplexing and aggregation protocol