A kind of port data separation method and device
Technical field
The invention belongs to the communications field more particularly to a kind of port data separation methods and device.
Background technique
When carrying out data communication using thin access point (full name in English fitAP) equipment, it is generally used for realizing control number
It is separated according to message with the virtual LAN vlan of user data message, so that control data message and user data message are mutual
It does not interfere.
Method currently used for realizing port data separation passes through rule usually when sending data packet by protocol stack
The channel vlan of model creates vlan interface, is then packaged distribution to the data message of user in protocol stack.
But if when the data of the user of access point connection are very more, for example at show ground, concert scene
Deng thin access point fitAP may overload operation.This is because the efficient packet of thin access point fitAP protocol stack is lower, by
In needing to need to forward layer by layer by protocol stack to user data package, a large amount of system resource can be occupied in this way, also, network is set
Standby when receiving data packet, also the same needs go to unpack, removal tag mark.In this way, one data packet of every transmission, need pair
Data packet is once encapsulated, and a data packet is often received, and needs once to unpack data packet, needs to consume system money
Source completes then to will affect the normal operation of field network when user is very more in the package and de-packaging operation of protocol stack, responds
User's normal use.
Summary of the invention
The purpose of the present invention is to provide a kind of port data separation methods, if to solve the connection of prior art access point
User data it is very more when, need to consume system resource and complete package and de-packaging operation in protocol stack, then will affect existing
The problem of normal operation of field network, response user's normal use.
In a first aspect, the embodiment of the invention provides a kind of port data separation methods, which comprises
When receiving the data of second line of a couplet port transmission, ignore protocol stack package process, and be sent to by the data
When upper layer network, data determine corresponding VLAN ID vlanid based on the received, and the data are added virtually
LAN ID vlanid;
When receiving the data of upper layer network transmission, received data are parsed to obtain VLAN ID
Vlanid, and forwarded the data on according to the VLAN ID vlanid to corresponding port.
With reference to first aspect, in the first possible implementation of first aspect, the data based on the received are determined
Corresponding VLAN ID vlanid step includes:
Source MAC and source network card equipment title are extracted in the received data;
Judge whether the source network card equipment title is identical with preset network card equipment title;
If the source network card equipment title is identical with preset network card equipment title, the VLAN ID
Vlanid is wireline interface VLAN ID vlanid;
If the source network card equipment title is different with preset network card equipment title, looked into according to the source MAC
Corresponding wireless interface is looked for, corresponding VLAN ID vlanid is determined according to the wireless interface.
With reference to first aspect, described to add the data virtually in second of possible implementation of first aspect
LAN ID vlanid step includes:
In data storage area, the data are elapsed backward, is obtained before the data storage location of data storage area
Structure control head space;
Structure control head space is reset into assignment, corresponding VLAN ID vlanid is written.
With reference to first aspect, described to receive upper layer network hair in the third possible implementation of first aspect
When the data sent, received data are parsed to obtain VLAN ID vlanid, and according to the virtual LAN
Mark vlanid, which is forwarded the data on to corresponding port step, includes:
When receiving the data of upper layer network transmission, the structure control head space of the data is parsed, the number is obtained
According to corresponding network interface;
The data are sent to corresponding network interface.
With reference to first aspect, in the 4th kind of possible implementation of first aspect, the port data separation method base
In thin base station fit AP.
Second aspect, the embodiment of the invention provides a kind of port data separation methods, which comprises
Adding unit is identified, for ignoring protocol stack package process when receiving the data of second line of a couplet port transmission, and
When the data are sent to upper layer network, data determine corresponding VLAN ID vlanid based on the received, and will
The data add VLAN ID vlanid;
Identification (RNC-ID) analytic unit, for parse to received data when receiving the data of upper layer network transmission
It forwards the data on to VLAN ID vlanid, and according to the VLAN ID vlanid to corresponding end
Mouthful.
In conjunction with second aspect, in the first possible implementation of second aspect, the mark adding unit includes:
Subelement is extracted, for extracting source MAC and source network card equipment title in the received data;
Judgment sub-unit, for judging whether the source network card equipment title is identical with preset network card equipment title;
First identifier subelement, if identical with preset network card equipment title for the source network card equipment title,
The VLAN ID vlanid is wireline interface VLAN ID vlanid;
Second identifier subelement, if different with preset network card equipment title for the source network card equipment title,
Corresponding wireless interface is searched according to the source MAC, corresponding VLAN ID is determined according to the wireless interface
vlanid。
In conjunction with second aspect, in second of possible implementation of second aspect, the mark adding unit includes:
Subelement is elapsed, for the data being elapsed backward, the data in data storage area are deposited in data storage area
Storage space obtains structure control head space before setting;
Corresponding virtual LAN is written for structure control head space to be reset assignment in mark write-in subelement
Identify vlanid.
In conjunction with second aspect, in the third possible implementation of second aspect, the identification (RNC-ID) analytic unit is specifically used
In:
When receiving the data of upper layer network transmission, the structure control head space of the data is parsed, the number is obtained
According to corresponding network interface, the data are sent to corresponding network interface.
In conjunction with second aspect, in the 4th kind of possible implementation of second aspect, the port data separation method base
In thin base station fit AP.
In the present invention, when receiving the data of second line of a couplet port, ignore the package process of protocol stack, sent by data
When to upper layer network, corresponding VLAN ID is determined according to data, and the virtual net is added to the data and is identified,
When receiving the data of upper layer network, received data are parsed to obtain VLAN ID, according to described virtual
LAN ID forwards the data to corresponding port, so as to avoid entering data protocol stack package and de-packaging operation,
The treatment effeciency for improving data reduces the consumption of system resource, so as to preferably adapt to multi-user while using
It is required that.
Detailed description of the invention
Fig. 1 is the implementation flow chart for the port data separation method that first embodiment of the invention provides;
Fig. 2 is the reality that the data based on the received that second embodiment of the invention provides determine corresponding VLAN ID
Existing flow chart;
Fig. 3 is the structural schematic diagram for the port data separator that third embodiment of the invention provides.
Specific embodiment
In order to make the objectives, technical solutions, and advantages of the present invention clearer, with reference to the accompanying drawings and embodiments, right
The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and
It is not used in the restriction present invention.
The purpose of the embodiment of the present invention is to solve in the prior art since more people are using the same access point, for example thin connects
When access point, thin access point may overload operation, which is because, thin access point need using protocol stack to data packet carry out
Forward layer by layer, a large amount of system resource can be occupied, unpacked when receiving data, send a data packet need into
The operation of row package, wastes a large amount of system resource, so that network data be caused to block, the speed for influencing the normal use of user is wanted
It asks.The present invention is specifically illustrated with reference to the accompanying drawing.
Embodiment one:
Fig. 1 shows the implementation process of the port data separation method of first embodiment of the invention offer, and details are as follows:
In step s101, when receiving the data of second line of a couplet port transmission, ignore protocol stack package process, and by institute
When stating data and being sent to upper layer network, data determine corresponding VLAN ID vlanid based on the received, and will be described
Data add VLAN ID vlanid.
Specifically, the data that reception second line of a couplet port described in the embodiment of the present invention is sent, refer to access point, such as thin access
The routing devices such as point.The second line of a couplet port refers to one end of close user side in a network, and in a network close to server
One end, then be upper layer network described in the embodiment of the present invention.
The package process of the protocol stack refers to that protocol stack according to the regulation of protocol layer, carries out package layer by layer to data, i.e.,
When data enter each protocol stack layers, header packet information is added to data according to the agreement of this layer.In embodiments of the present invention
Ignore protocol stack package process, the identification information that package can be carried out by modification data is realized, naturally it is also possible to by other
Protocol stack package process is ignored in the triggering that mode is instructed without package, realization.
After ignoring the package process, when sending data to upper layer network, according to the identification information in data, obtain
The corresponding VLAN ID vlanid of data, and the VLAN ID vlanid is added to the data, from
It and can will include that the data identified are accurately sent to target position, and can reduce the package operation to data.
In step s 102, when receiving the data of upper layer network transmission, received data are parsed to obtain void
Quasi- LAN ID vlanid, and forwarded the data on according to the VLAN ID vlanid to corresponding port.
When receiving the data sent by upper layer network, need to parse the target position of data, root of the present invention
It parses to obtain VLAN ID vlanid according to received data, according to the preset VLAN ID and port
Corresponding relationship, to forward the data to corresponding port.
For example, can be parsed to obtain source physical MAC address and network card equipment title according to data, according to network card equipment name
Claim and source physical MAC address, in conjunction with preset corresponding relationship, port corresponding to available data, thus by data into
Row separation.
The embodiment of the present invention is ignored the package process of protocol stack, is sent out by data when receiving the data of second line of a couplet port
When sending to upper layer network, corresponding VLAN ID is determined according to data, and the virtual network mark is added to the data
Know, when receiving the data of upper layer network, received data is parsed to obtain VLAN ID, according to the void
Quasi- LAN ID forwards the data to corresponding port, so as to avoid entering data protocol stack package and unpack behaviour
Make, improves the treatment effeciency of data, reduce the consumption of system resource, so as to preferably adapt to multi-user while using
Requirement.
Embodiment two:
The data based on the received provided Fig. 2 shows second embodiment of the invention determine corresponding VLAN ID
The implementation process of vlanid specifically introduce to the step as follows on the basis of example 1:
In step s 201, source MAC and source network card equipment title are extracted in the received data.
Specifically, extracting source MAC and source network card equipment title in the received data, can be exported in network card interface
Module adds add_vlan code, extraction source mac address field and source network card equipment title in the part data of sk_buff
Field.Wherein, the sk_buff is the most important structure of ICP/IP protocol stack, it is performance of the network data report in kernel
Form can extract the information of the address corresponding source mac and source network card equipment title in data data portion wherein.
In step S202, judge whether the source network card equipment title is identical with preset network card equipment title.
In embodiments of the present invention, wired network card apparatus title is preset, for example, the preset network card equipment title
It can be Eth1, then the identification of wired network interface can be rapidly performed by by the comparison of network card equipment title.
In step S203, if the source network card equipment title is identical with preset network card equipment title, the void
Quasi- LAN ID vlanid is wireline interface VLAN ID vlanid.
Since the title for presetting all wired network adapters is identical, then, if network card equipment title is identified as presetting
Selected title then can quickly identify wired network interface.
By the identification to wired network adapter title, it can overcome and wire user and wireless user are carried out in the prior art
Identify difficult problem.In the prior art, the data of the wired mouth and wireless mouth that are connected for thin access point are all unified
Forwarding also brings many inconvenience to management in this way, if we will extract wireless user, must just pick inside user list
Except wire user, wireless user is obtained with this, furthermore, current fitAP equipment at least one general wireless access point, greatly
Majority all concentrates between 2-10 wireless access point, and it is just more difficult to separate different access point users in this way.And it is of the invention
By the identification of network card equipment title, wireline interface can be quickly identified.
For example, if the preset entitled Eth1 of source network card equipment, when the network card equipment for parsing the equipment is entitled
It is then that can determine that the interface is the vlanid of wired mouthful of Eth1 according to the network card equipment title when Eth1.
In step S204, if the source network card equipment title is different with preset network card equipment title, according to institute
It states source MAC and searches corresponding wireless interface, corresponding VLAN ID vlanid is determined according to the wireless interface.
If comparing to obtain network card equipment title different from preset network card equipment title, then it represents that current interface is wireless
Interface then needs further to be further determined that according to the corresponding relationship of the source address mac and VLAN ID vlanid wireless
The VLAN ID vlanid of interface.The i.e. different source addresses mac correspond to different VLAN ID vlanid.From
And different wireless interfaces can be distinguished.
In the virtual local area network mark for the VLAN ID vlanid and different wireless interfaces for distinguishing wireline interface
Know vlanid, further include the steps that data are further added VLAN ID vlanid, comprising:
In data storage area, the data are elapsed backward, is obtained before the data storage location of data storage area
Structure control head space;Structure control head space is reset into assignment, corresponding VLAN ID vlanid is written.
It can be instructed data field by skb_push to pusher, it is empty for addition vlan_ethhdr structure control head storage
Between, after emptying assignment to vlan_ethhdr structure control head, corresponding VLAN ID vlanid is written to h_
It can be completed in vlan_TCI element and VLAN ID vlanid added to data.
It is corresponding with step S102 in embodiment one, it is described when receiving the data of upper layer network transmission, to received
Data are parsed to obtain VLAN ID vlanid, and according to the VLAN ID vlanid by the data
Being forwarded to corresponding port step includes:
When receiving the data of upper layer network transmission, the structure control head space of the data is parsed, the number is obtained
According to corresponding network interface;The data are sent to corresponding network interface.
It is corresponding with above-mentioned addition VLAN ID vlanid, when being parsed for received data, according to
The structure of structure control head accesses addition remove_vlan code in network card interface, when network device entrance receives data packet
When, the structured data of structure control head is first extracted, is hair according to the VLAN ID vlanid determination in the data of extraction
Toward which network interface, such as wired network interface and specific radio network interface etc., corresponding net is forwarded the data to
Network interface.
The embodiment of the present invention on the basis of example 1, further to wired network interface data and radio network interface
Data and different radio network interface data distinguish, and are effectively reducing the system resources consumption of the network equipment
Meanwhile also improving the convenience of data separation.
Embodiment three:
Fig. 3 shows the structural schematic diagram of the port data separation of third embodiment of the invention offer, and details are as follows:
Port data separator described in the embodiment of the present invention, comprising:
Adding unit 301 is identified, for ignoring protocol stack package process when receiving the data of second line of a couplet port transmission,
And when the data are sent to upper layer network, data determine corresponding VLAN ID vlanid based on the received,
And the data are added into VLAN ID vlanid;
Identification (RNC-ID) analytic unit 302, for being parsed to received data when receiving the data of upper layer network transmission
VLAN ID vlanid is obtained, and is forwarded the data on according to the VLAN ID vlanid to corresponding
Port.
Preferably, the mark adding unit includes:
Subelement is extracted, for extracting source MAC and source network card equipment title in the received data;
Judgment sub-unit, for judging whether the source network card equipment title is identical with preset network card equipment title;
First identifier subelement, if identical with preset network card equipment title for the source network card equipment title,
The VLAN ID vlanid is wireline interface VLAN ID vlanid;
Second identifier subelement, if different with preset network card equipment title for the source network card equipment title,
Corresponding wireless interface is searched according to the source MAC, corresponding VLAN ID is determined according to the wireless interface
vlanid。
Preferably, the mark adding unit includes:
Subelement is elapsed, for the data being elapsed backward, the data in data storage area are deposited in data storage area
Storage space obtains structure control head space before setting;
Corresponding virtual LAN is written for structure control head space to be reset assignment in mark write-in subelement
Identify vlanid.
Preferably, the identification (RNC-ID) analytic unit is specifically used for:
When receiving the data of upper layer network transmission, the structure control head space of the data is parsed, the number is obtained
According to corresponding network interface, the data are sent to corresponding network interface.
Preferably, the port data separation method is based on thin base station fit AP.
Port data separator described in the embodiment of the present invention, port data separation method described in the present embodiment one, two
It is corresponding, so here is no more repetition.
In several embodiments provided by the present invention, it should be understood that disclosed device and method can pass through it
Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the unit, only
Only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components can be tied
Another system is closed or is desirably integrated into, or some features can be ignored or not executed.Another point, it is shown or discussed
Mutual coupling, direct-coupling or communication connection can be through some interfaces, the INDIRECT COUPLING or logical of device or unit
Letter connection can be electrical property, mechanical or other forms.
The unit as illustrated by the separation member may or may not be physically separated, aobvious as unit
The component shown may or may not be physical unit, it can and it is in one place, or may be distributed over multiple
In network unit.It can select some or all of unit therein according to the actual needs to realize the mesh of this embodiment scheme
's.
It, can also be in addition, the functional units in various embodiments of the present invention may be integrated into one processing unit
It is that each unit physically exists alone, can also be integrated in one unit with two or more units.Above-mentioned integrated list
Member both can take the form of hardware realization, can also realize in the form of software functional units.
If the integrated unit is realized in the form of SFU software functional unit and sells or use as independent product
When, it can store in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially
The all or part of the part that contributes to existing technology or the technical solution can be in the form of software products in other words
It embodies, which is stored in a storage medium, including some instructions are used so that a computer
Equipment (can be personal computer, server or the network equipment etc.) executes the complete of each embodiment the method for the present invention
Portion or part.And storage medium above-mentioned include: USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory),
Random access memory (RAM, Random Access Memory), magnetic or disk etc. be various to can store program code
Medium.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention
Made any modifications, equivalent replacements, and improvements etc., should all be included in the protection scope of the present invention within mind and principle.