The usage of ifconfig, ping, ethtool, iperf.
1. ifconfig displays ip address or configures network properties
root@imx8mpevk:~# ifconfig -a
can0: flags=128<NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 231
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.100.20 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::204:9fff:fe08:55ee prefixlen 64 scopeid 0x20<link>
ether 00:04:9f:08:55:ee txqueuelen 1000 (Ethernet)
RX packets 108581 bytes 140666934 (134.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 36147 bytes 8210634 (7.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC> mtu 1500
ether 00:04:9f:08:55:ef txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 223
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1549 bytes 96683 (94.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1549 bytes 96683 (94.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Can0 is the network card of the CAN interface. You can see that there are three network cards: eth0, eth1 and lo. The network card which can be used is eth0, whose IP address is 192.168.100.20, and its MAC address is 00:04:9f:08:55:ee. There is no network cable plugged into eth1, so No IP address is displayed. lo is a loopback test network card. If eth0 does not have a ip address after the system starts (such running busybox file rootfs), you can use the ifconfig eth0 xxxx command to set or modify the IP address.
2. ping command to verify network interfac
Firstly, check the host IP address using cat /proc/cmdline
root@imx8mpevk:~# cat /proc/cmdline
console=ttymxc1,115200 root=/dev/nfs ip=dhcp nfsroot=192.168.100.250:/opt/REAL/NFS/IMX8MPEVK-4-root,v3,tcp
You can see that the host IP address is 192.168.100.250. Use the ping command as follows:
root@imx8mpevk:~# ping 192.168.100.250
PING 192.168.100.250 (192.168.100.250) 56(84) bytes of data.
64 bytes from 192.168.100.250: icmp_seq=1 ttl=64 time=1.06 ms
64 bytes from 192.168.100.250: icmp_seq=2 ttl=64 time=1.37 ms
64 bytes from 192.168.100.250: icmp_seq=3 ttl=64 time=1.37 ms
^C
--- 192.168.100.250 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.063/1.265/1.367/0.143 ms
You can see the statistics of packets sent and received, indicating that the communication between the board and the host is successful (the board is started through nfs, so the board and the host network are connected. Because the board is not connected to the external network, pinging the external network will fail).
3. ethtool obtains Ethernet card information or modifies parameter configuration
root@imx8mpevk:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Link partner advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
master-slave cfg: preferred slave
master-slave status: slave
Port: Twisted Pair
PHYAD: 1
Transceiver: external
MDI-X: Unknown
Supports Wake-on: g
Wake-on: d
Link detected: yes
From ethtool eth0, you can see that Speed: 1000Mb/s in the output information indicates that this is a Gigabit network card, and Auto-negotiation: on indicates that it is in an automatic negotiation state with the host. ethtool common commands are as below:
ethtool -i eth0
// Display the network card driver name, Linux kernel version and other information
ethtool -S eth0
// Check whether there are any errors when the network card receives/sends data, etc.
ethtool -s eth0 speed 10 duplex full autoneg on
//Modify the network card settings. This command sets the speed to 10M, full duplex, and turns on auto-negotiation.
4. iperf sends network stream:
Iperf is a testing tool for sending and receiving data streams between the server and the client. The following uses the board as the client and the host PC as the server:
iperf -c 192.168.100.33 -t 600 -i 1 -u -b 1000M
-c: Specify the server IP address to connect to
-t : Test time
-i : time interval
-u: test udp
-b: Maximum test bandwidth
root@imx8mpevk:~# iperf -c 192.168.100.33 -t 600 -i 1 -u -b 1000M
------------------------------------------------------------
Client connecting to 192.168.100.33, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11.22 us (kalman adjust)
UDP buffer size: 12.0 MByte (default)
------------------------------------------------------------
[ 3] local 192.168.100.20 port 37634 connected with 192.168.100.33 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 1.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 1.0- 2.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 2.0- 3.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 3.0- 4.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 4.0- 5.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 5.0- 6.0 sec 125 MBytes 1.05 Gbits/sec
[ 3] 6.0- 7.0 sec 125 MBytes 1.05 Gbits/sec
^C[ 3] WARNING: did not receive ack of last datagram after 10 tries.
[ 3] 0.0- 7.6 sec 950 MBytes 1.05 Gbits/sec
[ 3] Sent 677488 datagrams