CN106713525B - Method, device and system for configuring communication parameters - Google Patents

Method, device and system for configuring communication parameters Download PDF

Info

Publication number
CN106713525B
CN106713525B CN201611248651.8A CN201611248651A CN106713525B CN 106713525 B CN106713525 B CN 106713525B CN 201611248651 A CN201611248651 A CN 201611248651A CN 106713525 B CN106713525 B CN 106713525B
Authority
CN
China
Prior art keywords
address
terminal device
arp
address carried
destination
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611248651.8A
Other languages
Chinese (zh)
Other versions
CN106713525A (en
Inventor
季本奎
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201611248651.8A priority Critical patent/CN106713525B/en
Publication of CN106713525A publication Critical patent/CN106713525A/en
Application granted granted Critical
Publication of CN106713525B publication Critical patent/CN106713525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention provides a method, a device and a system for configuring communication parameters, relates to the technical field of communication, and can save the implementation cost of terminal equipment and network equipment while configuring the communication parameters for the terminal equipment. The method comprises the following steps: the terminal equipment receives a first ARP message, the first ARP message carries a source IP address and a destination IP address, the terminal equipment determines that the terminal equipment is not configured with communication parameters, and after the terminal equipment determines that the terminal equipment is not configured with the communication parameters, the terminal equipment configures the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message.

Description

Method, device and system for configuring communication parameters
Technical Field
The embodiment of the invention relates to the technical field of communication, in particular to a method, a device and a system for configuring communication parameters.
Background
With the development of communication technology, the number and the variety of terminal devices are increasing.
In order to enable communication between terminal devices, it is generally necessary to configure communication parameters for the terminal devices after the terminal devices access a local network (e.g., a local area network), such as an Internet Protocol (IP) address, a mask, and a gateway address for the terminal devices. Currently, communication parameters may be configured for a terminal device through a Dynamic Host Configuration Protocol (DHCP). Specifically, after the terminal device accesses the local network, the terminal device sends a DHCP discovery (DHCP discover) message, and after the relay device located between the terminal device and the server receives the DHCP discovery message, the relay device forwards the DHCP discovery message to the server, so that after the server receives the DHCP discovery message, the server configures communication parameters for the terminal device.
However, in the method for configuring communication parameters for a terminal device by using DHCP, the terminal device, the relay device, and the server are all required to support DHCP (specifically, both hardware and software are required to support), so when the method is used for configuring communication parameters for a terminal device, the implementation cost of the terminal device and the network device (such as the relay device and the server) is relatively high.
Disclosure of Invention
The application provides a method, a device and a system for configuring communication parameters, which can save the implementation cost of terminal equipment and network equipment while configuring the communication parameters for the terminal equipment.
In order to achieve the purpose, the technical scheme is as follows:
in a first aspect, a method for configuring communication parameters is provided, the method comprising: the method comprises the steps that terminal equipment receives a first Address Resolution Protocol (ARP) message carrying a source IP address and a destination IP address; and the terminal device determines that the terminal device is not configured with communication parameters; and after the terminal equipment determines that the terminal equipment is not configured with the communication parameters, the terminal equipment configures the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message.
In this application, when the terminal device is not configured with the communication parameters, the terminal device may configure the communication parameters for the terminal device according to at least one of the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet. Therefore, when the method for configuring the communication parameters is adopted to configure the communication parameters for the terminal equipment, the terminal equipment and the network equipment do not need to support DHCP, so that the realization cost of the terminal equipment and the network equipment can be saved while the communication parameters are configured for the terminal equipment.
In a first possible implementation manner of the first aspect, the communication parameter at least includes an IP address of the terminal device. Before the terminal equipment configures communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, the terminal equipment determines that the destination IP address of one ARP message is an effective IP address. The method for the terminal equipment to configure the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message comprises the following steps: and the terminal equipment configures the destination IP address carried by the first ARP message as the IP address of the terminal equipment.
In the method, the terminal device can configure the destination IP address carried by the first ARP packet as the IP address of the terminal device, so that when the IP address is configured for the terminal device by using the method for configuring communication parameters provided by the present application, the terminal device and the network device do not need to support DHCP, and thus the implementation cost of the terminal device and the network device can be saved while the IP address is configured for the terminal device.
In a second possible implementation manner of the first aspect, the method for determining, by a terminal device, that a destination IP address carried in a first ARP packet is an effective IP address may include: and after the terminal equipment sends the second ARP message, if the terminal equipment does not receive a response message of the second ARP message which carries the source IP address and the destination IP address which are the same as the source IP address carried by the second ARP message within preset time, the terminal equipment determines that the destination IP address carried by the first ARP message is an effective IP address.
In this application, the valid IP address may be understood as an IP address that is not occupied by other terminal devices in the subnet where the terminal device is located (i.e., other terminal devices except the terminal device in the subnet where the terminal device is located).
In this application, a terminal device (may be referred to as a first terminal device) may send a second ARP packet whose source IP address and destination IP address are both the same as the destination IP address carried in the first ARP packet, and after other terminal devices (may be referred to as second terminal devices) in a subnet where the first terminal device is located receive the second ARP packet, the second terminal device may determine whether the IP address of the second terminal device is the same as the source IP address carried in the second ARP packet. And when the second terminal equipment determines that the IP address of the second terminal equipment is the same as the source IP address carried by the second ARP message, the second terminal equipment sends a response message of the second ARP message. When the second terminal device determines that the IP address of the second terminal device is different from the source IP address carried by the second ARP packet, the second terminal device discards the second ARP packet, that is, the second terminal device does not send a response packet of the second ARP packet. In this way, the first terminal device may determine whether the destination IP address carried by the first ARP packet is an effective IP address (i.e., whether the destination IP address carried by the first ARP packet is occupied by other terminal devices in the subnet where the first terminal device is located) by determining whether the response packet of the second ARP packet is received within a preset time after the second ARP packet is sent.
In a third possible implementation manner of the first aspect, the communication parameter at least includes a gateway address of the terminal device. The method for the terminal equipment to configure the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message comprises the following steps: and the terminal equipment configures the source IP address carried by the first ARP message as a gateway address of the terminal equipment.
In the method, the terminal device can configure the source IP address carried by the first ARP packet as the gateway address of the terminal device, so that when the method for configuring communication parameters is used for configuring the gateway address for the terminal device, the terminal device and the network device do not need to support DHCP, and therefore, the gateway address can be configured for the terminal device, and the implementation cost of the terminal device and the network device can be saved.
In a fourth possible implementation manner of the first aspect, the communication parameter at least includes a mask of the terminal device. The method for the terminal equipment to configure the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message comprises the following steps: the terminal device can calculate the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, and configures a mask for the terminal device according to the calculation result.
In the method, the terminal device can calculate the source IP address carried by the first ARP message and the target IP address carried by the first ARP message, and configures the mask for the terminal device according to the calculation result, so that when the method for configuring the communication parameters is adopted to configure the mask for the terminal device, the terminal device and the network device do not need to support DHCP, and the realization cost of the terminal device and the network device can be saved while the mask is configured for the terminal device.
In a fifth possible implementation manner of the first aspect, the method for the terminal device to calculate the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet, and configure a mask for the terminal device according to a result of the calculation includes: the terminal equipment calculates the source IP address carried by the first ARP message and the target IP address carried by the first ARP message, determines the reverse mask of the mask according to the calculation result, performs bitwise non-calculation on the reverse mask by the terminal equipment, and configures the bitwise non-calculation result as the mask of the terminal equipment.
In a sixth possible implementation manner of the first aspect, the method for the terminal device to calculate the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet, and determine the anti-mask of the mask according to the calculation result includes: the method comprises the steps that a terminal device starts bitwise XOR operation on a source IP address carried by a first ARP message and a destination IP address carried by the first ARP message from the highest position, under the condition that the result of the bitwise XOR operation on the mth position of the source IP address carried by the first ARP message and the mth position of the destination IP address carried by the first ARP message is 1, the terminal device stops bitwise XOR operation on the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message and generates n first serial codes, and under the condition that the number of 1 in the n first serial codes is larger than 1, the terminal device determines the n first serial codes as an anti-mask of a mask, or; and under the condition that the number of 1 in the n-bit first string code is equal to 1, the terminal equipment determines a preset n-bit second string code as an inverse mask of the mask. Wherein m is an integer larger than zero, n is the same as the number of bits of the source IP address carried by the first ARP message and the number of bits of the destination IP address carried by the first ARP message, the values of the high m-1 bits of the n-bit first string code are all 0, the values of the low n-m +1 bits of the n-bit first string code are all 1, and n > m.
In the method, the terminal device can calculate the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, determine the reverse mask of the mask according to the calculation result, and can configure the result of bitwise non-calculation into the mask of the terminal device by bitwise non-calculation of the reverse mask, so that when the method for configuring the communication parameters is adopted to configure the mask for the terminal device, the terminal device and the network device do not need to support DHCP, thereby saving the implementation cost of the terminal device and the network device while configuring the mask for the terminal device.
In a second aspect, a terminal device is provided, which includes: the device comprises a receiving module, a determining module and a configuring module. The receiving module is used for receiving a first ARP message carrying a source IP address and a destination IP address; the determining module is used for determining that the terminal equipment is not configured with communication parameters; the configuration module is used for configuring the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message received by the receiving module after the determination module determines that the terminal equipment is not configured with the communication parameters.
In a first possible implementation manner of the second aspect, the communication parameter at least includes an IP address of the terminal device. The determining module is further configured to determine that a destination IP address carried by the first ARP packet received by the receiving module is an effective IP address before the configuration module configures the communication parameter for the terminal device according to at least one of a source IP address carried by the first ARP packet and a destination IP address carried by the first ARP packet, and the configuration module is specifically configured to configure the destination IP address carried by the first ARP packet received by the receiving module as the IP address of the terminal device after the determining module determines that the destination IP address carried by the first ARP packet is the effective IP address.
In a second possible implementation manner of the second aspect, the determining module is specifically configured to send a second ARP packet with a source IP address and a destination IP address both the same as a destination IP address carried in the first ARP packet, and after sending the second ARP packet, if a response packet of the second ARP packet with the source IP address and the destination IP address both the same as the source IP address carried in the second ARP packet is not received within a preset time, determine that the destination IP address carried in the first ARP packet received by the receiving module is an effective IP address.
In a third possible implementation manner of the second aspect, the communication parameter at least includes a gateway address of the terminal device. The configuration module is specifically configured to configure the source IP address carried by the first ARP packet received by the receiving module as a gateway address of the terminal device.
In a fourth possible implementation manner of the second aspect, the communication parameter at least includes a mask of the terminal device. The configuration module is specifically configured to calculate a source IP address carried by the first ARP packet received by the receiving module and a destination IP address carried by the first ARP packet, and configure a mask for the terminal device according to a result of the calculation.
In a fifth possible implementation manner of the second aspect, the configuration module is specifically configured to perform an operation on a source IP address carried by the first ARP packet received by the receiving module and a destination IP address carried by the first ARP packet, and determine a reverse mask of the mask according to an operation result; and bitwise negating the inverse mask, and configuring the result of bitwise negation as a mask of the terminal equipment.
In a sixth possible implementation manner of the second aspect, the configuration module is specifically configured to perform a bitwise exclusive or operation on a source IP address carried by the first ARP packet received by the receiving module and a destination IP address carried by the first ARP packet from a highest bit; under the condition that the m-th bit of the source IP address carried by the first ARP message and the m-th bit of the target IP address carried by the first ARP message are subjected to exclusive OR operation with the result of 1, stopping carrying out exclusive OR operation on the source IP address carried by the first ARP message and the target IP address carried by the first ARP message according to bits; and generating a first string of n bits; and determining the n-bit first string code as the mask inverse of the mask if the number of 1 in the n-bit first string code is greater than 1, or determining a preset n-bit second string code as the mask inverse of the mask if the number of 1 in the n-bit first string code is equal to 1. Wherein m is an integer larger than zero, n is the same as the number of bits of the source IP address carried by the first ARP message and the number of bits of the destination IP address carried by the first ARP message, the values of the high m-1 bits of the n-bit first string code are all 0, the values of the low n-m +1 bits of the n-bit first string code are all 1, and n > m.
For a description of the technical effect of the second aspect or any one of its possible implementations, reference may be specifically made to the above-mentioned description of the technical effect of the first aspect or any one of its possible implementations, and details are not described here again.
In the above first and second aspects, the communication parameter includes at least one of: the IP address of the terminal equipment, the gateway address of the terminal equipment and the mask code of the terminal equipment.
In a third aspect, a terminal device is provided, which includes: a processor, a transceiver, and a memory. The memory is used for storing computer-executable instructions, and when the terminal device runs, the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method for configuring the communication parameters according to the first aspect or any one of the possible implementation manners of the first aspect.
In a fourth aspect, a computer-readable storage medium is provided, in which one or more programs are stored, and the one or more programs include computer-executable instructions, and when a processor of a terminal device executes the computer-executable instructions, the terminal device executes the method for configuring communication parameters according to the first aspect or any one of the possible implementation manners of the first aspect.
For the description of the technical effects of the third aspect and the fourth aspect, reference may be specifically made to the above description of the technical effects of the first aspect or any one of the possible implementation manners thereof, and details are not described here again.
In a fifth aspect, a communication system is provided, which includes: a gateway, a remote device, and any one of the foregoing possible implementations of the second aspect and the second aspect or the terminal device in the third aspect, wherein the terminal device and the remote device are connected to the gateway.
For a description of the technical effect of the fifth aspect, reference may be specifically made to the above description of any one of the second aspect, the possible implementation manner of the second aspect, or the technical effect of the third aspect, and details are not repeated here.
Drawings
Fig. 1 is a schematic architecture diagram of a communication system according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a hardware structure of a probe apparatus according to an embodiment of the present invention;
fig. 3 is a first schematic diagram illustrating a method for configuring communication parameters according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a method for configuring communication parameters according to an embodiment of the present invention;
fig. 5 is a third schematic diagram illustrating a method for configuring communication parameters according to an embodiment of the present invention;
fig. 6 is a first schematic structural diagram of a terminal device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
The terms "first" and "second", etc. in the embodiments of the present invention are used to distinguish different objects, not to describe a specific order. For example, the first terminal device and the second terminal device are used to distinguish different terminal devices, rather than to describe a specific order of the terminal devices.
In the embodiments of the present invention, words such as "exemplary" or "for example" are used to mean serving as examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "e.g.," an embodiment of the present invention is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
In the description of the present invention, the meaning of "a plurality" means two or more unless otherwise specified. For example, the plurality of terminal devices means two or more terminal devices.
The technical solutions in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings in the embodiments of the present invention.
In order to enable communication between terminal devices, it is generally necessary to configure communication parameters for the terminal devices after the terminal devices access the local network, for example, to configure IP addresses, masks, gateway addresses, and the like for the terminal devices. Currently, communication parameters can be configured for a terminal device through DHCP. Specifically, after the terminal device accesses the local network, the terminal device sends a DHCP discovery message, and after the relay device located between the terminal device and the server receives the DHCP discovery message, the relay device forwards the DHCP discovery message to the server, so that after the server receives the DHCP discovery message, the server configures communication parameters for the terminal device. However, in the method for configuring communication parameters for a terminal device by using DHCP, the terminal device, the relay device, and the server are all required to support DHCP (specifically, both hardware and software are required to support), so when the method is used for configuring communication parameters for a terminal device, the implementation cost of the terminal device and the network device (such as the relay device and the server) is relatively high.
In order to solve the foregoing problem, an embodiment of the present invention provides a method for configuring a communication parameter, where a terminal device may configure a communication parameter for the terminal device according to at least one of a source IP address carried in the first ARP packet and a destination IP address carried in the first ARP packet. Therefore, when the method for configuring the communication parameters is adopted to configure the communication parameters for the terminal equipment, the terminal equipment and the network equipment do not need to support DHCP, so that the realization cost of the terminal equipment and the network equipment can be saved while the communication parameters are configured for the terminal equipment.
The method for configuring the communication parameters provided by the embodiment of the invention can be applied to a communication system. Fig. 1 is a schematic diagram of a system architecture of a communication system according to an embodiment of the present invention. In fig. 1, the communication system includes a remote device, a gateway, a terminal device 1, a terminal device 2, and a terminal device 3, and the terminal device 1, the terminal device 2, the terminal device 3, and the remote device are connected to the gateway. The remote device is connected to the gateway through an IP network or a multi-protocol label switching (MPLS) network. For example, assuming that the terminal device 1, the terminal device 2, and the terminal device 3 are all connected to a local network, and the terminal device 2 and the terminal device 3 have already configured communication parameters (for example, an IP address has already been configured), the terminal device 3 has not configured communication parameters (for example, an IP address has not been configured), the remote device may send an IP message to the gateway, and set a destination IP address of the IP message as an IP address pre-configured to the terminal device 1 (specifically, a technician may set a destination P address of the IP message as an IP address pre-configured to the terminal device 1 on the remote device), after receiving the IP message, the gateway may set the destination IP address of the IP message as a destination IP address carried by the first ARP message because the gateway does not store a Media Access Control (MAC) address corresponding to the destination IP address of the IP message, and setting the IP address of the gateway as a source IP address carried by the first ARP message, and sending the first ARP message to all terminal equipment connected with the gateway (namely all terminal equipment in a subnet where the gateway is located) so as to obtain an MAC address corresponding to a destination IP address of the IP message. First, after the terminal device 1 receives a first APR message sent by a gateway, the terminal device 1 may determine whether the terminal device 1 is not configured with communication parameters, and after determining that the terminal device 1 is not configured with communication parameters, the terminal device 1 may configure the communication parameters for the terminal device 1 according to at least one of a source IP address carried in the first ARP message and a destination IP address carried in the first ARP message. For example, the terminal device 1 may configure the destination IP address carried in the first ARP packet as the IP address of the terminal device 1. Secondly, after the terminal device 1 configures the destination IP address carried by the first ARP message as the IP address of the terminal device 1, the terminal device 1 may reply a response message of the first ARP message including the MAC address of the terminal device 1 to the gateway, so that the gateway may obtain the MAC address of the terminal device 1 from the response message of the first ARP message after receiving the response message of the first ARP message, and thus the gateway may use the MAC address of the terminal device 1 as the MAC address corresponding to the destination IP address of the IP message, that is, the gateway may use the MAC address of the terminal device 1 as the MAC address corresponding to the IP address of the terminal device 1, and further the gateway may store the corresponding relationship between the IP address of the terminal device 1 and the MAC address of the terminal device 1.
The communication system provided by the embodiment of the invention can not limit the number of the terminal devices. Fig. 1 illustrates an example in which 3 terminal apparatuses are included in the communication system. It should be noted that, when there is a terminal device to be configured with communication parameters in the communication system, the method for configuring communication parameters provided in the embodiment of the present invention may be used to configure communication parameters for the terminal device. When there are a plurality of terminal devices to be configured with communication parameters in the communication system, the method for configuring communication parameters provided by the embodiment of the present invention may be used to sequentially configure communication parameters for the plurality of terminal devices to be configured with communication parameters, that is, the method provided by the embodiment of the present invention may configure communication parameters for one terminal device at a time.
The terminal device in the embodiment of the present invention may also be referred to as a terminal (terminal), and the terminal device may be a computer, a Mobile Station (MS), a mobile terminal (MS), a notebook computer, or a probe device.
For example, taking the terminal device in the embodiment of the present invention as a probe device as an example, the following describes in detail a hardware structure of the probe device in the embodiment of the present invention with reference to fig. 2.
As shown in fig. 2, the probe apparatus may include: processor 11, transceiver 12, and memory 13. Those skilled in the art will appreciate that the configuration of the probe device shown in FIG. 2 does not constitute a limitation of the probe device, and may include more or fewer components than those shown in FIG. 2, or may combine some of the components shown in FIG. 2, or may be arranged differently than those shown in FIG. 2.
The processor 11 is a control center of the probe apparatus, connects various parts of the entire probe apparatus using various interfaces and lines, and implements functions of the probe apparatus by running or executing software programs and/or modules stored in the memory 13 and calling data stored in the memory 13. Alternatively, processor 11 may include one or more processing units; for example, the processor 11 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may also be integrated in the probe device as a separate module from the processor 11.
The transceiver 12 may be used to support data interaction between the probe device and other devices.
The memory 13 may be used to store software programs and modules, and the processor 11 executes functional applications and data processing of the probe device by running the software programs and modules stored in the memory 13. Further, the memory 13 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
Optionally, the probe device may further comprise a power source, which may be a battery. Optionally, the power supply may be logically connected to the processor through a power management system, so as to implement functions of managing charging, discharging, power consumption management, and the like through the power management system.
The remote device in the embodiment of the present invention may be a computer or other devices that can send IP packets.
In the embodiment of the present invention, in order to distinguish a terminal device to which communication parameters are to be configured from a terminal device to which communication parameters have been configured in a network, the terminal device to which communication parameters are to be configured is hereinafter referred to as a first terminal device, and the terminal device to which communication parameters have been configured is referred to as a second terminal device.
As shown in fig. 3, an embodiment of the present invention provides a method for configuring communication parameters, which includes the following steps S101-S108.
S101, the remote equipment sends an IP message to the gateway.
Since it is usually necessary for the terminal device to communicate with other devices based on communication parameters (for example, at least one of an IP address of the terminal device, a gateway address of the terminal device, and a mask of the terminal device), in the embodiment of the present invention, in order to allow the first terminal device to communicate with other devices, after the first terminal device accesses the local network and connects to the gateway, a technician on the side of the first terminal device may notify a technician on the side of the remote device that the first terminal device has accessed the local network and connected to the gateway. Therefore, a technician at one side of the remote device can set the destination IP address of the IP message on the remote device, and after the technician sets the destination IP address of the completed IP message, the technician can trigger the remote device to send the IP message to the gateway. Under the condition that the terminal equipment is not configured with the IP address, a technician can set the target IP address of the IP message as the IP address pre-configured to the first terminal equipment; in the case where the terminal device has been configured with an IP address but not with a gateway address or a mask, and in the case where the terminal device has been configured with an IP address but not with a gateway address and a mask, a technician may set the destination IP address of the IP packet as the IP address with which the terminal device has been configured.
Optionally, the IP packet in the embodiment of the present invention may be a control packet protocol (ICMP) ping packet, or may be another IP packet. The specific configuration may be set according to actual situations, and the embodiment of the present invention is not limited.
S102, the gateway receives the IP message.
In this embodiment of the present invention, after the gateway receives the IP packet, the gateway obtains the destination IP address of the IP packet, and executes the following step S103.
S103, the gateway determines that the MAC address corresponding to the destination IP address of the IP message is not stored in the gateway.
In general, after the gateway stores the IP address of the terminal device that has communicated with the gateway and the corresponding relationship between the IP address of the terminal device and the MAC address of the terminal device in the gateway, after receiving the IP message, the gateway first determines whether the MAC address corresponding to the destination IP address of the IP message is stored in the gateway, and when the gateway determines that the MAC address corresponding to the destination IP address of the IP message is not stored in the gateway, the gateway sets the destination IP address of the IP message as the destination IP address carried in the first APR message, sets the IP address of the gateway as the source IP address carried in the first ARP message, and sends the first ARP message to all terminal devices connected to the gateway (i.e. all terminal devices in the subnet where the gateway is located) to obtain the MAC address corresponding to the destination IP address of the IP message, and after receiving the first ARP message by the terminal device in the subnet where the gateway is located, the terminal device with the same IP address as the destination IP address carried in the first ARP message replies a response message of the first ARP message including the MAC address of the terminal device to the gateway, so that the gateway can obtain the MAC address of the terminal device from the first ARP message after receiving the response message of the first ARP message, and thus the gateway can use the MAC address of the terminal device 1 as the MAC address corresponding to the destination IP address of the IP message, that is, the gateway can use the MAC address of the terminal device 1 as the MAC address corresponding to the IP address of the terminal device 1, and further the gateway can store the corresponding relationship between the IP address of the terminal device 1 and the MAC address of the terminal device 1.
In a possible application scenario of the embodiment of the present invention, under the condition that the first terminal device is not configured with an IP address, a technician located at one side of the remote device may set, on the remote device, a destination IP address of an IP packet as an IP address pre-configured to the first terminal device, where the destination IP address of the IP packet is different from an IP address of a terminal device configured with an IP address in a subnet where the gateway is located, so that no terminal device in all terminal devices connected to the gateway (i.e., all terminal devices in the subnet where the gateway is located) communicates with the gateway using the destination IP address of the IP packet (i.e., the IP address pre-configured to the first terminal device), and therefore, the gateway does not store an MAC address corresponding to the destination IP address of the IP packet. Therefore, after receiving the IP packet sent by the remote device, the gateway sets the destination IP address of the IP packet as the destination IP address carried by the first ARP packet, sets the IP address of the gateway as the source IP address carried by the first ARP packet, and sends the first ARP packet (i.e., executes the following S104) to obtain the MAC address corresponding to the destination IP address of the IP packet. Specifically, in this possible application scenario, the method for the gateway to obtain the MAC address corresponding to the destination IP address of the IP packet will be described in detail in S107 of the following embodiment.
In another possible application scenario of the embodiment of the present invention, in a case that the first terminal device has been configured with an IP address but is not configured with a gateway address or a mask, or in a case that the first terminal device has been configured with an IP address but is not configured with a gateway address or a mask, a technician on the side of the remote device may set the destination IP address of the IP packet as the IP address of the first terminal device on the remote device. In this way, since none of the terminal devices connected to the gateway (i.e., all terminal devices in the subnet where the gateway is located) uses the destination IP address of the IP packet (i.e., the IP address configured to the first terminal device) to communicate with the gateway, the gateway does not store the MAC address corresponding to the destination IP address of the IP packet. Therefore, after receiving the IP packet sent by the remote device, the gateway sets the destination IP address of the IP packet as the destination IP address carried by the first ARP packet, sets the IP address of the gateway as the source IP address carried by the first ARP packet, and sends the first ARP packet (i.e., executes the following S104) to obtain the MAC address corresponding to the destination IP address of the IP packet.
Further, in the another possible application scenario, the method for the gateway to obtain the MAC address corresponding to the destination IP address of the IP packet may be: when the first terminal device receives the first ARP message sent by the gateway device, the first terminal device determines that the IP address of the first terminal device is the same as the destination IP address carried in the first ARP message, at this time, the first terminal device may reply to the gateway a response message of the first ARP message including the MAC address of the first terminal device, so that the gateway can obtain the MAC address of the first terminal device from the first ARP message after receiving the response message of the first ARP message, so that the gateway can use the MAC address of the first terminal device as the MAC address corresponding to the destination IP address of the IP message, i.e. the gateway may treat the MAC address of the first terminal device as the MAC address corresponding to the IP address of the first terminal device, the gateway may further store a correspondence between the IP address of the first terminal device and the MAC address of the first terminal device.
S104, the gateway sends a first ARP message, and the first ARP message carries a source IP address and a destination IP address.
And the source IP address carried by the first ARP message is the IP address of the gateway, and the destination IP address carried by the first ARP message is the destination IP address of the IP message.
In this embodiment of the present invention, the first ARP packet may be a broadcast packet (that is, the MAC address carried by the first ARP packet is a broadcast address). Optionally, the first ARP packet may be an ARP request packet.
S105, the first terminal equipment receives the first ARP message.
In the embodiment of the present invention, since the first ARP packet is a broadcast packet, after the gateway sends the first ARP packet, all terminal devices in the subnet where the gateway is located may receive the first ARP packet. After the first terminal device receives the first ARP packet, the first terminal device may execute S106.
S106, the first terminal device determines whether the first terminal device is not configured with communication parameters.
In this embodiment of the present invention, in a case that the first terminal device determines that the first terminal device is not configured with the communication parameters, the first terminal device may perform the following S107; in the case where the first terminal device determines that the first terminal device has been configured with the communication parameters, the first terminal device may perform S108 described below.
S107, the first terminal equipment configures communication parameters for the first terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message.
In the embodiment of the present invention, the first terminal device may configure the communication parameter for the first terminal device according to at least one of the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet. That is, the first terminal device may configure communication parameters for the terminal device according to the source IP address carried in the first ARP packet; the first terminal device can also configure communication parameters for the first terminal device according to the destination IP address carried by the first APR message; the first terminal device may also configure communication parameters for the first terminal device according to the source IP address carried in the first ARP packet and the destination IP address carried in the first APR packet.
And S108, the first terminal equipment discards the first ARP message.
Optionally, in this embodiment of the present invention, when the communication parameter includes an IP address of the first terminal device, the step S107 may be implemented by the following step S107 a. When the communication parameter includes the gateway address of the first terminal device, S107 may be implemented by S107b described below. When the communication parameter includes a mask of the first terminal device, S107 described above may be implemented by S107c described below. When the communication parameters include the IP address of the first terminal device and the gateway address of the first terminal device, the above S107 may be implemented by the following S107a and S107 b. When the communication parameters include the IP address of the first terminal device and the mask of the first terminal device, the above S107 may be implemented by the following S107a and S107 c. When the communication parameters include the gateway address of the first terminal device and the mask of the first terminal device, the above S107 may be implemented by the following S107b and S107 c. When the communication parameters include the IP address of the first terminal device, the gateway address of the first terminal device, and the mask of the first terminal device, the above S107 may be implemented by the following S107a, S107b, and S107 c.
In the embodiment of the present invention, the first terminal device may configure an IP address of the first terminal device, a gateway address of the first terminal device, or a mask of the first terminal device (i.e., the first terminal device may perform S107a, S107b, or S107c described below). The first terminal device may also configure any two items of the IP address of the first terminal device, the gateway address of the first terminal device, and the mask of the first terminal device (i.e., the first terminal device may perform any two items of S107a, S107b, and S107c described below). The first terminal device may further configure an IP address of the first terminal device, a gateway address of the first terminal device, and a mask of the first terminal device (i.e., the first terminal device may perform S107a, S107b, and S107c described below); here, when the first terminal device performs S107a, S107b, and S107c described below, S107a may be performed first, and then S107b and S107c may be performed. The embodiment of the present invention may not limit the execution sequence of S107b and S107c, that is, in the embodiment of the present invention, S107b may be executed first and then S107c may be executed first, S107c may be executed first and then S107b may be executed, and S107b and S107c may be executed simultaneously.
It should be noted that, in the embodiment of the present invention, in a case that the first terminal device is not configured with an IP address, after the first terminal device receives the first ARP packet, if the first terminal device determines that the first terminal device is not configured with an IP address, the first terminal device may directly execute the following S107a, or the first terminal device may execute the following S107a after determining that the destination IP address carried in the first ARP packet is a valid IP address (that is, the destination IP address carried in the first ARP packet is not occupied by other terminal devices in the subnet where the first terminal device is located).
In the embodiment of the present invention, in the case that the first terminal device has been configured with the IP address but is not configured with the gateway address or the mask, the first terminal device may directly perform S107b or S107 c. In the case where the first terminal device has been configured with the IP address but is not configured with the gateway address and the mask, the first terminal device may directly perform S107b and S107 c.
S107a, the first terminal device configures the destination IP address carried in the first ARP packet as the IP address of the first terminal device.
The valid IP address may be understood as an IP address that is not occupied by other terminal devices in the subnet where the first terminal device is located (terminal devices other than the first terminal device in the subnet where the first terminal device is located).
In the embodiment of the present invention, after the first terminal device configures the destination IP address carried in the first ARP packet as the IP address of the first terminal device, the first terminal device may reply a response packet of the first ARP packet including the MAC address of the first terminal device to the gateway, so that the gateway may obtain the MAC address of the first terminal device from the first ARP packet after receiving the response packet of the first ARP packet, and thus the gateway may use the MAC address of the first terminal device as the MAC address corresponding to the destination IP address of the IP packet, that is, the gateway may use the MAC address of the first terminal device as the MAC address corresponding to the IP address of the first terminal device, and further the gateway may store a corresponding relationship between the IP address of the first terminal device and the MAC address of the first terminal device.
S107b, the first terminal device configures the source IP address carried in the first ARP packet as a gateway address of the first terminal device.
S107c, the first terminal device calculates a source IP address carried in the first ARP packet and a destination IP address carried in the first ARP packet, and configures a mask for the first terminal device according to a result of the calculation.
Optionally, in this embodiment of the present invention, the step S107c may be implemented by the following steps (1) and (2):
(1) and the first terminal equipment calculates the source IP address carried by the first ARP message and the target IP address carried by the first ARP message, and determines the reverse mask of the mask according to the calculation result.
(2) And the first terminal equipment performs bitwise negation on the inverse mask, and configures the result of bitwise negation as the mask of the first terminal equipment.
Optionally, in the embodiment of the present invention, in the step (1), the first terminal device may perform an operation on the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet by using a bitwise xor operation starting from the highest bit.
Exemplarily, in the embodiment of the present invention, the above (1) may be implemented by the following (1a) and (1 b):
(1a) the first terminal equipment starts bitwise XOR operation on a source IP address carried by a first ARP message and a destination IP address carried by the first ARP message from the highest bit, and stops bitwise XOR operation on the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message under the condition that the result of the bitwise XOR operation on the mth bit of the source IP address carried by the first ARP message and the mth bit of the destination IP address carried by the first ARP message by the first terminal equipment is 1, and the first terminal equipment generates an n-bit first string code.
Wherein m is an integer greater than zero, n is the same as the number of bits of the source IP address carried by the first ARP message and the number of bits of the destination IP address carried by the first ARP message, the values of the high m-1 bits of the n-bit first serial codes are all 0, the values of the low n-m +1 bits of the n-bit first serial codes are all 1, and n > m.
(1b) Under the condition that the number of 1 in the n-bit first string is greater than 1, the first terminal equipment determines the n-bit first string as a mask code; and under the condition that the number of 1 in the n-bit first string code is equal to 1, the first terminal equipment determines a preset n-bit second string code as an inverse mask of the mask.
For example, assuming that the number of bits of the source IP address carried in the first ARP packet and the number of bits of the destination IP address carried in the first ARP packet are both 32 bits, the first terminal device starts bitwise xor operation on the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet from the highest bit (the 31 th bit is the highest bit, and the 0 th bit is the lowest bit). And under the condition that the m-th bit of the source IP address carried by the first ARP message and the m-th bit of the destination IP address carried by the first ARP message are subjected to exclusive OR operation by the first terminal equipment to obtain a result of 1, stopping carrying out the exclusive OR operation on the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message by the first terminal equipment according to the bits, and generating a 32-bit first serial code. Wherein, the high m-1 bits of the 32-bit first string are all 0, and the low 32-m +1 bits of the 32-bit first string are all 1. For example, assuming that m is 29, the values of the high 28 (i.e. 29-1) bits of the 32-bit first string code generated by the first terminal device are all 0, and the values of the low 4 (i.e. 32-29+1) bits of the 32-bit first string code are all 1, i.e. the 32-bit first string code can be expressed as: 00000000.00000000.00000000.00001111 (referred to as string 1). Assuming that m is 32, the values of the upper 31 (i.e. 32-1) bits of the 32-bit first string generated by the first terminal device are all 0, and the values of the lower 1 (i.e. 32-32+1) bits of the 32-bit first string are all 1, i.e. the 32-bit first string can be expressed as: 00000000.00000000.00000000.00000001 (referred to as string 2).
Since the IP address is 32 bits in general, the predetermined n-bit second string code may be a 32-bit string code. The specific number of bits of the preset second serial code may be the same as the number of bits of the source IP address carried in the first ARP message and the number of bits of the destination IP address carried in the first ARP message. And since the lower two bits of the inverse mask are both 1 in the normal case, the preset n-bit second string code can be expressed as: 00000000.00000000.00000000.00000011.
illustratively, in the case where the 32-bit first string is string 1 described above, the first terminal device determines string 1 described above as an inverse mask of the mask. In the case where the 32-bit first string is string 2 described above, since string 2 does not comply with the rule of anti-masking, the first terminal device may determine a preset 32-bit second string (e.g., 00000000.00000000.00000000.00000011) as the anti-masking of the mask.
After the first terminal device determines the inverse mask of the mask, the first terminal device may perform bitwise not operation on the inverse mask, and configure a result of the bitwise not operation as the mask of the first terminal device.
For example: assuming that the above-determined inverse mask is expressed as: 00000000.00000000.00000000.00000011 (0.0.0.3 when expressed as a decimal number), the result of the bitwise negation of the inverse mask by the first terminal device may be expressed as: 11111111.11111111.11111111.11111100 (255.255.255.252 when expressed as a decimal number), i.e. the first terminal device may configure 11111111.11111111.11111111.11111100 as a mask for the first terminal device.
Optionally, in this embodiment of the present invention, after the first terminal device configures the communication parameter for the first terminal device according to at least one of the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet, the first terminal device may communicate with other devices based on the communication parameter.
According to the method for configuring the communication parameters provided by the embodiment of the invention, when the terminal equipment is not configured with the communication parameters, the terminal equipment can configure the communication parameters for the terminal equipment according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message. Therefore, when the method for configuring the communication parameters provided by the embodiment of the invention is adopted to configure the communication parameters for the terminal equipment, the terminal equipment and the network equipment do not need to support DHCP, so that the realization cost of the terminal equipment and the network equipment can be saved while the communication parameters are configured for the terminal equipment.
Optionally, in this embodiment of the present invention, the communication parameter may include at least one of an IP address of the first terminal device, a gateway address of the first terminal device, and a mask of the first terminal device.
In this embodiment of the present invention, in a case that the first terminal device is not configured with an IP address, the communication parameter may include the IP address of the first terminal device. That is, in the case of configuring the IP address for the first terminal device, as shown in fig. 4, the following S109 is further included after S106 and before S107 shown in fig. 3, as shown in fig. 3, and at this time S106 shown in fig. 3 may be replaced with S106a, and S107 may be replaced with S107 a.
S106, the first terminal device determines whether the first terminal device is not configured with the IP address.
S109, the first terminal device determines whether the destination IP address carried by the first ARP message is an effective IP address.
In the embodiment of the present invention, although a technician at a side of a remote device sets a destination IP address of an IP packet as an IP address preconfigured to a first terminal device on the remote device when the first terminal device is not configured with an IP address, and the destination IP address of the IP packet is different from IP addresses of terminal devices configured with IP addresses in a subnet where a gateway is located, since the first terminal device cannot know whether the IP address preconfigured to the first terminal device is already occupied by other terminal devices in the subnet where the first terminal device is located, after the first terminal device receives a first ARP packet sent by the gateway and determines that the first terminal device is not configured with an IP address, it may be determined whether the destination IP address carried by the first ARP packet (i.e. the IP address preconfigured to the first terminal device or the destination IP address of the IP packet) is a valid IP address, that is, whether the destination IP address carried in the first ARP packet is already occupied by other terminal devices in the subnet where the first terminal device is located (for example, after the first terminal device receives the first ARP packet sent by the gateway and determines that the first terminal device is not configured with an IP address, the foregoing S109 may be executed).
In this embodiment of the present invention, after the first terminal device executes the step S109, if the first terminal device determines that the destination IP address carried in the first ARP packet is an effective IP address, the first terminal device may execute the step S107 a. If the first terminal device determines that the destination IP address carried in the first ARP packet is not the valid IP address, the first terminal device may discard the first ARP packet, that is, the first terminal device may execute the foregoing S108.
Optionally, in the embodiment of the present invention, with reference to fig. 4, as shown in fig. 5, S109 shown in fig. 4 may be replaced with S109a-S109 g.
S109a, the first terminal equipment sends a second ARP message.
In this embodiment of the present invention, the second ARP packet may be a broadcast packet (that is, the MAC address carried by the second ARP packet is a broadcast address). Optionally, the second ARP packet may be a gratuitous ARP request packet.
And the source IP address carried by the second ARP message and the destination IP address carried by the second ARP message are the same as the destination IP address carried by the first ARP message. After the first terminal device sends the second ARP packet, if the first terminal device does not receive the response packet of the second ARP packet within the preset time, the first terminal device may determine that the destination IP address carried in the first ARP packet is an effective IP address after the preset time (that is, the destination IP address carried in the first ARP packet is not occupied by other terminal devices in the subnet where the first terminal device is located); if the first terminal device receives the response packet of the second ARP packet within the preset time, the first terminal device may determine that the destination IP address carried in the first ARP packet is not the valid IP address (that is, the destination IP address carried in the first ARP packet is already occupied by the second terminal device). And the source IP address of the response message of the second ARP message and the destination IP address of the response message of the second ARP message are the same as the source IP address carried by the second ARP message.
S109b, the second terminal device receives the second ARP packet.
In the embodiment of the present invention, since the second APR message is a broadcast message, after the first terminal device sends the second ARP message, terminal devices around the first terminal device may all receive the second ARP message.
The embodiment of the present invention is described by taking, as an example, one terminal device, for example, a second terminal device, among terminal devices around a first terminal device.
S109c, the second terminal device determines whether the source IP address carried in the second ARP packet is the same as the IP address of the second terminal device.
In this embodiment of the present invention, when the second terminal device determines that the source IP address carried in the second ARP packet is different from the IP address of the second terminal device, the second terminal device may execute the following S109 d; in a case where the second terminal device determines that the source IP address carried in the second ARP packet is the same as the IP address of the second terminal device, the second terminal device may perform S109f described below.
S109d, the second terminal device discards the second ARP packet.
In the embodiment of the present invention, after the second terminal device discards the second ARP packet, the second terminal device does not send a response packet of the second ARP packet, and thus the first terminal device does not receive the response packet of the second ARP packet sent by the second terminal device, so that the first terminal device can wait for a preset time after sending the second ARP packet, and if the first terminal device does not receive the response packet of the second ARP packet within the preset time, the first terminal device determines that the destination IP address carried by the first ARP packet is an effective IP address. That is, the first terminal apparatus may perform S109e described below after sending the second ARP packet.
In the embodiment of the present invention, the preset time may be a preset time period (for example, may be set to 1 second). Specifically, the preset time may be set according to actual use requirements, and the embodiment of the present invention is not limited.
S109e, if the first terminal device does not receive the response packet of the second ARP packet within the preset time, the first terminal device determines that the destination IP address carried in the first ARP packet is an effective IP address.
And S109f, the second terminal equipment sends a response message of the second ARP message.
In the embodiment of the present invention, the response packet of the second ARP packet is a broadcast packet (that is, the MAC address of the response packet of the second ARP packet is a broadcast address). Optionally, the response message of the second ARP message may be a gratuitous ARP request message.
S109g, the first terminal device receives the response packet of the second ARP packet, and the first terminal device determines that the destination IP address carried in the first ARP packet is not an effective IP address.
In the embodiment of the present invention, after the first terminal device receives the response packet of the second ARP packet, the first terminal device may determine that the destination IP address carried in the first ARP packet is occupied by the second terminal device, that is, the first terminal device may determine that the destination IP address carried in the first ARP packet is not an effective IP address.
It should be noted that, in the embodiment of the present invention, after the first terminal device sends the second APR message, the first terminal device may execute S109e or S109 g. In order to distinguish the two different cases where the first terminal device performs S109e and S109g, S109e is indicated with a dashed box in fig. 5.
In order to better understand the implementation manner of the embodiment of the present invention, an application scenario of the embodiment of the present invention is described as an example below.
For example, the method for configuring communication parameters provided by the embodiment of the present invention may be applied to the following scenario one and scenario two.
Scene one: when the IP network fails, a terminal device (e.g., the first terminal device in the above-described embodiment) is used to locate the network failure.
In a scenario one, the terminal device may be a probe device, and before the probe device is used to locate a network fault, the communication parameters may be configured for the probe device by using the method for configuring communication parameters provided in the embodiment of the present invention. After the communication parameters are configured for the probe device, the test device (for example, a network tester or a dedicated probe packet sending device) may send a test message to the probe device, and after the probe device receives the test message, the test message may be sent back to the test device.
In the first scenario, in the case that the communication parameter is configured for the probe device by using the method for configuring a communication parameter provided by the embodiment of the present invention, the probe device may not need to support DHCP, so that the hardware and software costs of the probe device are reduced, and network devices (e.g., a server and a relay device) that support DHCP are also not needed, so that the cost of the network devices is also reduced.
Further, in the first scenario, when the method for configuring communication parameters provided by the embodiment of the present invention is used to configure communication parameters for a probe device, a technician located at a side of a remote device only needs to send an IP packet with a destination IP address pre-configured to the probe device on the remote device, so as to configure communication parameters for the probe device.
And in a second scenario, the terminal device (for example, the first terminal device in the above embodiment) collects data, and sends the collected data to the background server for processing (for example, in the vegetable greenhouse, the terminal device with the sensor function collects the temperature and humidity in the vegetable greenhouse, and sends the temperature and humidity in the vegetable greenhouse to the background server, so that the background server can adjust the temperature and humidity in the vegetable greenhouse in time).
In the second scenario, if there are multiple terminal devices collecting data, the method for configuring communication parameters provided in the embodiment of the present invention may be used to sequentially configure communication parameters for each terminal device in the multiple terminal devices, so that each terminal device can send the collected data to the background server for processing and analysis. Furthermore, when the communication parameters are configured for the plurality of terminal devices, a technician at one side of the remote device can sequentially send a plurality of IP messages with the target IP addresses pre-configured to the terminal devices on the remote device to sequentially configure the parameters for the plurality of terminal devices, so that the personnel cost and the device cost can be reduced.
In the embodiment of the present invention, a terminal device (for example, the first terminal device in the above embodiment) may be divided into functional modules according to the above method embodiment, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. It should be noted that, the division of the modules in the embodiment of the present invention is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
Exemplarily, in a case that each function module is divided according to each function, a schematic structural diagram of a terminal device provided in an embodiment of the present invention is shown in fig. 6, and in fig. 6, the first terminal device includes: a receiving module 21, a determining module 22 and a configuring module 23. Wherein, the receiving module 21 is configured to support the terminal device to execute S105 executed by the first terminal device in the foregoing method embodiment; the determining module 22 is configured to support the terminal device to perform S106 and S109 performed by the first terminal device in the foregoing method embodiment (specifically, may support the terminal device to perform S109a, S109e, and S109g performed by the first terminal device in the foregoing method embodiment); the configuration module 23 is configured to support the terminal device to perform S107 (specifically, may support the terminal device to perform at least one of S107a, S107b, and S107c) performed by the first terminal device in the above method embodiment.
The receiving module 21, determining module 22, and configuring module 23 described above may also be used to perform other processes for the techniques described herein.
In this embodiment of the present invention, the terminal device may further include a functional module for executing other processes in the foregoing method embodiment, for example, the terminal device may further include a functional module for executing S108 executed by the first terminal device in the foregoing method embodiment.
It should be noted that all relevant contents of each step related to the above method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again.
Exemplarily, in the case of using an integrated unit, a schematic structural diagram of a terminal device provided by an embodiment of the present invention is shown in fig. 7, and in fig. 7, the terminal device includes a processing module 31, a communication module 32, and a storage module 33. The processing module 31 is used for controlling and managing the actions of the terminal device, for example, performing the steps performed by the above-described determining module 22 and configuring module 23, and/or other processes for performing the techniques described herein. The communication module 32 is used for supporting the interaction between the terminal device and other devices, for example, for executing the steps executed by the receiving module 21, and the storage module 33 is used for storing the program codes and data of the terminal device.
The processing module 31 may be a processor or a controller in a terminal device, and the processor or the controller may be the processor 11 in the probe device shown in fig. 2, and the processor or the controller may implement or execute various exemplary logic blocks, modules and circuits described in connection with the disclosure of the present invention. The processor or controller may be a Central Processing Unit (CPU), a general purpose processor, a Digital Signal Processor (DSP), an application-specific integrated circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, transistor logic, hardware components, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs, and microprocessors, among others.
The communication module 12 may be a transceiver, a transceiver circuit or a communication interface, etc. in the terminal device, and the transceiver, the transceiver circuit or the communication interface, etc. may be the transceiver in the probe device as shown in fig. 2.
The storage module 33 may be a memory or the like in the terminal device. The memory may be the memory 14 in the probe device described above and shown in FIG. 2, which may include volatile memory (volatile memory), such as random-access memory (RAM); the memory may also include a non-volatile memory (non-volatile memory), such as a read-only memory (ROM), a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD); the memory may also comprise a combination of memories of the kind described above.
The terminal device may further include a bus, and the bus may be divided into an address bus, a data bus, a control bus, and the like.
An embodiment of the present invention further provides a computer-readable storage medium, where one or more programs are stored in the computer-readable storage medium, where the one or more programs include computer-executable instructions, and when a processor or a controller in the terminal device executes the computer-executable instructions, the terminal device executes each step performed by the first terminal device in the method flow shown in the foregoing method embodiment.
Through the above description of the embodiments, it is clear to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions. For the specific working processes of the system, the apparatus and the unit described above, reference may be made to the corresponding processes in the foregoing method embodiments, and details are not described here again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: flash memory, removable hard drive, read only memory, random access memory, magnetic or optical disk, and the like.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (12)

1. A method for configuring communication parameters, comprising:
the method comprises the steps that terminal equipment receives a first Address Resolution Protocol (ARP) message, wherein the first ARP message carries a source Internet Protocol (IP) address and a destination IP address;
the terminal device determines that the terminal device is not configured with communication parameters;
after determining that the terminal equipment is not configured with the communication parameters, the terminal equipment configures the communication parameters for the terminal equipment according to at least one of a source IP address carried by the first ARP message and a destination IP address carried by the first ARP message;
the communication parameters comprise an IP address of the terminal equipment and a gateway address of the terminal equipment; or
The communication parameters comprise an IP address of the terminal equipment and a mask of the terminal equipment;
if the communication parameters at least comprise the gateway address of the terminal equipment;
the terminal device configures the communication parameters for the terminal device according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, including:
the terminal equipment configures a source IP address carried by the first ARP message as a gateway address of the terminal equipment;
if the communication parameters at least comprise the mask of the terminal equipment;
the terminal device configures the communication parameters for the terminal device according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, including:
and the terminal equipment calculates the source IP address carried by the first ARP message and the target IP address carried by the first ARP message, and configures a mask for the terminal equipment according to the calculation result.
2. The method of claim 1, wherein the communication parameters include at least an IP address of the terminal device;
before the terminal device configures the communication parameters for the terminal device according to at least one of the source IP address carried by the first ARP packet and the destination IP address carried by the first ARP packet, the method further includes:
the terminal equipment determines that a target IP address carried by the first ARP message is an effective IP address;
the terminal device configures the communication parameters for the terminal device according to at least one of the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message, including:
and after determining that the destination IP address carried by the first ARP message is an effective IP address, the terminal equipment configures the destination IP address carried by the first ARP message as the IP address of the terminal equipment.
3. The method according to claim 2, wherein the determining, by the terminal device, that the destination IP address carried in the first ARP packet is an effective IP address includes:
the terminal equipment sends a second ARP message, and a source IP address carried by the second ARP message and a target IP address carried by the second ARP message are both the same as a target IP address carried by the first ARP message;
after the terminal equipment sends the second ARP message, if the terminal equipment does not receive a response message of the second ARP message within preset time, the terminal equipment determines that a target IP address carried by the first ARP message is an effective IP address, and a source IP address carried by the response message and the target IP address carried by the response message are the same as a source IP address carried by the second ARP message.
4. The method according to claim 1, wherein the terminal device performs an operation on the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet, and configures a mask for the terminal device according to a result of the operation, including:
the terminal equipment calculates a source IP address carried by the first ARP message and a target IP address carried by the first ARP message, and determines a reverse mask of the mask according to a calculation result;
and the terminal equipment performs bitwise NOT operation on the inverse mask, and configures the result of the bitwise NOT operation as the mask of the terminal equipment.
5. The method according to claim 4, wherein the terminal device performs an operation on the source IP address carried in the first ARP packet and the destination IP address carried in the first ARP packet, and determines the anti-mask of the mask according to an operation result, including:
the terminal equipment starts bitwise XOR operation on the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message from the highest position;
under the condition that the m-th bit of the source IP address carried by the first ARP message and the m-th bit of the destination IP address carried by the first ARP message are subjected to exclusive OR operation by the terminal equipment to obtain a result of 1, stopping performing the exclusive OR operation on the source IP address carried by the first ARP message and the destination IP address carried by the first ARP message by the terminal equipment according to the bits, wherein m is an integer larger than zero;
the terminal equipment generates n first serial codes, wherein n is the same as the bit number of a source IP address carried by the first ARP message and the bit number of a target IP address carried by the first ARP message, the high m-1 bit values of the n first serial codes are all 0, the low n-m +1 bit values of the n first serial codes are all 1, and n is larger than m;
in case the number of 1's in the n-bit first string is greater than 1, the terminal device determines the n-bit first string as an inverse mask of the mask,
or;
and under the condition that the number of 1 s in the n-bit first string codes is equal to 1, the terminal equipment determines a preset n-bit second string code as a reverse mask of the mask.
6. A terminal device, comprising: the device comprises a receiving module, a determining module and a configuration module;
the receiving module is used for receiving a first Address Resolution Protocol (ARP) message, and the first ARP message carries a source Internet Protocol (IP) address and a destination IP address;
the determining module is used for determining that the terminal equipment is not configured with communication parameters;
the configuration module is configured to configure the communication parameter for the terminal device according to at least one of a source IP address carried by the first ARP packet and a destination IP address carried by the first ARP packet received by the receiving module after the determining module determines that the terminal device is not configured with the communication parameter;
the communication parameters comprise an IP address of the terminal equipment and a gateway address of the terminal equipment; or
The communication parameters comprise an IP address of the terminal equipment and a mask of the terminal equipment;
if the communication parameter at least includes the gateway address of the terminal device, the configuration module is specifically further configured to configure the source IP address carried by the first ARP packet received by the receiving module as the gateway address of the terminal device;
if the communication parameter at least includes the mask of the terminal device, the configuration module is specifically further configured to perform an operation on the source IP address carried by the first ARP packet received by the receiving module and the destination IP address carried by the first ARP packet, and configure the mask for the terminal device according to an operation result.
7. The terminal device of claim 6, wherein the communication parameters include at least an IP address of the terminal device;
the determining module is further configured to determine that the destination IP address carried by the first ARP packet received by the receiving module is an effective IP address before the configuration module configures the communication parameter for the terminal device according to at least one of the source IP address carried by the first ARP packet and the destination IP address carried by the first ARP packet;
the configuration module is specifically configured to configure the destination IP address carried by the first ARP packet received by the receiving module as the IP address of the terminal device after the determining module determines that the destination IP address carried by the first ARP packet is an effective IP address.
8. The terminal device of claim 7,
the determining module is specifically configured to send a second ARP packet, and after sending the second ARP packet, if a response packet of the second ARP packet is not received within a preset time, determine that a destination IP address carried by the first ARP packet received by the receiving module is an effective IP address, where a source IP address carried by the second ARP packet and a destination IP address carried by the second ARP packet are both the same as a destination IP address carried by the first ARP packet, and a source IP address of the response packet and a destination IP address of the response packet are the same as a source IP address carried by the second ARP packet.
9. The terminal device of claim 6,
the configuration module is specifically configured to perform an operation on a source IP address carried by the first ARP packet received by the receiving module and a destination IP address carried by the first ARP packet, and determine an inverse mask of the mask according to an operation result; and bitwise negating the inverse mask, and configuring the result of bitwise negating as a mask of the terminal equipment.
10. The terminal device of claim 9,
the configuration module is specifically configured to perform bitwise exclusive or operation on the source IP address carried by the first ARP packet received by the receiving module and the destination IP address carried by the first ARP packet from a highest bit; under the condition that the m-th bit of the source IP address carried by the first ARP message and the m-th bit of the target IP address carried by the first ARP message are subjected to exclusive OR operation, the m-th bit of the source IP address carried by the first ARP message and the m-th bit of the target IP address carried by the first ARP message are subjected to exclusive OR operation according to bits; generating n first serial codes, wherein n is the same as the number of bits of a source IP address carried by the first ARP message and the number of bits of a destination IP address carried by the first ARP message, the values of m-1 bits higher than the n first serial codes are both 0, and the values of n-m +1 bits lower than the n first serial codes are both 1; and determining the n-bit first string as an inverse mask of the mask if the number of 1's in the n-bit first string is greater than 1, or determining a preset n-bit second string as an inverse mask of the mask if the number of 1's in the n-bit first string is equal to 1; m is an integer greater than zero, n > m.
11. A terminal device, comprising: a processor, a transceiver, and a memory;
the memory is used for storing computer-executable instructions, and when the terminal device runs, the processor executes the computer-executable instructions stored in the memory, so that the terminal device executes the method for configuring communication parameters according to any one of claims 1 to 5.
12. A communication system, comprising: a gateway, a remote device, and a terminal device according to any one of claims 6 to 10 or claim 11, the terminal device and the remote device being connected to the gateway.
CN201611248651.8A 2016-12-29 2016-12-29 Method, device and system for configuring communication parameters Active CN106713525B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611248651.8A CN106713525B (en) 2016-12-29 2016-12-29 Method, device and system for configuring communication parameters

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611248651.8A CN106713525B (en) 2016-12-29 2016-12-29 Method, device and system for configuring communication parameters

Publications (2)

Publication Number Publication Date
CN106713525A CN106713525A (en) 2017-05-24
CN106713525B true CN106713525B (en) 2021-01-29

Family

ID=58903986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611248651.8A Active CN106713525B (en) 2016-12-29 2016-12-29 Method, device and system for configuring communication parameters

Country Status (1)

Country Link
CN (1) CN106713525B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111935332A (en) * 2020-08-11 2020-11-13 杭州锐格思科技有限公司 Configuration method for managing IP address of switch
CN112929241B (en) * 2021-03-26 2022-06-21 新华三信息安全技术有限公司 Network testing method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1457025A2 (en) * 2001-12-20 2004-09-15 Sierra Wireless, Inc. Architecture for emulating an ethernet network interface card
CN101500023A (en) * 2008-02-03 2009-08-05 北京艾德斯科技有限公司 Automatic configuration method for network appliance IP address
CN101552805A (en) * 2009-05-04 2009-10-07 福州星网视易信息系统有限公司 IP address automatical allocation method of household network player
CN101656763A (en) * 2009-09-11 2010-02-24 华为技术有限公司 IP address automatic distribution method, client and server
CN102158565A (en) * 2011-04-07 2011-08-17 瑞斯康达科技发展股份有限公司 Method and system for configuring Internet protocol (IP) address for remote device
CN104618520A (en) * 2013-11-04 2015-05-13 华为技术有限公司 IP (Internet Protocol) address configuration method, equipment and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1457025A2 (en) * 2001-12-20 2004-09-15 Sierra Wireless, Inc. Architecture for emulating an ethernet network interface card
CN101500023A (en) * 2008-02-03 2009-08-05 北京艾德斯科技有限公司 Automatic configuration method for network appliance IP address
CN101552805A (en) * 2009-05-04 2009-10-07 福州星网视易信息系统有限公司 IP address automatical allocation method of household network player
CN101656763A (en) * 2009-09-11 2010-02-24 华为技术有限公司 IP address automatic distribution method, client and server
CN102158565A (en) * 2011-04-07 2011-08-17 瑞斯康达科技发展股份有限公司 Method and system for configuring Internet protocol (IP) address for remote device
CN104618520A (en) * 2013-11-04 2015-05-13 华为技术有限公司 IP (Internet Protocol) address configuration method, equipment and system

Also Published As

Publication number Publication date
CN106713525A (en) 2017-05-24

Similar Documents

Publication Publication Date Title
CN107070691B (en) Cross-host communication method and system of Docker container
CN110401568B (en) Network topology discovery method and equipment
CN102056152B (en) Implementation method of automatic configuration for network addresses of wireless sensors based on Internet protocol version 6 over low power wireless personal area network (6LoWPAN)
CN107360184B (en) Terminal equipment authentication method and device
CN106921578B (en) Method and device for generating forwarding table item
US20130332586A1 (en) Providing ipv6 connectivity through shared external interfaces on electronic devices
CN106507414B (en) Message forwarding method and device
CN106713525B (en) Method, device and system for configuring communication parameters
WO2017157318A1 (en) Link discovery method and apparatus
CN107465621B (en) Router discovery method, SDN controller, router and network system
US9832066B2 (en) Port number extension method and switch
US11902380B1 (en) Liveness detection for an authenticated client session
CN107249038A (en) Business datum retransmission method and system
WO2012021827A1 (en) Systems and methods for managing network address information
CN112165483B (en) ARP attack defense method, device, equipment and storage medium
EP3745660A1 (en) Multicast processing for neighbor discovery proxy devices using hardware filtering
Varis Anatomy of a linux bridge
US9025494B1 (en) IPv6 network device discovery
CN115695374A (en) IPv6 subnet prefix advertisement implementation method, device, equipment and storage medium
US10057210B2 (en) Transaction-based network layer address rotation
Dessouky et al. A hardware approach for detecting the ARP attack
CN114465750A (en) Network topology confusion virtual path creating method, device, terminal and system
KR101303030B1 (en) Method for operating and searching host in internet protocol version 6 network
CN111092777B (en) Method and device for learning forwarding table item
WO2024001549A1 (en) Address configuration method and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant