WO2018053799A1 - 一种识别网口类型的方法、装置及存储介质 - Google Patents

一种识别网口类型的方法、装置及存储介质 Download PDF

Info

Publication number
WO2018053799A1
WO2018053799A1 PCT/CN2016/099856 CN2016099856W WO2018053799A1 WO 2018053799 A1 WO2018053799 A1 WO 2018053799A1 CN 2016099856 W CN2016099856 W CN 2016099856W WO 2018053799 A1 WO2018053799 A1 WO 2018053799A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
network port
type
mode
determining
Prior art date
Application number
PCT/CN2016/099856
Other languages
English (en)
French (fr)
Inventor
高飞
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Priority to EP16916538.8A priority Critical patent/EP3518464A4/en
Priority to PCT/CN2016/099856 priority patent/WO2018053799A1/zh
Publication of WO2018053799A1 publication Critical patent/WO2018053799A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • H04L41/0816Configuration setting characterised by the conditions triggering a change of settings the condition being an adaptation, e.g. in response to network events
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/30Definitions, standards or architectural aspects of layered protocol stacks
    • H04L69/32Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e.g. the interfaces between the data link level and the physical level
    • H04L69/322Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions
    • H04L69/329Intralayer communication protocols among peer entities or protocol data unit [PDU] definitions in the application layer [OSI layer 7]

Definitions

  • the present invention relates to the field of communications, and in particular, to a method, an apparatus, and a storage medium for identifying a type of a network port.
  • the traditional home gateway product is connected to a specific device through a network cable in a specific mode, that is, a network cable is inserted into a compatible local area network (LAN) network port and a wide area network.
  • LAN local area network
  • WAN Wide Area Network
  • CPE Customer Premises Equipment
  • the network port can only be a LAN port or a WAN port. That is, the device can only be in gateway mode or broadband mode.
  • the network port is a LAN network port.
  • the device is a server end, and is connected to a client (such as a computer);
  • a client such as a computer
  • the network port is a WAN network port.
  • the device is a client end and is connected to the fixed network.
  • embodiments of the present invention are directed to providing a method and apparatus for identifying a type of network port. At least the problems existing in the prior art are solved, and automatic identification of the LAN network port and the WAN network port can be realized.
  • a method for identifying a network port type is applied to a first device having a compatible LAN network port and a WAN network port, the method comprising: the first device receiving an access signal of a second device connected to itself And obtaining a message of the interaction between the device and the second device; determining a message type of the interaction message; determining a type of the network port according to the message type; wherein the network port type includes: a LAN network port and a WAN Network port.
  • the determining the message type of the interaction message includes: determining a message type of the interaction message sent by the second device.
  • the determining the type of the network port according to the message type includes:
  • the message mode is the requesting IP mode, determining that the type of the network port is a LAN network port;
  • the type of the network port is determined to be a WAN network port.
  • the determining the type of the network port according to the message type further includes: when the message type is a dynamic host configuration protocol DHCP request message, determining that the message mode of the message is a requesting IP mode.
  • the type of the network port is determined to be a LAN network port, and the first device is configured as a server end.
  • the determining the type of the network port according to the message type further includes: when the message type is a DHCP response message, determining that the message mode of the message is an allocation IP mode; correspondingly, The type of the network port is determined to be a WAN network port, and the first device is configured as a DHCP client.
  • determining the type of the network port according to the message type further includes: determining, when the message type is an Ethernet Point-to-Point Protocol (PPPOE) response message,
  • the message mode is an IP mode; correspondingly, the type of the network port is determined to be a WAN network port, and the first device is configured as a PPPOE client.
  • PPOE Point-to-Point Protocol
  • the method further includes: the first device periodically sends a DHCP request message and a PPPOE request message to the network card corresponding to the network port.
  • the method further includes: when the determined network port type is different from the current configuration type of the network port, switching the type of the network port of the first device to the determined Network port type.
  • An apparatus for identifying a network port type comprising: an obtaining module, a determining module, and an identifying module, wherein
  • the acquiring module is configured to acquire an interaction message with the access device after receiving an access signal of the access device;
  • the determining module is configured to determine a message type of the interactive message
  • the identification module is configured to determine the type of the network port according to the message type.
  • the network port type includes: a LAN network port and a WAN network port.
  • the determining module is specifically configured to determine a message type of an interaction message from the access device.
  • the identification module is specifically configured to:
  • the message mode is the requesting IP mode, determining that the type of the network port is a LAN network port;
  • the type of the network port is determined to be a WAN network port.
  • the identifying module is further configured to: when the message type is a dynamic host configuration protocol DHCP request message, determine that the message mode of the message is a request IP mode; and correspondingly, determine the network port
  • the type is a LAN network port, and the first device is configured as a server.
  • the identification module is further configured to: when the message type is DHCP ringing When the message is received, the message mode of the message is determined to be an IP mode.
  • the type of the network port is determined to be a WAN network port, and the device is configured as a DHCP client.
  • the identifying module is further configured to: when the message type is an Ethernet peer-to-peer protocol PPPOE response message, determine that the message mode of the message is an assigned IP mode; and correspondingly, determine the network port
  • the type is a WAN network port, and the device is configured as a PPPOE client.
  • the device further includes: a sending module, configured to: the first device periodically sends a DHCP request message and a PPPOE request message to the network card corresponding to the network port.
  • the device further includes: a switching module, configured to switch the type of the network port of the device to the device when the determined network port type is different from the current configuration of the network port Determine the type of network port.
  • a switching module configured to switch the type of the network port of the device to the device when the determined network port type is different from the current configuration of the network port Determine the type of network port.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores a computer program for performing the above method for identifying a network port type according to an embodiment of the present invention.
  • the method, device, and storage medium for identifying a network port type in the embodiment of the present invention after receiving the access signal of the second device connected to the first device, the first device acquires an interaction message of the second device;
  • the message type of the interaction message is determined according to the type of the message; wherein the network port type includes: a LAN network port and a WAN network port.
  • the embodiment of the present invention solves at least the problems existing in the prior art, and can automatically recognize the LAN network port and the WAN network port, thereby improving the user experience.
  • FIG. 1 is a schematic flowchart of a method for identifying a network port type according to Embodiment 1 of the present invention
  • FIG. 2 is a schematic flowchart of a method for identifying a network port type according to Embodiment 2 of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for identifying a network port type according to Embodiment 3 of the present invention.
  • FIG. 4 is a schematic structural diagram of another apparatus for identifying a network port type according to Embodiment 4 of the present invention.
  • An embodiment of the present invention provides a method for identifying a network port type.
  • the method is applied to a first device having a compatible LAN network port and a WAN network port. As shown in FIG. 1 , the method includes:
  • the first device may be a device such as a CPE; the second device is an access device connected to the CPE device through a network cable.
  • the network port sends an access signal of the second device to the first device to notify that the second device is currently accessed.
  • the acquired interaction message includes: an interaction message sent by the first device to the second device and an interaction message sent by the second device to the first device.
  • the network port can be a multiplexed Ethernet port, and the device periodically sends a Dynamic Host Configuration Protocol (DHCP) request message and an Ethernet point-to-point protocol (Point To) to the network card corresponding to the multiplexed Ethernet port.
  • DHCP Dynamic Host Configuration Protocol
  • PPPOE Point Protocol Over Ethernet
  • the first device may determine a message type of the interaction message from the second device, that is, an interaction message sent by the second device to the first device.
  • the interaction message from the second device includes: a DHCP request message, a DHCP response message, a PPPOE response message, and the like, wherein the message mode of the DHCP request message is a request IP mode, a DHCP response message, and a PPPOE response.
  • the message mode of the message is the assigned IP mode.
  • S103 Determine the type of the network port according to the message type, where the network port type includes: a LAN network port and a WAN network port;
  • the message mode of the message is determined according to the message type, the message mode includes requesting the IP mode and the allocated IP mode; when the message mode is the requesting IP mode, determining that the type of the network port is a LAN network port; when the message mode is the assigned IP mode
  • the type of the network port is determined to be a WAN network port.
  • the message mode of the message is the request IP mode, the type of the network port is a LAN network port, and the device is configured as a server end; when the message type is a DHCP response message
  • the message mode of the message is the IP mode, the type of the network port is a WAN port, and the device is configured as a DHCP client.
  • the message mode is a PPPOE response message
  • the message mode of the message is the IP mode.
  • the type of the network port is a WAN network port, and the device is configured as a PPPOE client.
  • the method further includes: when the determined network port type is different from the current configuration type of the network port, switching the type of the network port of the device to the determined network port type. That is, when the network port type determined in step S103 is a WAN network port, and the network port type currently configured by the network port is a LAN network port, the type of the network port is switched from the WAN network port to the LAN network port; The network port type determined in step S103 is a LAN network port, and the type of the network port currently configured by the network port is a WAN network port, and the type of the network port is switched from the LAN network port to the WAN network port.
  • the type of the network port of the device is switched to the determined network port type, when If the type of the network port is the same as the current type of the network port, the network port type is not switched and the original network port type is retained.
  • the method for identifying the network port type provided by the first embodiment of the present invention is further described in the first embodiment of the present invention.
  • the initial state of the multiplexed Ethernet port can also be a LAN network port, which is not limited by the present invention.
  • the method includes:
  • the CPE is initialized to a WAN network port.
  • the CPE After being powered on, the CPE can be initialized to the broadband mode and the multiplexed Ethernet port is initialized to the WAN network port as the initial mode. After the initialization, the CPE enables the IP address function of the monitoring application to monitor whether the access device accessing the CPE through the multiplexed Ethernet port sends a DHCP request packet to the CPE. This includes access through the multiplexed Ethernet port. The device applies for ip, wifi user application ip, other Ethernet port application ip, etc. to apply for IP function. The CPE periodically sends a DHCP Request message to the NIC corresponding to the multiplexed Ethernet port, and the DHCP Request message is a request packet for applying for IP.
  • the two parts of the real-time monitoring and the periodic sending of the request message can belong to different processes and are executed by different processes, but all belong to the CPE itself.
  • S202 After receiving the access signal accessed by the access device, determine an access type of the interaction message from the access device, and determine a type of the multiplexed Ethernet port.
  • the access device that accesses the CPE is determined to be the client.
  • S203 Adjust the type of the multiplexed Ethernet interface. Specifically, the type of the multiplexed Ethernet interface of the CPE is switched to the LAN network port. Correspondingly, the CPE is switched to the gateway mode, and the CPE is configured as the server.
  • the access device that is connected to the CPE is the DHCP server or the PPPOE server.
  • the type of the multiplexed Ethernet port of the CPE is the WAN port.
  • the CPE is in the broadband mode and is configured as a DHCP client or a PPPOE client.
  • the CPE receives two kinds of DHCP message or PPPOE response message from the device connected to the multiplexed Ethernet interface.
  • the CPE has two ways to allocate ip according to the received message in the broadband mode: DHCP. Mode, PPPOE mode;
  • the server side that is accessed is a DHCP server.
  • the CPE is set to the DHCP broadband mode; when the received PPPOE response message indicates that the accessed server is the PPPOE server, the CPE is set to the PPPOE broadband mode.
  • the CPE will periodically send an application ip request to the multiplexed Ethernet port, and the sent request includes a PPPOE request and a DHCP request, thereby preventing The form of the access device through the multiplexed Ethernet port (the client ⁇ -----> server) changes.
  • the CPE after the power is turned on, the CPE periodically sends a DHCP request and a PPPOE request to the network card corresponding to the multiplexed Ethernet port, and continuously monitors whether the device accessing the CPE through the multiplexed Ethernet port sends a DHCP request, and identifies
  • the CPE broadcast sends a PADI lookup for the PPPOE server.
  • PADI PADI message sent by the CPE
  • the CPE sends the PADR to the PPPOE server after receiving the PADO sent by the PPPoE server the PPPOE server responds to the CPE with the PADS.
  • the CPE determines whether the current connection is a PPPOE server. If the PADO packet or the PADS packet is received, the CPE can be determined to be connected through the multiplexed Ethernet port. For the PPPOE server, the multiplexed Ethernet port is set to the WAN port, and the CPE is configured to the PPPOE broadband mode.
  • the CPE After receiving the DHCP Request message or the DHCP Ack message sent by the server, the CPE can determine whether the current multiplexed Ethernet port is connected to the DHCP server. If the DHCP Offer message is received, A DHCP Ack packet is used to determine that the CPE is connected to the DHCP server through the multiplexed Ethernet port.
  • the multiplexed Ethernet port is set to the WAN port and the CPE is configured as the DHCP broadband mode.
  • the client accessing the CPE needs to go through DHCPDiscover (the client sends the CPE) through DHCP.
  • ->DHCPOffer CPE sends to the client
  • ->DHCPRequest client
  • ->DHCPAck CPE sends to the client
  • the CPE receives the DHCPDiscover or DHCP Request message sent through the multiplexed Ethernet interface, it considers that the currently connected device is a client device. Set the multiplexed Ethernet port to the LAN port and set the current CPE mode to the gateway mode.
  • the CPE initially uses the multiplexed Ethernet port as the LAN network port or the WAN network port.
  • the WAN side is implemented by updating the WAN side IP address, the CPE DNS address, and the iptables rules related to the network card. Switching between the LAN port and the LAN port to accommodate changes in the upstream path of the CPE.
  • the embodiment of the invention further provides a device for identifying a network port type, which is applied to a compatible LAN network port and a WAN.
  • the device includes: an obtaining module 301, a determining module 302, and an identifying module 303, where
  • the obtaining module 301 is configured to: after receiving the access signal of the access device, acquire an interaction message with the second device;
  • the determining module 302 is configured to determine a message type of the interactive message.
  • the identification module 302 is configured to determine the type of the network port according to the message type.
  • the network port type includes: a LAN network port and a WAN network port.
  • the method is configured to determine a message mode of the message according to the message type, where the message mode includes requesting an IP mode and assigning an IP mode; and when the message mode is an IP mode, determining that the type of the network port is a LAN network. If the message mode is the IP mode, the type of the network port is determined to be a WAN network port.
  • the message type is a dynamic host configuration protocol DHCP request or a PPPOE request message
  • determining that the message mode of the message is the requesting IP mode; correspondingly, determining that the type of the network port is a LAN network port
  • the device is configured as a server.
  • the message type is a DHCP response message
  • the message mode of the message is determined to be an IP mode.
  • the type of the network port is determined to be a WAN network port, and the device is configured as a DHCP client.
  • the message mode of the message is determined to be an IP mode; correspondingly, the type of the network port is determined to be a WAN network port, and the device is configured as a PPPOE client. end.
  • PPPOE Point-to-Point Protocol
  • the device further includes: a sending module 304, and a switching module 305, wherein the sending module 304 is configured to periodically send the DHCP request packet and the PPPOE request packet to the network card corresponding to the network port. Text.
  • the switching module 305 is configured to switch the type of the network port of the first device to the determined network port type when the determined network port type is different from the network port type currently configured by the network port.
  • the obtaining module 301, the determining module 302, the identifying module 303, the sending module 304, and the switching module 305 in the device for identifying the network port type proposed in the embodiment of the present invention may all be implemented by a processor, and may also pass through a specific logic circuit.
  • the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA).
  • the integrated modules described in the embodiments of the present invention may also be stored in a computer readable storage medium if they are implemented in the form of software functional modules and sold or used as separate products. Based on such understanding, the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product stored in a storage medium, including a plurality of instructions.
  • a computer device (which may be a personal computer, server, or network device, etc.) is caused to perform all or part of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
  • embodiments of the invention are not limited to any specific combination of hardware and software.
  • the embodiment of the present invention further provides a computer storage medium, where the computer storage medium stores a computer program for performing the above method for identifying a network port type according to an embodiment of the present invention.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Small-Scale Networks (AREA)

Abstract

本发明实施例公开了一种识别网口类型的方法,应用于具有兼容局域网(LAN)网口和广域网(WAN)网口的第一设备中,所述方法包括:所述第一设备在接收到连接到与自身连接的第二设备的接入信号后,获取自身与所述第二设备的交互消息;判断所述交互消息的消息类型;根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。

Description

一种识别网口类型的方法、装置及存储介质 技术领域
本发明涉及通信领域,尤其涉及一种识别网口类型的方法、装置及存储介质。
背景技术
本申请发明人在实现本申请实施例技术方案的过程中,至少发现相关技术中存在如下技术问题:
针对同一个网口复用的情况,传统的家庭网关类产品的做法是在特定模式下通过网线连接特定设备,也就是说,通过网线插入到兼容局域网(Local Area Network,LAN)网口和广域网(Wide Area Network,WAN)网口的用户端设备(Customer Premises Equipment,CPE)等设备时,该网口只能是LAN网口或WAN网口,即该设备只能处于网关模式或者宽带模式,具体来说:当在网关模式下通过网线插入到网口时,该网口为LAN网口,此时,该设备是服务器端,与客户端(如:电脑)连接;在宽带模式下通过网线插入到网口时,该网口为WAN网口,此时,该设备是客户器端,与固网连接。
因此,若用户对当前CPE工作模式不明确则将设备(服务器端设备或客户端设备)通过网线连接CPE后设备无法获得期望的服务,造成用户体验不好。从而,急需一种自动识别当前网络充当LAN网口还是WAN网络皮的解决方案。
发明内容
有鉴于此,本发明实施例希望提供一种识别网口类型的方法和装置, 至少解决了现有技术存在的问题,能够实现LAN网口和WAN网口的自动识别。
本发明实施例的技术方案是这样实现的:
一种识别网口类型的方法,应用于具有兼容LAN网口和WAN网口的第一设备中,所述方法包括:所述第一设备在接收到与自身连接的第二设备的接入信号后,获取自身与所述第二设备的交互消息;判断所述交互消息的消息类型;根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。
其中,所述判断所述交互消息的消息类型包括:判断所述第二设备发送的交互消息的消息类型。
其中,所述根据所述消息类型确定所述网口的类型包括:
根据所述消息类型确定所述消息的消息模式,所述消息模式包括请求IP模式和分配IP模式;
当所述消息模式为请求IP模式时,确定所述网口的类型为LAN网口;
当所述消息模式为分配IP模式时,确定所述网口的类型为WAN网口。
在一实施例中,所述根据所述消息类型确定所述网口的类型还包括:当所述消息类型为动态主机配置协议DHCP请求报文时,确定所述消息的消息模式为请求IP模式;相应的,确定所述网口的类型为LAN网口,所述第一设备配置为服务器端。
在一实施例中,所述根据所述消息类型确定所述网口的类型还包括:当所述消息类型为DHCP响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述第一设备配置为DHCP客户端。
在一实施例中,所述根据所述消息类型确定所述网口的类型还包括:当所述消息类型为以太网点对点协议PPPOE响应报文时,确定所述消息的 消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述第一设备配置为PPPOE客户端。
在一实施例中,所述方法还包括:所述第一设备周期性的向所述网口对应的网卡发送DHCP请求报文和PPPOE请求报文。
在一实施例中,所述方法还包括:当所述确定的网口类型与所述网口当前的配置的类型不同时,将所述第一设备的网口的类型切换至所述确定的网口类型。
一种识别网口类型的装置,所述装置包括:获取模块、判断模块以及识别模块,其中,
所述获取模块,配置为在接收到接入设备的接入信号后,获取与所述接入设备的交互消息;
所述判断模块,配置为判断所述交互消息的消息类型;
所述识别模块,配置为根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。
其中,所述判断模块,具体配置为判断来自于所述接入设备的交互消息的消息类型。
其中,所述识别模块具体配置为:
根据所述消息类型确定所述消息的消息模式,所述消息模式包括请求IP模式和分配IP模式;
当所述消息模式为请求IP模式时,确定所述网口的类型为LAN网口;
当所述消息模式为分配IP模式时,确定所述网口的类型为WAN网口。
在一实施例中,所述识别模块还配置为:当所述消息类型为动态主机配置协议DHCP请求报文时,确定所述消息的消息模式为请求IP模式;相应的,确定所述网口的类型为LAN网口,所述第一设备配置为服务器端。
在一实施例中,所述识别模块还配置为:当所述消息类型为DHCP响 应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为DHCP客户端。
在一实施例中,所述识别模块还配置为:当所述消息类型为以太网点对点协议PPPOE响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为PPPOE客户端。
在一实施例中,所述装置还包括:发送模块,配置为所述第一设备周期性的向所述网口对应的网卡发送DHCP请求报文和PPPOE请求报文。
在一实施例中,所述装置还包括:切换模块,配置为当所述确定的网口类型与所述网口当前的配置的类型不同时,将所述装置的网口的类型切换至所述确定的网口类型。
本发明实施例还提供一种计算机存储介质,所述计算机存储介质存储有计算机程序,该计算机程序用于执行本发明实施例的上述识别网口类型的方法。
本发明实施例识别网口类型的方法、装置及存储介质,第一设备在接收到连接到所述第一设备的第二设备的接入信号后,获取所述第二设备的交互消息;判断所述交互消息的消息类型;根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。采用本发明实施例,至少解决了现有技术存在的问题,能够实现LAN网口和WAN网口的自动识别,从而提升用户体验。
附图说明
图1为本发明实施例一提供的一种识别网口类型的方法的流程示意图;
图2为本发明实施例二提供的一种识别网口类型的方法的流程示意图;
图3为本发明实施例三提供的一种识别网口类型的装置的结构示意图;
图4为本发明实施例四提供的另一种识别网口类型的装置的结构示意图。
具体实施方式
下面结合附图对技术方案的实施作进一步的详细描述。
实施例一
本发明实施例提供了一种识别网口类型的方法,该方法应用于具有兼容LAN网口和WAN网口的第一设备中,如图1所示,该方法包括:
S101:第一设备在接收到与自身连接的第二设备的接入信号后,获取自身与所述接入设备的交互消息;
这里,第一设备可为CPE等设备;第二设备为通过网线连接到CPE设备的接入设备。当第二设备通过网线接入到第一设备的网口时,网口向第一设备内部发送第二设备的接入信号,以通知当前有第二设备接入,此时,第一设备获取第二设备与第一设备之间的交互消息,这里,此时,获取的交互消息包括:第一设备发送给第二设备的交互消息和第二设备发送给第一设备的交互消息。
这里,该网口可为复用以太网口,设备周期性的向复用以太网口对应的网卡发送动态主机配置协议(Dynamic Host Configuration Protocol,DHCP)请求报文和以太网点对点协议(Point To Point Protocol Over Ethernet,PPPOE)请求报文。
S102:判断所述交互消息的消息类型;
第一设备可判断来自于第二设备的交互消息的消息类型,也就是第二设备发送给第一设备的交互消息。这里,来自第二设备的交互消息包括:DHCP请求报文、DHCP响应报文,PPPOE响应报文等交互消息,其中,DHCP请求报文的消息模式为请求IP模式,DHCP响应报文和PPPOE响应报文的消息模式为分配IP模式。
S103:根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口;
这里,根据消息类型确定消息的消息模式,消息模式包括请求IP模式和分配IP模式;当消息模式为请求IP模式时,确定所述网口的类型为LAN网口;当消息模式为分配IP模式时,确定所述网口的类型为WAN网口。具体的,当消息类型为DHCP请求报文时,所述消息的消息模式为请求IP模式,所述网口的类型为LAN网口,所述设备配置为服务器端;当消息类型为DHCP响应报文时,该消息的消息模式为分配IP模式,该网口的类型为WAN网口,设备配置为DHCP客户端;当消息类型为PPPOE响应报文时,该消息的消息模式为分配IP模式,该网口的类型为WAN网口,该设备配置为PPPOE客户端。
该方法还包括:当所述确定的网口类型与所述网口当前的配置的类型不同时,将所述设备的网口的类型切换至所述确定的网口类型。也就是说,当步骤S103确定的网口类型为WAN网口,而该网口当前配置的网口类型为LAN网口,则将该网口的类型由WAN网口切换为LAN网口;当步骤S103确定的网口类型为LAN网口,而该网口当前配置的网口类型为WAN网口,则将该网口的类型由LAN网口切换为WAN网口。
需要说明的是,当所述确定的网口类型与所述网口当前的配置的网口类型不同时,将所述设备的网口的类型切换至所述确定的网口类型,当所述确定的网口类型与所述网口当前的配置的类型相同时,对网口类型不做切换,保留原来的网口类型。
实施例二
本发明实施例二具有复用以太网口的设备CPE的复用以太网口的初始状态为WAN网口为例,对本发明实施例一提供的识别网口类型的方法做进一步说明,但需要说明的是,复用以太网口的初始状态也可为LAN网口,本发明对此不做限制。
如图2所示,该方法包括:
S201:CPE初始化为WAN网口;
CPE在开机后可初始化为宽带模式并将复用以太网口初始化为WAN网口,以此作为初始模式。在初始化之后,CPE开启监听申请IP功能,实时监听通过复用以太网口接入CPE的接入设备是否向CPE发送了DHCP请求报文,此处包括通过复用以太网口接入的接入设备申请ip、wifi用户申请ip、其它以太网口申请ip等申请IP功能。CPE在开启监听申请IP功能的同时,周期性的向复用以太网口对应的网卡发送DHCP请求报文,其中,DHCP请求报文为用于申请IP的请求报文。
这需要说明的是,实时监听和周期性的发送请求报文这两部分任务分可属于不同的进程,由不同的进程执行,但都属于CPE自身要完成的任务。
S202:接收到接入设备接入的接入信号后,判断来自接入设备的交互消息的接入类型,确定复用以太网口的类型。
若收到来自复用以太网口接入的设备发出的DHCP请求报文等用于申请IP的请求,则确定接入CPE的接入设备为客户端,此时执行步骤203;
S203:调整复用以太网口的类型;具体的,将CPE的复用以太网口的类型切换为LAN网口,相应的,将CPE切换为网关模式,CPE配置为服务器端。
若收到来自复用以太网口接入的设备发出的DHCP响应报文或PPPOE响应报文等用于分配IP的消息,则确定接入CPE的接入设备为DHCP服务器端或PPPOE服务器端,保持CPE的复用以太网口的类型为WAN网口,CPE为宽带模式,配置为DHCP客户端或PPPOE客户端。
收到来自复用以太网口接入的设备发出的DHCP响应报文或PPPOE响应报文两种分配报文的消息,CPE根据接收到的消息在宽带模式下有两种分配ip的方式:DHCP方式、PPPOE方式;
当接收到的是DHCP响应报文则说明接入的服务器端为DHCP服务器, 此时将CPE设定为DHCP宽带模式;当接收到的是PPPOE响应报文则说明接入的服务器端为PPPOE服务器,此时将CPE设定为PPPOE宽带模式。
需要说明的是,无论此时CPE为4G网关模式、DHCP宽带模式、PPPOE模式,CPE内部仍将周期性向复用以太网口发送申请ip请求,所发送请求包括PPPOE请求和DHCP请求,从而能够防止通过复用以太网口接入设备的形式(客户端<----->服务器)发生变化。
在本发明实施例中,上电后CPE内部周期性向复用以太网口对应的网卡发送DHCP请求、PPPOE请求并且不断监听通过复用以太网口接入CPE的设备是否发送了DHCP请求,在识别LAN网口和WAN网口的过程中涉及到三种过程:PPPOE-server过程、DHCP-server过程以及客户端过程,当接收到接入设备的接入信号后,这三种过程中的消息交互具体如下:
a.发现PPPOE-server过程:
PPPOE发现阶段,CPE广播发送PADI查找PPPOE服务器。当网络内有PPPOE服务器并且收到了CPE发送的PADI报文则会向CPE回应PADO。当CPE在收到PPPoE服务器发送的PADO之后向PPPOE服务器发送PADR,PPPOE服务器向CPE回应PADS。
当CPE周期性的发送PPPOE请求报文后收到PADO或PADS报文,则确定当前连接的是否是PPPOE服务器,若收到PADO报文或PADS报文则可确定CPE通过复用以太网口连接了PPPOE服务器,则将复用以太网口设置为WAN口,CPE配置为PPPOE宽带模式。
b.发现DHCP-server过程:
当CPE作为客户端第一次向DHCP服务器申请ip需要经历DHCPDiscover-(CPE发送给DHCP服务器)--->DHCP Offer(DHCP服务器发送给CPE)---->DHCP Request(CPE发送给DHCP服务器)---->DHCP Ack(DHCP服务器发送给CPE)四个步骤。
当CPE在发出DHCP请求报文后收到服务器端发来的DHCP Offer报文或DHCP Ack报文,则可确定当前复用以太网口上连接的是否是DHCP服务器,若收到DHCP Offer报文或DHCP Ack报文,可确定CPE通过复用以太网口连接了DHCP服务器,则将复用以太网口设置为WAN口,CPE配置为DHCP宽带模式。
c.发现客户端过程:
当CPE作为服务器端,接入CPE的客户端通过DHCP方式申请ip地址需要经历DHCPDiscover(客户端发送给CPE)---->DHCPOffer(CPE发送给客户端)---->DHCPRequest(客户端发送给CPE)---->DHCPAck(CPE发送给客户端)四个步骤,如果CPE收到通过复用以太网口发来的DHCPDiscover或DHCP Request消息则认为当前连接的设备是客户端设备,此时将复用以太网口设置为LAN口,将CPE当前模式设置为网关模式。
在本发明实施例提供的自动识别LAN网口和WAN网口的方法中,CPE初始时将复用以太网口可作为LAN网口也可作为WAN网口。在从LAN网口切换至WAN网口或从WAN网口切换至LAN网口的过程中,通过将WAN侧IP地址、CPE的DNS地址、与网卡相关的iptables规则等进行更新,从而实现WAN端和LAN口之间的切换,以适应CPE的上行通路的变化。
实施例三
本发明实施例还提供一种识别网口类型的装置,应用于具有兼容LAN网口和WAN
Figure PCTCN2016099856-appb-000001
的网口的第一设备中,如图3所示,所述装置包括:获取模块301、判断模块302以及识别模块303,其中,
获取模块301,配置为在接收到接入设备的接入信号后,获取与所述第二设备的交互消息;
判断模块302,配置为判断所述交互消息的消息类型;
具体配置为判断来自于所述接入设备的交互消息的消息类型。
识别模块302,配置为根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。
具体配置为根据所述消息类型确定所述消息的消息模式,所述消息模式包括请求IP模式和分配IP模式;当所述消息模式为请求IP模式时,确定所述网口的类型为LAN网口;当所述消息模式为分配IP模式时,确定所述网口的类型为WAN网口。
这里,当所述消息类型为动态主机配置协议DHCP请求或PPPOE请求报文时,确定所述消息的消息模式为请求IP模式;相应的,确定所述网口的类型为LAN网口,所述装置配置为服务器端。当所述消息类型为DHCP响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为DHCP客户端。当所述消息类型为以太网点对点协议PPPOE响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为PPPOE客户端。
如图4所示,所述装置还包括:发送模块304、切换模块305,其中,发送模块304配置为所述第一设备周期性的向网口对应的网卡发送DHCP请求报文和PPPOE请求报文。切换模块305配置为当所述确定的网口类型与所述网口当前的配置的网口类型不同时,将所述第一设备的网口的类型切换至所述确定的网口类型。
本发明实施例中提出的识别网口类型的装置中的获取模块301、判断模块302以及识别模块303、发送模块304和切换模块305都可以通过处理器来实现,当然也可通过具体的逻辑电路实现;在实际应用中,处理器可以为中央处理器(CPU)、微处理器(MPU)、数字信号处理器(DSP)或现场可编程门阵列(FPGA)等。
本发明实施例所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。这样,本发明实施例不限制于任何特定的硬件和软件结合。
相应地,本发明实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机程序,该计算机程序用于执行本发明实施例的上述识别网口类型的方法。
以上所述,仅为本发明的较佳实施例而已,并非用于限定本发明的保护范围。

Claims (17)

  1. 一种识别网口类型的方法,应用于具有兼容局域网LAN网口和广域网WAN网口的第一设备中,所述方法包括:
    所述第一设备在接收到与自身连接的第二设备的接入信号后,获取自身与所述第二设备的交互消息;
    判断所述交互消息的消息类型;
    根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。
  2. 根据权利要求1所述的方法,其中,所述判断所述交互消息的消息类型包括:判断所述第二设备发送的交互消息的消息类型。
  3. 根据权利要求2所述的方法,其中,所述根据所述消息类型确定所述网口的类型包括:
    根据所述消息类型确定所述消息的消息模式,所述消息模式包括请求IP模式和分配IP模式;
    当所述消息模式为请求IP模式时,确定所述网口的类型为LAN网口;
    当所述消息模式为分配IP模式时,确定所述网口的类型为WAN网口。
  4. 根据权利要求3所述的方法,其中,所述根据所述消息类型确定所述网口的类型还包括:
    当所述消息类型为动态主机配置协议DHCP请求报文时,确定所述消息的消息模式为请求IP模式;
    相应的,确定所述网口的类型为LAN网口,所述第一设备配置为服务器端。
  5. 根据权利要求3所述的方法,其中,所述根据所述消息类型确定所述网口的类型还包括:
    当所述消息类型为DHCP响应报文时,确定所述消息的消息模式为分配IP模式;
    相应的,确定所述网口的类型为WAN网口,所述第一设备配置为DHCP客户端。
  6. 根据权利要求3所述的方法,其中,所述根据所述消息类型确定所述网口的类型还包括:
    当所述消息类型为以太网点对点协议PPPOE响应报文时,确定所述消息的消息模式为分配IP模式;
    相应的,确定所述网口的类型为WAN网口,所述第一设备配置为PPPOE客户端。
  7. 根据权利要求2所述的方法,其中,所述方法还包括:所述第一设备周期性的向所述网口对应的网卡发送DHCP请求报文和PPPOE请求报文。
  8. 根据权利要求1所述的方法,其中,所述方法还包括:
    当所述确定的网口类型与所述网口当前的配置类型不同时,将所述第一设备的网口类型切换至所述确定的网口类型。
  9. 一种识别网口类型的装置,所述装置包括:获取模块、判断模块以及识别模块,其中,
    所述获取模块,配置为在接收到接入设备的接入信号后,获取与所述接入设备的交互消息;
    所述判断模块,配置为判断所述交互消息的消息类型;
    所述识别模块,配置为根据所述消息类型确定所述网口的类型;其中,所述网口类型包括:LAN网口和WAN网口。
  10. 根据权利要求9所述的装置,其中,所述判断模块,配置为判断来自于所述接入设备的交互消息的消息类型。
  11. 根据权利要求10所述的装置,其中,所述识别模块配置为:
    根据所述消息类型确定所述消息的消息模式,所述消息模式包括请求IP模式和分配IP模式;
    当所述消息模式为请求IP模式时,确定所述网口的类型为LAN网口;
    当所述消息模式为分配IP模式时,确定所述网口的类型为WAN网口。
  12. 根据权利要求11所述的装置,其中,所述识别模块还配置为:
    当所述消息类型为动态主机配置协议DHCP请求报文时,确定所述消息的消息模式为请求IP模式;相应的,确定所述网口的类型为LAN网口,所述装置配置为服务器端。
  13. 根据权利要求11所述的装置,其中,所述识别模块还配置为:
    当所述消息类型为DHCP响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为DHCP客户端。
  14. 根据权利要求11所述的装置,其中,所述识别模块还配置为:
    当所述消息类型为以太网点对点协议PPPOE响应报文时,确定所述消息的消息模式为分配IP模式;相应的,确定所述网口的类型为WAN网口,所述装置配置为PPPOE客户端。
  15. 根据权利要求10所述的装置,其中,所述装置还包括:发送模块,配置为周期性的向所述网口对应的网卡发送DHCP请求报文和PPPOE请求报文。
  16. 根据权利要求9所述的装置,其中,所述装置还包括:切换模块,配置为当所述确定的网口类型与所述网口当前的配置的类型不同时,将所述装置的网口的类型切换至所述确定的网口类型。
  17. 本发明实施例还提供了一种计算机存储介质,所述计算机存储介质存储有计算机程序,该计算机程序用于执行本发明实施例的上述识别网 口类型的方法。
PCT/CN2016/099856 2016-09-23 2016-09-23 一种识别网口类型的方法、装置及存储介质 WO2018053799A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP16916538.8A EP3518464A4 (en) 2016-09-23 2016-09-23 METHOD FOR IDENTIFYING THE NETWORK CONNECTION TYPE, DEVICE AND STORAGE MEDIUM
PCT/CN2016/099856 WO2018053799A1 (zh) 2016-09-23 2016-09-23 一种识别网口类型的方法、装置及存储介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/099856 WO2018053799A1 (zh) 2016-09-23 2016-09-23 一种识别网口类型的方法、装置及存储介质

Publications (1)

Publication Number Publication Date
WO2018053799A1 true WO2018053799A1 (zh) 2018-03-29

Family

ID=61689811

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/099856 WO2018053799A1 (zh) 2016-09-23 2016-09-23 一种识别网口类型的方法、装置及存储介质

Country Status (2)

Country Link
EP (1) EP3518464A4 (zh)
WO (1) WO2018053799A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1509032A (zh) * 2002-12-16 2004-06-30 动态广域网端口检测
CN103534984A (zh) * 2012-10-08 2014-01-22 华为终端有限公司 端口设置方法、路由设备及电脑程序产品
WO2016086544A1 (zh) * 2014-12-04 2016-06-09 中兴通讯股份有限公司 网络设备的网口配置方法、装置及存储介质
CN106341246A (zh) * 2015-07-07 2017-01-18 西安中兴新软件有限责任公司 一种自动识别lan端口和wan端口的方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1509032A (zh) * 2002-12-16 2004-06-30 动态广域网端口检测
CN103534984A (zh) * 2012-10-08 2014-01-22 华为终端有限公司 端口设置方法、路由设备及电脑程序产品
WO2016086544A1 (zh) * 2014-12-04 2016-06-09 中兴通讯股份有限公司 网络设备的网口配置方法、装置及存储介质
CN106341246A (zh) * 2015-07-07 2017-01-18 西安中兴新软件有限责任公司 一种自动识别lan端口和wan端口的方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3518464A4 *

Also Published As

Publication number Publication date
EP3518464A4 (en) 2020-04-22
EP3518464A1 (en) 2019-07-31

Similar Documents

Publication Publication Date Title
US7725594B2 (en) Assigning priority to network traffic at customer premises
US9401889B2 (en) Port-based dynamic network parameter assignment
US20100106791A1 (en) PROCESSING METHOD AND DEVICE FOR QinQ TERMINATION CONFIGURATION
EP2888863B1 (en) Method and apparatus for configuring dhcp client
US10855809B2 (en) Printer with dual media access control interfaces and uninterrupted interface change
JP4806728B2 (ja) Dhcpネットワークシステムにおける輻輳を減少させるための改良された方法及び装置
CN106341246A (zh) 一种自动识别lan端口和wan端口的方法和装置
US9521109B2 (en) Systems, methods, and computer-readable media for allocation and renewal of IP addresses
WO2017088101A1 (zh) 一种网络连接信息获取方法及路由器
CN105610994B (zh) Ip地址分配方法、同轴电缆中间转换器及系统
CN102904902B (zh) 一种基于dhcp旁路阻断方法
US20140280467A1 (en) Method of managing port dhcp server protocol addresses
KR20040077888A (ko) 다이내믹 호스트 구성 프로토콜 임대 시간 결정 방법 및장치
WO2012028011A1 (zh) 一种会话监控方法及服务节点设备
WO2018053799A1 (zh) 一种识别网口类型的方法、装置及存储介质
WO2016177185A1 (zh) 媒体访问控制mac地址的处理方法及装置
KR100595524B1 (ko) 기기 검색 시스템 및 방법
WO2012119386A1 (zh) 一种接入网络中的认证方法、设备和系统
WO2015085558A1 (zh) 一种动态分配ip地址的方法、装置和系统
WO2016062268A1 (zh) 动态主机配置协议重连方法、dhcp服务器及系统
WO2005067205A1 (fr) Dispositif d&#39;acces a large bande et son procede pour la commande d&#39;un agent de relais dhcp
US20230114769A1 (en) Remote controller source address verification and retention for access devices
CN108243078B (zh) 地址分配方法和装置
Wang et al. DHCP support for secure automatic detection of host status
TW201431341A (zh) 端口dhcp伺服器協定位址管理之方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16916538

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2016916538

Country of ref document: EP

Effective date: 20190423