Abstract: This issue xiaobian brings you the use of LiteOS open source Ping component instructions, please follow the steps of xiaobian together into the journey of exploration!

This article is from Huawei Cloud community “LiteOS Component Test – Play Ping”, author: Lionlace.

Basic introduction

ICMP: Internet Control Message Protocol

Ping: Packet Internet Groper

The Ping command uses the ICMP protocol to send data to check whether the network is normal.

The principle of

Ping is used to determine whether the local host can successfully exchange (send and receive) packets with another host. Based on the displayed information, you can check whether TCP/IP parameters are correctly set, whether the TCP/IP network runs normally, and whether the network is normal. The operations of the Ping command are as follows:

  • Verify connections to one or more remote computers by sending ICMP echo packets to the computer and listening for the echo packets;

  • Each sent packet waits at most one second;

  • Prints the number of packets transmitted and received. Note that the successful ping does not necessarily mean that the TCP/IP configuration is correct. You may need to perform a large number of packet exchanges between the local host and remote host to verify the TCP/IP configuration. If the ping succeeds and the network is still unavailable, the fault may be caused by the software configuration of the network system. A successful Ping ensures that only one network path exists between the current host and the destination host.

Directions for use

Ping is used to check whether the network is normal or the network connection speed. A smaller delay increases the network speed; otherwise, a larger delay decreases the network speed.

Theoretically, all development boards supporting lwIP protocol stack in LiteOS can support ping command. Currently, development boards with ping function have been verified as follows:

STM32F769IDISCOVERY

Cloud_STM32F429IGTx_FIRE

Ping command format

[ping <IP >]

Can make ping

Set the LiteOS source code to the root directory, copy the default configuration file ${platform}. Config from tools/build/config/ to the root directory and rename it.config.

Continue with the make Menuconfig command in the LiteOS source directory and enable ping by following the menu path below.

Components  --->
     Network  --->
         [*] Enable Ping
Copy the code

After ping is enabled, LiteOS will automatically enable ping dependent lwIP and set it to Ipv4 mode. After menuconfig is saved and exited, LiteOS will automatically download the source code of lwIP from Github, download the corresponding patch package from LiteOS_Components of Gitee, and enter the patch. For details about the component download process, see gitee.com/LiteOS/Lite… .

** Note: ** Download requires a Linux host with Internet access and Git installed.

test

1. Prepare a PC running Linux or Windows.

2. Connect the PC and development board to the same LAN;

3. Connect the serial port of the development version to the PC and start the serial port monitoring software. (The IP address of the test PC is 192.168.x.y.

4. After ping is enabled, run make clean in the LiteOS source code root directory. Make -j command to compile the LiteOS project. After the compilation is successful, the static library file libping.a is generated in the out/${platform}/lib directory, and the system image file is Huawei_LiteOS.

5. Burn system image files and reset the development board;

6. Enter shell and run help. If ping is displayed, the ping command has taken effect.

Huawei LiteOS # help
*******************shell commands:*************************
date          free          help          hwi           ifconfig      log           memcheck      ping  
swtmr         systeminfo    task          uname         watch  
Huawei LiteOS #
Copy the code

7. Test the network

Run the ping192.168.x.y command in shell. If the following command output is displayed, the network is normal.

Y ping 4 packets start. Huawei LiteOS # Huawei LiteOS # [0]Reply from 192.168.x.y: [1]Reply from 192.168.x. Y: time=0ms TTL=128. [2]Reply from 192.168.x. Time =1ms TTL=128. [3]Reply from 192.168.x.y: time=1ms TTL=128.Copy the code

If the request times out, the following information indicates that the network is faulty.

Y ping 4 packets start. Huawei LiteOS # ping: request timed out. Ping: request timed out Ping : request timed out. Ping : request timed out.Copy the code

The above is all the content of “ping” instructions. Welcome to learn and exchange.

conclusion

We will continue to add more components, development boards, architectures, features and more in the future.

Thank you for reading, have any questions, suggestions, please leave a message to us, let us progress together:

Gitee.com/LiteOS/Lite… .

To make it easier to find the “LiteOS” code store, visit gitee.com/LiteOS/Lite… , follow “Watch”, like “Star”, and “Fork” to your own account, as shown in the picture.

To learn more, please pay attention to the IoT community, add huawei Cloud IoT Small Assistant wechat account (HWC-iot), reply to “Read” for more information.

Click to follow, the first time to learn about Huawei cloud fresh technology ~