WO2020206849A1 - 一种处理带vlan tag的dhcp数据的方法及系统 - Google Patents

一种处理带vlan tag的dhcp数据的方法及系统 Download PDF

Info

Publication number
WO2020206849A1
WO2020206849A1 PCT/CN2019/094116 CN2019094116W WO2020206849A1 WO 2020206849 A1 WO2020206849 A1 WO 2020206849A1 CN 2019094116 W CN2019094116 W CN 2019094116W WO 2020206849 A1 WO2020206849 A1 WO 2020206849A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
client
vlan tag
dhcp
ethernet
Prior art date
Application number
PCT/CN2019/094116
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 烽火通信科技股份有限公司
Publication of WO2020206849A1 publication Critical patent/WO2020206849A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/46Interconnection of networks
    • H04L12/4641Virtual LANs, VLANs, e.g. virtual private networks [VPN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/30Peripheral units, e.g. input or output ports
    • H04L49/3072Packet splitting
    • 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
    • H04L61/5007Internet protocol [IP] addresses
    • H04L61/5014Internet protocol [IP] addresses using dynamic host configuration protocol [DHCP] or bootstrap protocol [BOOTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/45Network directories; Name-to-address mapping
    • H04L61/4505Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
    • H04L61/4511Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]

Definitions

  • the invention relates to the technical field of intelligent terminal communication, in particular to a method and system for processing DHCP data with VLAN TAG.
  • the data sent and received by the Linux open source DHCP Server is all three-layer data.
  • VLAN TAG is stripped in the Linux kernel protocol stack, so protocol data with VLAN TAG cannot be processed. If the DHCP data sent by the client has VLAN TAG , The ordinary DHCP Server cannot assign an IP address to it.
  • the upstream routing device may not match the connected network, resulting in inability to connect to the Internet network, which will cause inconvenience to program debugging and service testing, resulting in slower debugging progress and reduced efficiency .
  • the purpose of the present invention is to provide a method and system for processing DHCP data with VLAN TAG, which can process DHCP data with VLAN TAG sent by the client.
  • the present invention provides a method for processing DHCP data with VLAN TAG, which includes the following steps:
  • the VLAN TAG and client MAC obtained in the message, obtain the IP and DNS information assigned by the server to the client corresponding to the VLAN TAG and client MAC;
  • client MAC According to the obtained VLAN TAG, client MAC, source IP, destination IP, port information, IP and DNS information to be replied to the client, reorganize the message according to the Ethernet frame data format and DHCP data format, and send the reorganization to the client After the message.
  • the capturing of the message sent by the client specifically includes the following steps:
  • the filtering out DHCP protocol messages includes the following steps:
  • the report is reported in accordance with the Ethernet frame data format and the DHCP data format.
  • the reorganization of the text includes the following steps:
  • Ethernet header, the 802.1Q frame, the IP message header, the UDP header, the DHCP application data, and the Ethernet tail are sequentially combined into the reorganized Ethernet frame data, in which:
  • the Ethernet header includes the client MAC
  • the 802.1Q frame includes the length and specific value of the VLAN TAG
  • the UDP header includes port information
  • the IP message header includes the protocol version number
  • the DHCP application data includes the reply to the client IP and DNS information of the end.
  • the sending of the reassembled message to the client specifically includes the following steps: using an open source interface function for sending Ethernet frames to realize the sending of the reassembled message.
  • the present invention also provides a system for processing DHCP data with VLAN TAG, including:
  • Message capture module which is used to: capture the message sent by the client
  • the message filtering module is used to: set a message filter to filter out DHCP protocol messages;
  • the message parsing module is used to: parse out the VLAN TAG, client MAC, source IP, destination IP, and port information from the message;
  • An information search module which is used to: obtain the IP and DNS information assigned by the server to the client corresponding to the VLAN TAG and client MAC according to the VLAN TAG and client MAC obtained in the message;
  • the message reassembly module is used to: according to the obtained VLAN TAG, client MAC, source IP, destination IP, port information, IP and DNS information to be replies to the client, and report according to the Ethernet frame data format and DHCP data format Text reorganization;
  • the message sending module is used to: send the reassembled message to the client.
  • the message capturing module captures the message sent by the client, specifically including the following steps: real-time capture of the data message sent by the client and reaching the server network port through the API interface function.
  • the message filtering module filters out DHCP protocol messages, including the following steps:
  • the DHCP protocol message is extracted
  • the message reassembly module according to the obtained VLAN TAG, client MAC, source IP, destination IP, port information, IP and DNS information to be replies to the client, according to the Ethernet frame data format and DHCP
  • the data format reorganizes the message, including the following steps:
  • Ethernet header, the 802.1Q frame, the IP message header, the UDP header, the DHCP application data, and the Ethernet tail are sequentially combined into the reorganized Ethernet frame data, in which:
  • the Ethernet header includes the client MAC
  • the 802.1Q frame includes the length and specific value of the VLAN TAG
  • the UDP header includes port information
  • the IP message header includes the protocol version number
  • the DHCP application data includes the reply to the client IP and DNS information of the end.
  • the message sending module sends the reassembled message to the client, which specifically includes the following steps: adopting an open source interface function for sending Ethernet frames to realize the sending of the reassembled message.
  • the present invention captures the message sent by the client in real time, encapsulates and reassembles the message, and forms a new Ethernet data frame to realize the processing of DHCP data with VLAN TAG, thereby assigning new IP, DNS, etc. to the client Address information improves the convenience and timeliness of program debugging, development and business testing.
  • FIG. 1 is a schematic diagram of the network environment structure of the method for processing DHCP data with VLAN TAG according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a system for processing DHCP data with VLAN TAG according to an embodiment of the present invention.
  • the embodiment of the present invention is used to realize the interaction of DHCP data with VLAN TAG between the DHCP client and the DHCP server.
  • an embodiment of the present invention provides a method for processing DHCP data with VLAN TAG, which includes the following steps:
  • the embodiment of the present invention captures the message sent by the client in real time, encapsulates and reassembles the message, and forms a new Ethernet data frame to realize the processing of DHCP data with VLAN TAG, thereby assigning a new IP to the client.
  • DNS and other address information improves the convenience and timeliness of program debugging, development and business testing, and avoids the problem of incompatibility with the connected network.
  • the capturing of the message sent by the client specifically includes the following steps: real-time capturing of the data message sent by the client and arriving at the network port of the server through an API interface function.
  • the open source PCAP code under Linux uses the interface functions it provides to capture the data packets received in the network interface eth0 in real time.
  • the filtering out DHCP protocol messages includes the following steps:
  • the DHCP protocol message in the buffer BUFFER is analyzed to extract the VLAN TAG, source IP, destination IP, port 67, 68 and other data information in the message; then the VLAN TAG sent by the client , IP, port and other information are temporarily stored in the prepared sending data buffer BUFFER.
  • This BUFFER data is the data that needs to be returned to the client.
  • a comparative search is performed in a file stored locally on the server side to find out the IP, DNS and other information that needs to be replied to the client.
  • the message is matched according to the Ethernet frame data format and the DHCP data format
  • the reorganization includes the following steps:
  • This message includes two parts: header and data.
  • the Ethernet header, the 802.1Q frame, the IP message header, the UDP header, the DHCP application data, and the Ethernet tail are sequentially combined into the reorganized Ethernet frame data, in which:
  • the Ethernet header includes the client MAC
  • the 802.1Q frame includes the length and specific value of the VLAN TAG
  • the UDP header includes port information
  • the IP message header includes the protocol version number
  • the DHCP application data includes the reply to the client IP and DNS information of the end.
  • the sending of the reassembled message to the client specifically includes the following steps: using the open source PCAP to send the interface function of the Ethernet frame to realize the sending of the reassembled message.
  • the embodiment of the present invention also provides a system for processing DHCP data with VLAN TAG, including:
  • Message capture module which is used to: capture the message sent by the client
  • the message filtering module is used to: set a message filter to filter out DHCP protocol messages;
  • the message parsing module is used to: parse out the VLAN TAG, client MAC, source IP, destination IP, and port information from the message;
  • An information search module which is used to: obtain the IP and DNS information assigned by the server to the client corresponding to the VLAN TAG and client MAC according to the VLAN TAG and client MAC obtained in the message;
  • the message reassembly module is used to: according to the obtained VLAN TAG, client MAC, source IP, destination IP, port information, IP and DNS information to be replies to the client, and report according to the Ethernet frame data format and DHCP data format Text reorganization;
  • the message sending module is used to: send the reassembled message to the client.
  • the message capturing module capturing the message sent by the client specifically includes the following steps: real-time capture of the data message sent by the client and reaching the server network port through an API interface function.
  • the message filtering module filters out DHCP protocol messages, including the following steps:
  • the DHCP protocol message is extracted
  • the message reassembly module according to the obtained VLAN TAG, client MAC, source IP, destination IP, port information, IP and DNS information to be replies to the client, according to the Ethernet frame data format and DHCP data
  • the format reorganizes the message, including the following steps:
  • Ethernet header, the 802.1Q frame, the IP message header, the UDP header, the DHCP application data, and the Ethernet tail are sequentially combined into the reorganized Ethernet frame data, in which:
  • the Ethernet header includes the client MAC
  • the 802.1Q frame includes the length and specific value of the VLAN TAG
  • the UDP header includes port information
  • the IP message header includes the protocol version number
  • the DHCP application data includes the reply to the client IP and DNS information of the end.
  • the message sending module sending the reassembled message to the client specifically includes the following steps: using an open source interface function for sending Ethernet frames to realize the sending of the reassembled message.
  • the embodiments of the present application provide a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, all method steps or some methods of the method for processing DHCP data with VLAN TAG are realized step.
  • the present invention implements all or part of the processes in the above method for processing DHCP data with VLAN TAG, which can also be completed by instructing relevant hardware through a computer program.
  • the computer program can be stored in a computer-readable storage medium. When executed by the processor, the steps of the foregoing method embodiments can be implemented.
  • the computer program includes computer program code, and the computer program code may be in the form of source code, object code, executable file, or some intermediate forms.
  • Computer-readable media may include: any entity or device capable of carrying computer program code, recording media, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access Memory (RAM, Random Access Memory), electric carrier signal, telecommunications signal, software distribution medium, etc.
  • computer-readable media can be appropriately added or deleted according to the requirements of the legislation and patent practice in the jurisdiction.
  • computer-readable media does not include Electric carrier signal and telecommunications signal.
  • an embodiment of the present application also provides an electronic device, including a memory and a processor.
  • the memory stores a computer program running on the processor.
  • the processor executes the computer program to realize the processing of DHCP data with VLAN TAG. All or part of the method steps in the method.
  • the so-called processor can be a central processing unit (Central Processing Unit, CPU), other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), ready-made Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
  • the processor is the control center of the computer device, and various parts of the computer device are connected by various interfaces and lines.
  • the memory may be used to store computer programs and/or modules, and the processor implements various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory.
  • the memory may mainly include a storage program area and a storage data area, where the storage program area can store the operating system, at least one application program (such as sound playback function, image playback function, etc.) required by the function; the storage data area can be stored according to the mobile phone Use the created data (such as audio data, video data, etc.).
  • the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disks, memory, plug-in hard disks, smart media cards (SMC), and secure digital (SD) cards. , Flash Card, at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
  • the embodiments of the present invention can be provided as methods, systems, servers, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种处理带VLAN TAG的DHCP数据的方法及系统,涉及智能终端通信技术领域,本发明通过实时捕获客户端发送的报文,对报文进行封装重组,形成新的以太网数据帧,来实现对带VLAN TAG的DHCP数据的处理,从而给客户端分配新的IP,DNS 等地址信息,提高程序的调试、开发以及业务的测试的便利性和时效性。

Description

一种处理带VLAN TAG的DHCP数据的方法及系统 技术领域
本发明涉及智能终端通信技术领域,具体涉及一种处理带VLAN TAG的DHCP数据的方法及系统。
背景技术
目前Linux开源的DHCP Server收发的数据都是三层数据,VLAN TAG在Linux内核协议栈被剥离了,所以不能处理带有VLAN TAG的协议数据,如果当客户端发送的DHCP数据带有VLAN TAG时,则普通的DHCP Server无法给其分配IP地址。此时需要借助上行的路由设备来配置带有VLAN TAG的WAN连接。但是,当上行的路由设备配置了VLAN TAG之后,可能会与接入的网络无法匹配,导致无法连接Internet网络,进而给程序调试及业务测试带来不便,导致调试进展的放慢及效率的下降。
发明内容
针对现有技术中存在的缺陷,本发明的目的在于提供一种处理带VLAN TAG的DHCP数据的方法及系统,能处理客户端发送的带VLAN TAG的DHCP数据。
为达到以上目的,本发明采取的技术方案是:本发明提供一种处理带VLAN TAG的DHCP数据的方法,包括以下步骤:
捕获客户端发送的报文,过滤出DHCP协议报文;
从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,向客户端发送重组后的报文。
在上述方案的基础上,所述捕获客户端发送的报文,具体包括以下步骤:
通过API接口函数,实时捕获客户端发送的、到达服务端网口的报文。
在上述方案的基础上,所述过滤出DHCP协议报文,包括以下步骤:
设置过滤参数,提取出DHCP协议报文;
将过滤出的报文,复制到预先指定的缓冲队列中。
在上述方案的基础上,所述根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
在上述方案的基础上,所述向客户端发送重组后的报文,具体包括以下步骤:采用开源的发送以太网帧的接口函数,实现重组后的报 文的发送。
本发明还提供一种处理带VLAN TAG的DHCP数据的系统,包括:
报文捕获模块,其用于:捕获客户端发送的报文;
报文过滤模块,其用于:设置报文过滤器,过滤出DHCP协议报文;
报文解析模块,其用于:从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
信息查找模块,其用于:根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
报文重组模块,其用于:根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组;
报文发送模块,其用于:向客户端发送重组后的报文。
在上述方案的基础上,所述报文捕获模块捕获客户端发送的报文,具体包括以下步骤:通过API接口函数,实时捕获客户端发送的、到达服务端网口的数据报文。
在上述方案的基础上,所述报文过滤模块过滤出DHCP协议报文,包括以下步骤:
通过设置过滤参数,提取出DHCP协议报文;
将过滤出的报文,复制到预先指定的缓冲队列中,等待依次进行处理。
在上述方案的基础上,所述报文重组模块根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和 DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
在上述方案的基础上,所述报文发送模块向客户端发送重组后的报文,具体包括以下步骤:采用开源的发送以太网帧的接口函数,实现重组后的报文的发送。
与现有技术相比,本发明的优点在于:
本发明通过实时捕获客户端发送的报文,对报文进行封装重组,形成新的以太网数据帧,来实现对带VLAN TAG的DHCP数据的处理,从而给客户端分配新的IP,DNS等地址信息,提高程序的调试、开发以及业务的测试的便利性和时效性。
附图说明
图1为本发明实施例的实现处理带VLAN TAG的DHCP数据的方法的网络环境结构示意图;
图2为本发明实施例的实现处理带VLAN TAG的DHCP数据的系统的流程示意图。
具体实施方式
以下结合附图对本发明的实施例作进一步详细说明。
参见图1所示,本发明实施例用于实现DHCP客户端与DHCP 服务端之间带VLAN TAG的DHCP数据的交互。
参见图2所示,本发明实施例提供一种处理带VLAN TAG的DHCP数据的方法,包括以下步骤:
S1,捕获客户端发送的报文,过滤出DHCP协议报文;
S2,从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
S3,根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
S4,根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,向客户端发送重组后的报文。
本发明实施例通过实时捕获客户端发送的报文,对报文进行封装重组,形成新的以太网数据帧,来实现对带VLAN TAG的DHCP数据的处理,从而给客户端分配新的IP,DNS等地址信息,提高程序的调试、开发以及业务的测试的便利性和时效性,并避免与接入的网络无法匹配的问题。
作为优选的实施方式,所述捕获客户端发送的报文,具体包括以下步骤:通过API接口函数,实时捕获客户端发送的、到达服务端网口的数据报文。例如,Linux下开源的PCAP代码,通过其提供的接口函数来实时捕获网络接口eth0中收到的数据包。
作为优选的实施方式,所述过滤出DHCP协议报文,包括以下步骤:
设置过滤参数,提取出DHCP协议报文;
将过滤出的报文,复制到预先指定的缓冲队列中,等待依次进行下一步处理。
例如,通过设置过滤参数"udp port 67||vlan||vlan and udp port 67"来对报文进行过滤,提取出DHCP协议相关的报文,由于只需要处理DHCP协议相关数据,那么其他的数据将其丢弃。此过程也是通过指定的API接口进行数据抓包,放入其预先设定的数据缓冲BUFFER中,进行临时存储。
作为优选的实施方式,对缓冲BUFFER中的DHCP协议报文进行解析,提取出报文中的VLAN TAG,源IP,目的IP,端口67,68等数据信息;然后将此客户端发送的VLAN TAG,IP,端口等信息临时存储在准备好的发送数据缓冲BUFFER中,此BUFFER数据是需要给客户端回复的数据。
作为优选的实施方式,根据报文中获取的CLIENT端的MAC地址和VLAN TAG值信息,在服务端的本地存储的文件中进行对比查找,找出给客户端需回复的IP,DNS等信息。
作为优选的实施方式,所述根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
重组发送数据报文,此报文包括头和数据两部分。依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
重组完了一个完整的以太网数据帧,通过普通的DHCP服务端 工具是无法完成对其数据的发送的。作为优选的实施方式,所述向客户端发送重组后的报文,具体包括以下步骤:采用开源的PCAP发送以太网帧的接口函数,实现重组后的报文的发送。
通过S1到S4,完成了对DHCP OFFER报文的传输,接下来重复以上4个步骤来完成对DHCP ACK报文的发送,经过数据的收发四个过程后,便实现了整个DHCP协议的交互过程,这样的DHCP服务端就将IP,DNS等信息分配给了对应的客户端,来实现对带VLAN TAG的DHCP数据的处理,从而给客户端分配新的IP,DNS等地址信息,提高程序的调试、开发以及业务的测试的便利性和时效性。
本发明实施例还提供一种处理带VLAN TAG的DHCP数据的系统,包括:
报文捕获模块,其用于:捕获客户端发送的报文;
报文过滤模块,其用于:设置报文过滤器,过滤出DHCP协议报文;
报文解析模块,其用于:从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
信息查找模块,其用于:根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
报文重组模块,其用于:根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组;
报文发送模块,其用于:向客户端发送重组后的报文。
作为优选的实施方式,所述报文捕获模块捕获客户端发送的报文,具体包括以下步骤:通过API接口函数,实时捕获客户端发送的、到 达服务端网口的数据报文。
作为优选的实施方式,所述报文过滤模块过滤出DHCP协议报文,包括以下步骤:
通过设置过滤参数,提取出DHCP协议报文;
将过滤出的报文,复制到预先指定的缓冲队列中,等待依次进行处理。
作为优选的实施方式,所述报文重组模块根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
作为优选的实施方式,所述报文发送模块向客户端发送重组后的报文,具体包括以下步骤:采用开源的发送以太网帧的接口函数,实现重组后的报文的发送。
基于同一发明构思,本申请实施例提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现处理带VLAN TAG的DHCP数据的方法的所有方法步骤或部分方法步骤。
本发明实现上述实现处理带VLAN TAG的DHCP数据的方法中的全部或部分流程,也可以通过计算机程序来指令相关的硬件来完成,计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处 理器执行时,可实现上述各个方法实施例的步骤。其中,计算机程序包括计算机程序代码,计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。计算机可读介质可以包括:能够携带计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、电载波信号、电信信号以及软件分发介质等。需要说明的是,计算机可读介质包含的内容可以根据司法管辖区内立法和专利实践的要求进行适当的增减,例如在某些司法管辖区,根据立法和专利实践,计算机可读介质不包括电载波信号和电信信号。
基于同一发明构思,本申请实施例还提供一种电子设备,包括存储器和处理器,存储器上储存有在处理器上运行的计算机程序,处理器执行计算机程序时实现处理带VLAN TAG的DHCP数据的方法中的所有方法步骤或部分方法步骤。
所称处理器可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等,处理器是计算机装置的控制中心,利用各种接口和线路连接整个计算机装置的各个部分。
存储器可用于存储计算机程序和/或模块,处理器通过运行或执行存储在存储器内的计算机程序和/或模块,以及调用存储在存储器内的数据,实现计算机装置的各种功能。存储器可主要包括存储程序 区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据手机的使用所创建的数据(比如音频数据、视频数据等)等。此外,存储器可以包括高速随机存取存储器,还可以包括非易失性存储器,例如硬盘、内存、插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)、至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、服务器或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、服务器和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中 指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (10)

  1. 一种处理带VLAN TAG的DHCP数据的方法,其特征在于,包括以下步骤:
    捕获客户端发送的报文,过滤出DHCP协议报文;
    从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
    根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
    根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,向客户端发送重组后的报文。
  2. 如权利要求1所述的方法,其特征在于,所述捕获客户端发送的报文,具体包括以下步骤:
    通过API接口函数,实时捕获客户端发送的、到达服务端网口的报文。
  3. 如权利要求1所述的方法,其特征在于,所述过滤出DHCP协议报文,包括以下步骤:
    设置过滤参数,提取出DHCP协议报文;
    将过滤出的报文,复制到预先指定的缓冲队列中。
  4. 如权利要求1所述的方法,其特征在于,所述根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
    依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
    以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
  5. 如权利要求1所述的方法,其特征在于:所述向客户端发送重组后的报文,具体包括以下步骤:采用开源的发送以太网帧的接口函数,实现重组后的报文的发送。
  6. 一种处理带VLAN TAG的DHCP数据的系统,其特征在于,包括:
    报文捕获模块,其用于:捕获客户端发送的报文;
    报文过滤模块,其用于:设置报文过滤器,过滤出DHCP协议报文;
    报文解析模块,其用于:从报文中解析出VLAN TAG、客户端MAC、源IP、目的IP和端口信息;
    信息查找模块,其用于:根据报文中获取的VLAN TAG和客户端MAC,获得服务端分配给与VLAN TAG和客户端MAC对应的客户端的IP和DNS信息;
    报文重组模块,其用于:根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组;
    报文发送模块,其用于:向客户端发送重组后的报文。
  7. 如权利要求6所述的系统,其特征在于:所述报文捕获模块捕获客户端发送的报文,具体包括以下步骤:通过API接口函数,实时捕获客户端发送的、到达服务端网口的数据报文。
  8. 如权利要求6所述的系统,其特征在于:所述报文过滤模块 过滤出DHCP协议报文,包括以下步骤:
    通过设置过滤参数,提取出DHCP协议报文;
    将过滤出的报文,复制到预先指定的缓冲队列中,等待依次进行处理。
  9. 如权利要求6所述的系统,其特征在于:所述报文重组模块根据获得的VLAN TAG、客户端MAC、源IP、目的IP、端口信息、待回复给客户端的IP和DNS信息,按照以太网帧数据格式和DHCP数据格式对报文进行重组,具体包括以下步骤:
    依次将以太网首部、802.1Q帧、IP报文首部、UDP首部、DHCP应用数据和以太网尾部组成重组后的以太网帧数据,其中:
    以太网首部包括客户端MAC,802.1Q帧包括VLAN TAG的长度和具体的数值,UDP首部包括端口信息,IP报文首部包括协议版本号、源IP和目的IP,DHCP应用数据包括待回复给客户端的IP和DNS信息。
  10. 如权利要求6所述的系统,其特征在于:所述报文发送模块向客户端发送重组后的报文,具体包括以下步骤:采用开源的发送以太网帧的接口函数,实现重组后的报文的发送。
PCT/CN2019/094116 2019-04-09 2019-07-01 一种处理带vlan tag的dhcp数据的方法及系统 WO2020206849A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910282799.0 2019-04-09
CN201910282799.0A CN110099138A (zh) 2019-04-09 2019-04-09 一种处理带vlan tag的dhcp数据的方法及系统

Publications (1)

Publication Number Publication Date
WO2020206849A1 true WO2020206849A1 (zh) 2020-10-15

Family

ID=67444579

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/094116 WO2020206849A1 (zh) 2019-04-09 2019-07-01 一种处理带vlan tag的dhcp数据的方法及系统

Country Status (2)

Country Link
CN (1) CN110099138A (zh)
WO (1) WO2020206849A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113992608A (zh) * 2021-10-25 2022-01-28 北京科东电力控制系统有限责任公司 一种网络收发包路径优化方法、装置及存储介质
CN114745419A (zh) * 2022-05-07 2022-07-12 深信服科技股份有限公司 获取终端mac地址的方法、装置、设备及存储介质
CN114827297A (zh) * 2022-04-29 2022-07-29 中国建设银行股份有限公司 协议适配方法、装置、设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101227407A (zh) * 2008-01-25 2008-07-23 华为技术有限公司 基于二层隧道协议的报文发送方法及装置
CN101252587A (zh) * 2008-04-18 2008-08-27 杭州华三通信技术有限公司 用户终端的接入鉴权方法和设备
CN102137011A (zh) * 2011-02-18 2011-07-27 华为技术有限公司 网络中的报文转发方法、装置和系统
CN103685257A (zh) * 2013-12-06 2014-03-26 上海斐讯数据通信技术有限公司 一种dhcp网络防护系统及方法
CN104104747A (zh) * 2014-07-28 2014-10-15 杭州华三通信技术有限公司 报文传输方法及装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2011153679A1 (zh) * 2010-06-07 2011-12-15 华为技术有限公司 业务配置方法、设备和系统
US9712489B2 (en) * 2014-07-29 2017-07-18 Aruba Networks, Inc. Client device address assignment following authentication
CN106850871B (zh) * 2017-01-23 2020-11-17 上海上讯信息技术股份有限公司 一种单物理网卡多vlan的dhcp服务器实现方法
CN107508928A (zh) * 2017-09-07 2017-12-22 安徽皖通邮电股份有限公司 一种dhcp自动获取ip地址的实现方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101227407A (zh) * 2008-01-25 2008-07-23 华为技术有限公司 基于二层隧道协议的报文发送方法及装置
CN101252587A (zh) * 2008-04-18 2008-08-27 杭州华三通信技术有限公司 用户终端的接入鉴权方法和设备
CN102137011A (zh) * 2011-02-18 2011-07-27 华为技术有限公司 网络中的报文转发方法、装置和系统
CN103685257A (zh) * 2013-12-06 2014-03-26 上海斐讯数据通信技术有限公司 一种dhcp网络防护系统及方法
CN104104747A (zh) * 2014-07-28 2014-10-15 杭州华三通信技术有限公司 报文传输方法及装置

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113992608A (zh) * 2021-10-25 2022-01-28 北京科东电力控制系统有限责任公司 一种网络收发包路径优化方法、装置及存储介质
CN113992608B (zh) * 2021-10-25 2024-01-05 北京科东电力控制系统有限责任公司 一种网络收发包路径优化方法、装置及存储介质
CN114827297A (zh) * 2022-04-29 2022-07-29 中国建设银行股份有限公司 协议适配方法、装置、设备及存储介质
CN114827297B (zh) * 2022-04-29 2024-04-16 中国建设银行股份有限公司 协议适配方法、装置、设备及存储介质
CN114745419A (zh) * 2022-05-07 2022-07-12 深信服科技股份有限公司 获取终端mac地址的方法、装置、设备及存储介质
CN114745419B (zh) * 2022-05-07 2024-02-23 深信服科技股份有限公司 获取终端mac地址的方法、装置、设备及存储介质

Also Published As

Publication number Publication date
CN110099138A (zh) 2019-08-06

Similar Documents

Publication Publication Date Title
WO2021207922A1 (zh) 报文传输方法、装置及系统
US10148573B2 (en) Packet processing method, node, and system
WO2020206849A1 (zh) 一种处理带vlan tag的dhcp数据的方法及系统
CN110149262B (zh) 一种信令报文的处理方法和装置、及存储介质
CN109361606B (zh) 一种报文处理系统及网络设备
EP3422656B1 (en) Udp protocol acceleration method and system
CN108632558B (zh) 一种视频通话的方法和装置
US20150289301A1 (en) Terminal matching method, terminal and system
CN106559302A (zh) 单播隧道建立方法、装置和系统
CN107360205A (zh) 数据报文的传输方法及装置、系统
CN108664316A (zh) 一种获取api的接口信息的方法和装置
US20220393908A1 (en) Message Encapsulation Method and Apparatus, and Message Decapsulation Method and Apparatus
CN108989480A (zh) 一种在服务器获取客户端地址的方法
CN108173763B (zh) 报文处理方法、设备及系统
CN115225734A (zh) 一种报文处理方法和网络设备
CN107483369B (zh) 一种报文处理方法及虚拟交换机
CN110049009B (zh) 一种身份信息获取系统和方法
CN108574609B (zh) 一种传输监控方法和装置
CN110351159B (zh) 一种跨内网的网络性能测试方法及装置
CN108574637B (zh) 一种地址自学习的方法、装置及交换机
WO2017193814A1 (zh) 一种业务链生成方法及系统
EP3913865A1 (en) Message decapsulation method and device, message encapsulation method and device, electronic device, and storage medium
CN110098993B (zh) 一种信令报文的处理方法和装置
CN111478940A (zh) 一种数据处理的方法和装置
CN111865884A (zh) 一种报文处理方法、装置及设备

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: 19923853

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19923853

Country of ref document: EP

Kind code of ref document: A1