The content of the invention
The embodiment of the present invention provides a kind of adaptive network connection method and system, to provide the user two kinds of connection sides
Formula, user can select one of which access way as needed, so as to meet the different demand of user.
The embodiment of the present invention provides a kind of adaptive network connection method, including:
Whether the network interface of monitoring client has the request message of network connection, if so, whether then judging the request message
For PADI message, connected if so, then starting PPPoE servers and providing PPPoE network for client;If it is not, then starting DHCP clothes
Business device provides DHCP network connections for client.
Wherein, it is described to judge whether the request message is that PADI message is specifically included:Obtain the class of the request message
Type-word section and code word segment value, if the protocol type field of the request message is 0x8863, and code field is 0x09, then institute
Request message is stated for PADI message.
Further, if start PPPoE servers provides PPPoE network connection for client, when PPPoE network connection
The packet transmitted after success in detection network, if the packet detected is the packet of PPPoE types, to the detection
To packet be transmitted, if detect packet be non-PPPoE types packet, by the packet detected
Abandon, wherein, the packet of the PPPoE types is that protocol type field is 0x8863 or 0x8864 packet.
If start Dynamic Host Configuration Protocol server provides DHCP network connections for client, net is detected after DHCP network connections are successful
The packet transmitted in network, if the packet detected is the packet of non-PPPoE types, to the packet detected
It is transmitted, if the packet detected is the packet of the PPPoE types of non-PADI message, by the data detected
Bag is abandoned, if detecting PADI message, disconnects the data path of DHCP network connections, and starts PPPoE servers for client
End provides PPPoE network connection;Wherein, the packet of the PPPoE types be protocol type field be 0x8863 or
0x8864 packet, the PADI message is that protocol type field is 0x8863, and code field is 0x09 packet.
The embodiment of the present invention also provides a kind of adaptive network connection system, including:
Monitoring modular, for monitoring whether the network interface of client has the request message of network connection, if so, described will then ask
Message is asked to be sent to judge module;
Judge module, for judging whether the request message is PADI message, and will determine that result is sent to management mould
Block;
Management module, is provided for starting PPPoE servers when the request message is PADI message for client
PPPoE network is connected, and is started Dynamic Host Configuration Protocol server when the request message is not PADI message and is provided DHCP networks for client
Connection.
Wherein, the judge module obtains the type field and code field of the request message, if the request message
Protocol type field be 0x8863, and code field be 0x09, it is determined that the request message be PADI message.
Further, adaptive network connection system also includes first detection module, is connected with the management module;It is described
First detection module is used for when the management module starts PPPoE servers and provides PPPoE network connection for client, if
PPPoE network successful connection is then detected to the packet transmitted in network, if the packet detected is PPPoE types
Packet, then be transmitted to the packet detected, if the packet detected is the packet of non-PPPoE types,
Then by the data packet discarding detected, wherein, the packets of the PPPoE types be protocol type field be 0x8863 or
Person 0x8864 packet.
Further, adaptive network connection system also includes the second detection module, is connected with the management module;It is described
Second detection module is used for when the management module starts Dynamic Host Configuration Protocol server and provides DHCP network connections for client, if DHCP
Network connection success is then detected to the packet transmitted in network, if the packet detected is the number of non-PPPoE types
According to bag, then the packet detected is transmitted, if the packet detected is the PPPoE types of non-PADI message
Packet, then by the data packet discarding detected, if detecting PADI message, the data for disconnecting DHCP network connections are led to
Road, and start PPPoE servers for client provide PPPoE network connection;Wherein, the packet of the PPPoE types is association
The packet that type field is 0x8863 or 0x8864 is discussed, the PADI message is that protocol type field is 0x8863, and generation
Code word segment value is 0x09 packet.
Adaptive network connection method provided in an embodiment of the present invention uses the request message sent to client to supervise
Survey, and request message is identified, when request message is PADI message, then starts PPPoE servers and provided for client
PPPoE network is connected, if the unreal PADI message of request message, is started Dynamic Host Configuration Protocol server and is provided DHCP networks company for client
Connect.It therefore, it can carry out different network connections according to user's different demands;And adaptive net provided in an embodiment of the present invention
DHCP network connection devices are being set up in network connection method, if monitoring PADI message, and the data of shut-off DHCP network connections are led to
Road, sets up PPPoE network connection, realizes the switching of network connection.
Embodiment
The embodiment of the present invention provides a kind of adaptive network connection method and system, to provide the user two kinds of connection sides
Formula, user can select one of which access way as needed, so as to meet the different demand of user.
Before embodiments of the invention are specifically described, one is carried out to DHCP and PPPoE networking mode below
Individual simple illustration.
DHCP networking modes provide the mode of a set of dynamic access and distribution IP address for the main frame on network.DHCP points are
Two parts:One is server end, and another is client.There is provided IP address distribution positioned at the distal end of network for server end
And management service, client, which is located at, is used for the PC of user.User's PC is recognized after network interface card, automatic start dhcp client,
It is automatically performed dhcp address application process.After dhcp client starts, DHCP service is searched by sending DHCPDICOVER message
Device, if having stored dhcp server ip address, by sending DHCPINFORM message application DNS (DomainName
System, domain name system) etc. other configurations parameter.
PPPoE networking modes are a kind of broadband access methods, and it can provide a kind of cut-in method of point-to-point, and can
To verify username and password, access safety is improved.PPPoE points are PPPoE server ends and pppoe client.PPPoE is serviced
Device end provides the IP address and dns address of access, and verifies the validity of username and password.If user passes through PPPoE
Mode access network, starts pppoe client first, inputs username and password, then starts connection, pppoe client hair
Send PADI(PPPoEActive Discovery Initiation, are actively discovered initial bag)Message searches PPPoE servers, opens
Beginning PPPoE dialing procedure.
In order that those skilled in the art more fully understand the present invention program, below in conjunction with the embodiment of the present invention
Accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is only
The embodiment of a part of the invention, rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill people
The every other embodiment that member is obtained under the premise of creative work is not made, should all belong to the model that the present invention is protected
Enclose.
The embodiment of the present invention provides a kind of adaptive network connection method, including:
Whether the network interface of monitoring client has the request message of network connection, if so, whether then judging the request message
For PADI message, connected if so, then starting PPPoE servers and providing PPPoE network for client;If it is not, then starting DHCP clothes
Business device provides DHCP network connections for client.
It should be noted that request message can be known by the protocol type field and code field of read requests message
Type, if the protocol fields of request message be 0x8863, and code field be 0x09, then the request message be PADI message,
Otherwise it is DHCP DISCOVER or DHCP INFORM message.
After PADI message is detected, PPPoE servers are searched, client carries out data interaction with PPPoE servers, complete
Into PPPoE dialing procedures and user name and the verification process of password.After the request message detected is non-PADI message, then look into
Dynamic Host Configuration Protocol server is looked for, and if the request message is DHCPDISCOVER message, Dynamic Host Configuration Protocol server is client distribution IP
Location and dns address, if the request message is DHCP INFORM message, Dynamic Host Configuration Protocol server is that client distributes dns address.
Further, if start Dynamic Host Configuration Protocol server provide DHCP network connections for client, when DHCP network connections into
The packet transmitted in network is detected after work(, if the packet detected is the packet of PPPoE types, is detected to described
Packet be transmitted, if detect packet be non-PPPoE types packet, the packet detected is lost
Abandon, wherein, the packet of the PPPoE types is that protocol type field is 0x8863 or 0x8864 packet.
If start Dynamic Host Configuration Protocol server provides DHCP network connections for client, net is detected after DHCP network connections are successful
The packet transmitted in network, if the packet detected is the packet of non-PPPoE types, to the packet detected
It is transmitted, if the packet detected is the packet of the PPPoE types of non-PADI message, by the data detected
Bag is abandoned, if detecting PADI message, disconnects the data path of DHCP network connections, and starts PPPoE servers for client
End provides PPPoE network connection;Wherein, the packet of the PPPoE types be protocol type field be 0x8863 or
0x8864 packet, the PADI message is that protocol type field is 0x8863, and code field is 0x09 packet.
It should be noted that the PPPoE modes of dialling up on the telephone need user to start pppoe client, PPPoE companies are then set up
Connect, the process just clearly indicates that user is connecting network using which, until user actively disconnects PPPoE connections, it is believed that use
Family finishes the connection network of which, therefore, PPPoE dialing parties in the adaptive network connection method that present invention implementation is provided
The network connection priority of formula is higher than the network connection of DHCP modes, i.e., during PPPoE connections, and the networking for being not responding to DHCP please
Ask, but during DHCP connections, response PPPoE networking request.
Therefore, adaptive network connection method provided in an embodiment of the present invention uses the request sent to client to disappear
Breath is monitored, and request message is identified, and when request message is PADI message, then it is visitor to start PPPoE servers
Family end provides PPPoE network connection, if request message is not PADI message, starts Dynamic Host Configuration Protocol server and provides DHCP for client
Network connection.It therefore, it can carry out different network connections according to user's different demands;And it is provided in an embodiment of the present invention from
Method for connecting network is adapted to during DHCP network connections are set up, if monitoring PADI message, shut-off DHCP network connections
Data path, sets up PPPoE network connection, realizes the switching of network connection.
The embodiment of the present invention also provides a kind of adaptive network connection method, shown in Figure 1, including:
Whether S101, the network interface of monitoring client have the request message of network connection, if so, step S102 is then carried out, if
No, then monitoring is proceeded;
Whether the request message that S102, judgement are monitored is PADI message;
The type of request message can be obtained by the protocol type field and code field of read requests message, if request
The protocol type field of message is 0x8863, and code field is 0x09, then the request message is request PPPoE network connection
PADI message, otherwise, to ask the DHCPDISCOVER message or DHCP INFORM message of DHCP network connections.
S103a, when the request message monitored be PADI message when, start PPPoE servers provide PPPoE for client
Network connection;
When setting up PPPoE network connection, PPPoE data paths are selected, PPPoE data paths have following functions:
A1, the packet for abandoning all non-PPPoE types, prevent flow from revealing;
A2, all PPPoE types of transmission packet;
After a3, PPPoE network connection disconnect, S 101 is gone to.
It should be noted that it is 0x8863 or 0x8864 data that the packet of PPPoE types, which is protocol type field,
Bag, in addition, the packet all for non-PPPoE types.
In PPPoE network connection time-continuing process, if detecting the request message of DHCP network connections, the message is probably
DHCP DISCOVER or DHCP INFORM, now, the request message is abandoned, and continues the transmission of PPPoE categorical data reports.
S103b, when the request message monitored is not PADI message, start Dynamic Host Configuration Protocol server provide DHCP for client
Network connection;
When setting up DHCP network connections, DHCP data paths are selected, DHCP data paths have following functions:
B1, the packet for abandoning all PPPoE types, prevent flow from revealing;
B2, all non-PPPoE types of transmission packet;
B3, receive after PADI message, the shut-off of DHCP data paths opens PPPoE servers, provides the user with service.
Therefore, the request message that adaptive network connection method provided in an embodiment of the present invention is sent to client enters
Row monitoring and identification, different network connections are carried out according to the difference of request message, therefore meet different users to network
The different demands of connected mode, can be adaptive selected internetwork connection mode, and have selected one kind according to user's selection
Internetwork connection mode is connected to after network, if there is the data path of another internetwork connection mode, can forbid the data
Tunnel data, have reached the beneficial effect for preventing that flow from revealing.
The embodiment of the present invention also provides a kind of adaptive network connection system, including:
Monitoring modular, for monitoring whether the network interface of client has the request message of network connection, if so, described will then ask
Message is asked to be sent to judge module;
Judge module, for judging whether the request message is PADI message, and will determine that result is sent to management mould
Block;
Management module, is provided for starting PPPoE servers when the request message is PADI message for client
PPPoE network is connected, and is started Dynamic Host Configuration Protocol server when the request message is not PADI message and is provided DHCP networks for client
Connection.
It should be noted that the judge module obtains the type field and code field of the request message, if described
The protocol type field of request message is 0x8863, and code field is 0x09, it is determined that the request message is PADI message;
Further, adaptive network connection system can include first detection module, be connected with management module, first
Detection module is used for when management module starts PPPoE servers and provides PPPoE network connection for client, if PPPoE network
Successful connection is detected to the packet transmitted in network, right if the packet detected is the packet of PPPoE types
The packet detected is transmitted, if the packet detected is the packet of non-PPPoE types, by the detection
The data packet discarding arrived, wherein, the packet of the PPPoE types is that protocol type field is 0x8863 or 0x8864 number
According to bag.
Further, adaptive network connection system can also include the second detection module, be connected with management module,
Second detection module is used for when management module starts Dynamic Host Configuration Protocol server and provides DHCP network connections for client, if DHCP networks
Successful connection is then detected to the packet transmitted in network, if the packet detected is the packet of non-PPPoE types,
Then the packet detected is transmitted, if the packet detected is the data of the PPPoE types of non-PADI message
Bag, then by the data packet discarding detected, if detecting PADI message, disconnect the data path of DHCP network connections,
And start PPPoE servers for client provide PPPoE network connection;Wherein, the packet of the PPPoE types is protocol class
The packet that type-word section is 0x8863 or 0x8864, the PADI message is that protocol type field is 0x8863, and code word
Segment value is 0x09 packet.
Therefore, the judge module in adaptive network connection system provided in an embodiment of the present invention is supervised to monitoring modular
The request message measured makes a distinction, and when request message is PADI message, it is visitor to start PPPoE servers by management module
Family end provides PPPoE network connection, when request message is not PADI message, and it is client that management module, which starts Dynamic Host Configuration Protocol server,
DHCP network connections are provided.Therefore, adaptive network connection system can carry out different networks according to user's different demands
Connection.Also, first detection module and the second detection module in adaptive network connection system provided in an embodiment of the present invention
Datagram in network transmission can be detected, unwanted packet is timely abandoned, reach anti-fluid stopping
The beneficial effect of leakage is measured, and the second detection module can adaptively turn off DHCP networks after PADI message is received
The data path of connection, starts PPPoE servers and provides PPPoE network connection for client, realize the switching of network connection.
The embodiment of the present invention also provides a kind of adaptive network connection system, referring to described in Fig. 2, including:
Monitoring modular 201, the request message for detecting the network connection whether network interface end has client to send, if so,
The request message is then sent to judge module 202;
Judge module 202, whether the request message for judging to receive is PADI message, and will determine that result is sent to
Management module 203;
Management module 203, for when the request message is PADI message, starting PPPoE servers and being carried for client
For PPPoE network connection, when the request message is not PADI message, then starts Dynamic Host Configuration Protocol server and provide DHCP for client
Network connection.
Further, shown in Figure 3, the embodiment of the present invention also provides a kind of adaptive network connection system, and this is adaptive
Network connection system is answered also to include first detection module 204 and the on the basis of the adaptive network connection system shown in Fig. 2
Two detection modules 205, the detection module 205 of first detection module 204 and second is connected with management module 203 respectively;
First detection module 204 is used for when the signal for the PPPoE network successful connection for receiving the transmission of management module 203
Afterwards, the packet transmitted in network is detected, if the packet detected is the packet of PPPoE types, to described
The packet detected is transmitted, if the packet detected is the packet of non-PPPoE types, is detected described
Data packet discarding, wherein, the packet of the PPPoE types is that protocol type field is 0x8863 or 0x8864 data
Bag;
Second detection module 205 is used for after the DHCP network connections for receiving the transmission of management module 203 successful signal,
The packet transmitted in network is detected, if the packet detected is the packet of non-PPPoE types, to the inspection
The packet measured is transmitted, if the packet detected is the packet of the PPPoE types of non-PADI message, will be described
The data packet discarding detected, if detecting PADI message, disconnects the data path of DHCP network connections, and start PPPoE
Server provides PPPoE network connection for client;Wherein, the packet of the PPPoE types is that protocol type field is
0x8863 or 0x8864 packet, the PADI message is that protocol type field is 0x8863, and code word segment value is
0x09 packet.
Therefore, 202 pairs of monitoring moulds of judge module in adaptive network connection system provided in an embodiment of the present invention
The request message that block 201 is monitored is made a distinction, and when request message is PADI message, PPPoE is started by management module 203
Server provides PPPoE network connection for client, when request message is not PADI message, and management module 203 starts DHCP
Server provides DHCP network connections for client.Therefore, adaptive network connection system can be according to user's different demands
Carry out different network connections.And the detection module 205 of first detection module 204 and second in the embodiment of the present invention is to network
Unnecessary packet carries out discard processing in transmission, has reached the beneficial effect for preventing that flow from revealing.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment is can
To instruct the hardware of correlation to complete by program, the program can be stored in a computer-readable recording medium, storage
Medium can include:Read-only storage(ROM, Read Only Memory), random access memory(RAM, Random
Access Memory), disk or CD etc..
Meanwhile, in the above-described embodiments, the description to each embodiment all emphasizes particularly on different fields, and is not described in detail in some embodiment
Part, may refer to the associated description of other embodiment.
The adaptive network connection method provided above the embodiment of the present invention and system are described in detail, herein
In apply specific case the principle and embodiment of the present invention be set forth, the explanation of above example is only intended to side
The method and its core concept of the assistant solution present invention;Simultaneously for those of ordinary skill in the art, the think of according to the present invention
Think, will change in specific embodiments and applications, in summary, this specification content should not be construed as pair
The limitation of the present invention.