openharmony 鸿蒙 kernel-small-debug-shell-net-arp

2022-08-09 浏览 (841)

arp

Command Function

Hosts on an Ethernet communicate with each other using MAC addresses. IP addresses must be converted into MAC addresses to enable communication between hosts on a LAN (Ethernet). To achieve this purpose, the host stores a table containing the mapping between IP addresses and MAC addresses. This table is called an Address Resolution Protocol (ARP) cache table. Before sending an IP packet to a LAN, the host looks up the destination MAC address in the ARP cache table. The ARP cache table is maintained by the TCP/IP stack. You can run the arp command to view and modify the ARP cache table.

Syntax

arp

arp [-i IF] -s IPADDR HWADDR

arp [-i IF] -d IPADDR

Parameters

Table 1 Parameter description

ParameterDescriptionValue Range
No parameterPrints the content of the ARP cache table.N/A
-i IFSpecifies the network port. This parameter is optional.N/A
-s IPADDR
HWADDR
Adds an ARP entry. The second parameter is the IP address and MAC address of the other host on the LAN.N/A
-d IPADDRDeletes an ARP entry.N/A

Usage Guidelines

  • The arp command is used to query and modify the ARP cache table of the TCP/IP stack. If ARP entries for IP addresses on different subnets are added, the protocol stack returns a failure message.

  • This command can be used only after the TCP/IP protocol stack is enabled.

Example

Run arp.

ARP cache table information:

OHOS # arp
Address                 HWaddress               Iface       Type
192.168.1.10            E6:2B:99:2C:4B:20       eth0        static

Table 2 Parameter description

ParameterDescription
AddressIPv4 address of the network device.
HWaddressMAC address of the network device.
IfaceName of the port used by the ARP entry.
TypeWhether the ARP entry is dynamic or static. A dynamic ARP entry is automatically created by the protocol stack, and a static ARP entry is added by the user.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Kernel

harmony 鸿蒙Kernel Coding Specification

harmony 鸿蒙Standard Libraries

harmony 鸿蒙Interrupt Management

harmony 鸿蒙Event

harmony 鸿蒙Mutex

harmony 鸿蒙Queue

harmony 鸿蒙Semaphore

harmony 鸿蒙Doubly Linked List

harmony 鸿蒙Memory Management

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/b3f9fcd71249407ba06648ed9856e998