# Patent

## Title
System and method for selecting layer-2 adapter

## Abstract

The present invention relates to a Layer 2 adapter selecting system, including a Layer 3 packet requirements extracting module, a destination Layer 2 address acquiring module, a Layer 2 adapter metric acquiring module, an appropriate Layer 2 adapter identifier selecting module, a packet caching module and a packet scheduling module; wherein the packet caching module is configured to cache a received Layer 3 packet; the Layer 3 packet requirements extracting module is configured to read the Layer 3 packet and extract the type and a parameter value of the requirements; the Layer 2 adapter metric acquiring module is configured to acquire instant metric parameter values of each of the adapters; the appropriate Layer 2 adapter identifier selecting module calculates an adapter identifier and a Layer 3 packet metric; the destination Layer 2 address acquiring module is configured to acquire a Layer 2 address of each of the adapters associated with a destination Layer 3 address; and the packet scheduling module calls an external Layer 2 adapter driver, and the Layer 2 adapter driver completes packaging and sending of the packet. The present invention may solve the problem of resource waste of multiple links, so that the multiple links may be used dynamically in parallel.

## Background
FIELD OF THE INVENTION
The present invention relates to the field of network communications, and particularly, relates to a Layer 2 adapter selecting system and method.
BACKGROUND OF THE INVENTION
With the rapid development of internet, network operators generally deploy redundant links in consideration of network reliability, and the redundant links have two types, namely homogeneous ones and heterogeneous ones. Whatever type of redundant links is adopted, the redundant links and original ones are not included within the same transmission path; and under normal conditions, only one of two or more links between a source and a destination runs normally, so, huge waste of the link resources will be caused.
If the redundant links are arranged in a network, multiple Layer 2 adapters need to be provided at the source and the destination, but the protocols used on the layers above Layer 2 are the same. In addition, multiple adapters have been provided in terminals in practice. Accordingly, under packet switching manner, the problem of selecting the multiple Layer 2 adapters will occur. In the prior art, if the multiple Layer 2 adapters have the same Layer 3 address, then only one adapter is activated within a time period in the selecting process of the Layer 2 adapters, which leads to the waste of the link resources.
SUMMARY OF THE INVENTION
To overcome the problem that the selecting methods of the existing Layer 2 adapters are prone to cause waste of link resources, the present invention provides a Layer 2 adapter selecting system and method.
To fulfill the above-mentioned object, the present Layer 2 adapter selecting system includes: a Layer 3 packet requirements extracting module, a destination Layer 2 address acquiring module, a Layer 2 adapter metric acquiring module, an appropriate Layer 2 adapter identifier selecting module, a packet caching module and a packet scheduling module; wherein,
the packet caching module is configured to cache a received Layer 3 packet;
the Layer 3 packet requirements extracting module is configured to read the Layer 3 packet from the packet caching module, extract the type and parameter value of a requirements from the Layer 3 packet and transmit the obtained results to the appropriate Layer 2 adapter identifier selecting module;
the Layer 2 adapter metric acquiring module is configured to acquire instant metric parameter values of each of the adapters and transmit the obtained results to the appropriate Layer 2 adapter identifier selecting module;
the appropriate Layer 2 adapter identifier selecting module calculates an adapter identifier and a Layer 3 packet metric according to the type and parameter value of the requirements calculated by the Layer 3 packet requirements extracting module and each adapter metric value calculated by the Layer 2 adapter metric acquiring module, transmits the resulted adapter identifier and the Layer 3 packet metric to the packet scheduling module, determines the link corresponding to the adapter is a unidirectional link or a bidirectional link according to the obtained adapter identifier, and if the link is a unidirectional link, then performs parameter negotiation through a bidirectional link to obtain a unidirectional link destination address mapping parameter, and transmits the mapping parameter to an external destination Layer 2 adapter through the bidirectional link;
the destination Layer 2 address acquiring module is configured to acquire a Layer 2 address of each of the adapters associated with a destination Layer 3 address;
the packet scheduling module calls an external Layer 2 adapter driver according to the adapter identifier and Layer 3 packet metric obtained by the appropriate Layer 2 adapter identifier selecting module, wherein the Layer 2 adapter driver performs packaging and sending of the packet.
In the above technical solution, when the destination Layer 2 address acquiring module acquires the Layer 2 address of a destination adapter, if a data link is a bidirectional link, the source adapter interacts with the destination adapter through a Layer 2 data frame to obtain the Layer 2 address of the destination adapter; and if a data link is a unidirectional link, then the source and destination of another bidirectional link perform parameter negotiation to obtain a mapping parameter of the unidirectional link destination, after which the source transmits the mapping parameter of the unidirectional link destination to the destination through the bidirectional link.
In the above technical solution, the requirements is an metric to be satisfied for the packet transmission.
The present invention also provides a Layer 2 adapter selecting method implemented on the present Layer 2 adapter selecting system, which includes:
Step 1): after a Layer 3 packet is received, extracting the requirements from the received Layer 3 packet to obtain the type and the parameter value of the requirements;
step 2): acquiring the instant metric parameter values of each of the adapters;
step 3): calculating an adapter identifier and a Layer 3 packet metric according to the type and parameter value of the requirements obtained in step 1) and the metric parameter values of each of the adapters obtained in step 2);
step 4): scheduling the Layer 3 packet according to the adapter identifier and Layer 3 packet metric obtained in step 3) so as to call a corresponding Layer 2 adapter driver;
step 5): judging the link corresponding to each of the adapters is a unidirectional link or a bidirectional link, if the link is a unidirectional link, executing step 6), otherwise, executing step 7);
step 6): performing parameter negotiation through the source and the destination of a bidirectional link to obtain a unidirectional link destination address mapping parameter, after which the source sending the obtained address mapping parameter to a destination Layer 2 adapter through the bidirectional link, and then executing step 8);
step 7): the source adapter and the destination adapter interacting with each other through a Layer 2 data frame, so as to obtain a Layer 2 address of the destination adapter;
step 8): the Layer 2 adapter driver of the source adapter performing the packaging and sending of the packet.
In the above method, step 1) includes:
the packaging and sending of the packet.
In the above method, step 1) includes:
step 1-1): extracting the requirements field from the header of the Layer 3 packet;
step 1-2): extracting the type of the requirements from the requirements field, and if the requirements is of a single type, then decomposing the requirements field to obtain a single parameter; and if the requirements is of a composite type, then decomposing the requirements field to obtain a plurality of parameters, further running an algorithm involving each of the obtained parameters to obtain a single dimensionless value.
In the above method, in step 2), acquiring the instant metric parameter values of each of the adapters includes obtaining, from the Layer 2 adapter driver, various indices of a Layer 2 adapter link channel, including average packet transmission time, link rate and packet loss rate.
In the above method, step 3) includes:
Implementing an function on the single metric or calculated composite indices of each Layer 2 adapter obtained in step 2) according to the type and parameter value of the requirements obtained in step 1) to obtain an identifier of the Layer 2 adapter meeting the requirements; wherein, the function is a scalar-type function in the form ƒ=fun(x1, x2, . . . , xn), wherein fun is a single-valued function, and x1, x2 . . . xn represent the indices of the Layer 2 adapter.
The advantages of the present invention lie in that the Layer 2 adapter selecting system and method in the present invention overcomes the problem of waste of multiple link resources so that the multiple links



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a structural diagram of a Layer 2 adapter selecting system of the present invention;
FIG. 2 is a flowchart of a Layer 2 adapter selecting method of the present invention; and
FIG. 3 is a schematic diagram of a scenario described in an embodiment.



DETAILED DESCRIPTION OF THE EMBODIMENT
The present invention will be further described in conjunction with the accompanying drawings now.
With reference to FIG. 1, a Layer 2 adapter selecting system of the present invention includes core modules and auxiliary modules, wherein the core modules include a Layer 3 packet requirements extracting module, a destination Layer 2 address acquiring module, a Layer 2 adapter metric acquiring module and an appropriate Layer 2 adapter identifier selecting module; and the auxiliary modules include a packet caching module and a packet scheduling module.
The packet caching module is configured to cache a received Layer 3 packet.
The Layer 3 packet requirements extracting module is configured to read the Layer 3 packet from the packet caching module, extract the type of and parameter value of the requirements from the Layer 3 packet and transmit the obtained results to the appropriate Layer 2 adapter identifier selecting module. Wherein, the requirements refers to indices to be satisfied for the packet transmission, such as the shortest transmission time, the maximum bandwidth and lowest packet loss rate, or transmission time threshold, bandwidth threshold and packet loss rate threshold, or a function value obtained after each of the parameters are calculated, and the like.
The Layer 2 adapter metric acquiring module is configured to acquire instant metric parameter values of each of the adapters and transmit the obtained results to the appropriate Layer 2 adapter identifier selecting module.
The appropriate Layer 2 adapter identifier selecting module calculates an adapter identifier and a Layer 3 packet metric according to the type and parameter value of the requirements calculated by the Layer 3 packet requirements extracting module and each adapter metric value calculated by the Layer 2 adapter metric acquiring module, transmits the adapter identifier and the Layer 3 packet metric to the packet scheduling module, determines the link corresponding to the adapter is a unidirectional link or a bidirectional link according to the obtained adapter identifier, and if the link is a unidirectional link, then performs parameter negotiation through a bidirectional link so as to obtain a unidirectional link destination address mapping parameter, and sends the mapping parameter to an external destination Layer 2 adapter through the bidirectional link, so that the destination can implement a receiving operation. However, if the link is a bidirectional link, the parameter negotiation operation is not needed.
The destination Layer 2 address acquiring module is configured to acquire a Layer 2 address of each of the adapters associated with a destination Layer 3 address. When the destination Layer 2 address acquiring module acquires the Layer 2 address of a destination adapter, if a data link is a bidirectional link, the a source adapter interacts with the destination adapter through a Layer 2 data frame to obtain the Layer 2 address of the destination adapter; and if a data link is a unidirectional link, then the source and destination of another bidirectional link perform parameter negotiation to obtain a mapping parameter of the unidirectional link destination, after which the source transmits the mapping parameter of the unidirectional link destination to the destination through the bidirectional link.
The packet scheduling module calls an external Layer 2 adapter driver according to the adapter identifier and Layer 3 packet metric obtained by the appropriate Layer 2 adapter identifier selecting module, and the Layer 2 adapter driver performs the packaging and sending of the packet.
The Layer 2 adapter selecting system of the present invention has been described above, and a corresponding Layer 2 adapter selecting method will be illustrated below based on the system in conjunction with FIG. 2.
Step 1): after a Layer 3 packet is received, extracting a requirements from the received Layer 3 packet to obtain the type and the parameter value of the requirements;
the requirements refers to indices to be satisfied for the packet transmission, such as the shortest transmission time, the maximum bandwidth and lowest packet loss rate, or transmission time threshold, bandwidth threshold and packet loss rate threshold, or a function value obtained after each of the parameters are calculated, and the like.
step 2): acquiring the instant metric parameter values of each of the adapters;
step 3): calculating an adapter identifier and a Layer 3 packet metric according to the type and parameter value of the requirements obtained in step 1) and the metric parameter values of each of the adapters obtained in step 2);
step 4): scheduling the Layer 3 packet according to the adapter identifier and Layer 3 packet metric obtained in step 3) so as to call a corresponding Layer 2 adapter driver;
step 5): judging the link corresponding to each of the adapters is a unidirectional link or a bidirectional link, if the link is a unidirectional link, executing step 6), otherwise, executing step 7);
step 6): performing parameter negotiation through the source and the destination of a bidirectional link to obtain a unidirectional link destination address mapping parameter, after which the source sending the obtained address mapping parameter to a destination Layer 2 adapter through the bidirectional link, and then executing step 8);
step 7): the source adapter and the destination adapter interacting with each other through a Layer 2 data frame, so as to obtain a Layer 2 address of the destination adapter;
step 8): the Layer 2 adapter driver of the source adapter performing the packaging and sending of the packet.
The present method has been described in general as above, and some of the steps therein will be described further in the following.
Step 1) includes:
step 1-1): extracting the requirements field from the header of the Layer 3 packet;
step 1-2): extracting the type of the requirements from the requirements field, and if the requirements is of a single type, then decomposing the requirements field to obtain a single parameter; and if
step 1-2): extracting the type of the requirements from the requirements field, and if the requirements is of a single type, then decomposing the requirements field to obtain a single parameter; and if the requirements is of a composite type, then decomposing the requirements field to obtain a plurality of parameters, further running an algorithm involving each of the obtained parameters to obtain a single dimensionless value.
Step 2) includes: obtaining, from the Layer 2 adapter driver, various indices of a Layer 2 adapter link channel, including average packet transmission time, link rate and packet loss rate.
Step 3) includes:
Implementing an function on the single metric or calculated composite indices of each Layer 2 adapter obtained in step 2) according to the type and parameter value of the requirements obtained in step 1) to obtain an identifier of the Layer 2 adapter meeting the requirements; wherein, the function is a scalar-type function in the form ƒ=fun(x1, x2, . . . , xn), wherein fun is a single-valued function, and X1, x2 . . . xn represent the indices of the Layer 2 adapter.
The Layer 2 adapter selecting method of the present invention will be illustrated below in conjunction with a scenario of FIG. 3. In this scenario, the source is provided with three adapters A1, A2 and A3, which are 802.11b(WiFi) modulator, DOCSIS 1.0 modulator and unidirectional HFC QAM modulator respectively, whose interface rates are 11 Mbps, 30 Mbps and 38 Mbps respectively. Assuming the Layer 3 packet is an IP packet (may also be another type, such as IPX), the requirements, such as the maximum bandwidth (the bandwidth is taken as an example for selected, so the adapter identifier is A3. At the same time, adapter A3 is decided as connected to a unidirectional link, so corresponding unidirectional received parameters (such as a frequency point and a PID, the process of determining these parameters relates to negotiation of a bidirectional adapter such as the A2 and a destination adapter) of a destination are transmitted to the destination through the bidirectional adapter A2, thereafter the IP packet is sent to the adapter A3, which will encapsulate and send the Layer 2 packet.
It should be noted that the preceding embodiments are merely used for illustrating the technical solutions of the present invention, rather than limiting the present invention. Though the present invention is illustrated in detail with reference to the preceding embodiments, it should be understood by those of ordinary skill in the art that modifications or equivalent substitutions may be made to the technical solutions of the present invention, and these modifications or substitutions do not depart from the spirit and scope of the technical solutions of the present invention and should fall into the scope of the claims of the present invention

## Claims

1. A method for selecting between Layer 2 adapters, the method comprising:
caching a received Layer 3 packet;
reading the Layer 3 packet;
extracting the type and parameter value of a requirements from the Layer 3 packet;
transmitting the obtained results;
acquiring instant metric parameter values of each of the Layer 2 adapters;
transmitting obtained results;
calculating an adapter identifier and a Layer 3 packet metric according to the extracted type and parameter value of the requirements and each calculated adapter metric value, transmitting the resultant adapter identifier and the Layer 3 packet metric, determining whether a link corresponding to an external destination Layer 2 adapter is a unidirectional link or a bidirectional link according to the obtained adapter identifier, and if the link is a unidirectional link, performing parameter negotiation through a bidirectional link to obtain a unidirectional link destination address mapping parameter, and transmitting the mapping parameter to an external destination Layer 2 adapter through the bidirectional link;
acquiring a Layer 2 address of each adapter associated with a destination Layer 3 address;
calling an external Layer 2 adapter driver according to the adapter identifier and Layer 3 packet metric, wherein the Layer 2 adapter driver performs packaging and sending of the packet.

2. The method according to claim 1, wherein, when a Layer 2 address of a destination adapter is acquired, if a data link is a bidirectional link, then a source adapter interacts with the destination adapter through a Layer 2 data frame to obtain the Layer 2 address of the destination adapter; and if a data link is a unidirectional link, the source and destination of an other bidirectional link perform parameter negotiation to obtain a mapping parameter of the unidirectional link, after which the source transmits the mapping parameter of the unidirectional link destination to the destination through the other bidirectional link.

3. The method according to claim 1, wherein the requirements is a metric to be satisfied for the packet transmission.

4. A Layer 2 adapter selecting method, the method including:
after a Layer 3 packet is received, extracting the requirements from the received Layer 3 packet to obtain the type and the parameter value of the requirements;
acquiring the instant metric parameter values of each of the adapters;
calculating an adapter identifier and a Layer 3 packet metric according to the type and parameter value of the requirements obtained during extracting and the acquired instant metric parameter values of each of the adapters;
scheduling the Layer 3 packet according to the calculated adapter identifier and Layer 3 packet metric to call a corresponding Layer 2 adapter driver;
determining if the link corresponding to each of the adapters is a unidirectional link or a bidirectional link,
if the link is a unidirectional link, performing parameter negotiation through the source and the destination of a bidirectional link to obtain a unidirectional link destination address mapping parameter, after which the source sending the obtained address mapping parameter to a destination Layer 2 adapter through the bidirectional link; or
if the link is a unidirectional link, the source adapter and the destination adapter interacting with each other through a Layer 2 data frame to obtain a Layer 2 address of the destination adapter; and
packaging and sending of the packet by the Layer 2 adapter driver of the source adapter.

5. The method according to claim 4, wherein extracting the requirements from the received Layer 3 packet includes:
extracting the requirements field from the header of the Layer 3 packet; and
extracting the type of the requirements from the requirements field, wherein if the requirements is of a single type, decomposing the requirements field to obtain a single parameter; and if the requirements is of a composite type, decomposing the requirements field to obtain a plurality of parameters, further running an algorithm involving each of the obtained parameters to obtain a single dimensionless value.

6. The method according to claim 4, wherein acquiring the instant metric parameter values of each of the adapters includes obtaining, from the Layer 2 adapter driver, various indices of a Layer 2 adapter link channel, including average packet transmission time, link rate and packet loss rate.

7. The method according to claim 4, wherein calculating an adapter identifier and a Layer 3 packet metric includes:
implementing a function algorithm on single metric or calculated composite indices acquired for each Layer 2 according to the extracted type and parameter value of the requirements to obtain an identifier of the Layer 2 adapter meeting the requirements; wherein, the function algorithm is a scalar-type function ƒ=fun(x1, x2, . . . , xn), wherein fun is a single-valued function, and x1, x2 . . . xn represent indices of the Layer 2 adapter.