Summary of the invention
The embodiment of the present invention provides a kind of adaptive network method of attachment and system, and to two kinds of connected modes are provided for user, user can select wherein a kind of access way as required, thereby meets the demand that user is different.
The embodiment of the present invention provides a kind of adaptive network method of attachment, comprising:
The request message whether network interface of monitoring client has network to connect, if so, judges whether described request message is PADI message, if so, starts PPPoE server and connects for client provides PPPoE network; If not, starting Dynamic Host Configuration Protocol server connects for client provides DHCP network.
Wherein, describedly judge whether described request message is that PADI message specifically comprises: the type field and the code word segment value that obtain described request message, if the protocol type field of described request message is 0x8863, and code field is 0x09, and described request message is PADI message.
Further, if starting PPPoE server connects for client provides PPPoE network, when the packet transmitting in Sampling network after the successful connection of PPPoE network, if the packet detecting is the packet of PPPoE type, the described packet detecting is transmitted, if detect, packet is the packet of non-PPPoE type, by the described data packet discarding detecting, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864.
If starting Dynamic Host Configuration Protocol server connects for client provides DHCP network, when the packet transmitting in Sampling network after the successful connection of DHCP network, if the packet detecting is the packet of non-PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of the PPPoE type of non-PADI message, by the described data packet discarding detecting, if PADI message detected, disconnect DHCP network connect data path, and start PPPoE server for client provide PPPoE network connect; Wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, and described PADI message is that protocol type field is 0x8863, and the code field packet that is 0x09.
The embodiment of the present invention also provides a kind of adaptive network connected system, comprising:
Monitoring modular, the request message that whether has network to connect for monitoring the network interface of client, if so, sends to judge module by described request message;
Judge module, for judging whether described request message is PADI message, and sends to administration module by judged result;
Administration module, connects for client provides PPPoE network for start PPPoE server during for PADI message when described request message, starts Dynamic Host Configuration Protocol server and connect for client provides DHCP network in the time that described request message is not PADI message.
Wherein, described judge module obtains type field and the code field of described request message, if the protocol type field of described request message is 0x8863, and code field is 0x09, determines that described request message is PADI message.
Further, adaptive network connected system also comprises first detection module, is connected with described administration module; When described first detection module provides PPPoE network to connect for start PPPoE server when described administration module for client, if the successful connection of PPPoE network detects the packet transmitting in network, if the packet detecting is the packet of PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of non-PPPoE type, by the described data packet discarding detecting, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864.
Further, adaptive network connected system also comprises the second detection module, is connected with described administration module, when described the second detection module provides DHCP network to connect for start Dynamic Host Configuration Protocol server when described administration module for client, if the successful connection of DHCP network detects the packet transmitting in network, if the packet detecting is the packet of non-PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of the PPPoE type of non-PADI message, by the described data packet discarding detecting, if PADI message detected, disconnect the data path that DHCP network connects, and start PPPoE server for client provide PPPoE network connect, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, and described PADI message is that protocol type field is 0x8863, and the code word segment value packet that is 0x09.
The adaptive network method of attachment that the embodiment of the present invention provides adopts the request message that client is sent to monitor, and request message is identified, in the time that request message is PADI message, starting PPPoE server connects for client provides PPPoE network, if the unreal PADI message of request message, starts Dynamic Host Configuration Protocol server and connects for client provides DHCP network.Therefore, can carry out different networks according to the different demands of user connects; And DHCP network connector part is being set up in the adaptive network method of attachment that the embodiment of the present invention provides, if monitor PADI message, turn-off the data path that DHCP network connects, set up PPPoE network and connect, realize the switching that network connects.
Embodiment
The embodiment of the present invention provides a kind of adaptive network method of attachment and system, and to two kinds of connected modes are provided for user, user can select wherein a kind of access way as required, thereby meets the demand that user is different.
Before embodiments of the invention are specifically described, below the networking mode of DHCP and PPPoE is carried out to a simple explanation.
DHCP networking mode provides the mode of a set of Dynamic Acquisition and distributing IP address for the main frame on network.DHCP is divided into two parts: one is server end, and another is client.Server end is positioned at the far-end of network, and IP address assignment and management service are provided, and client is positioned at the PC for user.User's PC recognizes after network interface card, automatically starts dhcp client, automatically completes dhcp address application process.After dhcp client starts, search Dynamic Host Configuration Protocol server by sending DHCPDICOVER message, if stored dhcp server ip address, by sending other configuration parameters such as DHCPINFORM message application DNS (DomainName System, domain name system).
PPPoE networking mode is a kind of broadband access method, and it can provide a kind of cut-in method of point-to-point, and can authentication of users name and password, improves access security.PPPoE is divided into PPPoE server end and pppoe client.PPPoE server end provides IP address and the dns address of access, and the validity of authentication of users name and password.If user is by PPP over Ethernet access network, first start pppoe client, input username and password, then start to connect, pppoe client sends PADI(PPPoEActive Discovery Initiation, initiatively find initial package) message searches PPPoE server, starts PPPoE dialing procedure.
In order to make those skilled in the art person understand better the present invention program, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, rather than whole embodiment.Based on the embodiment in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, should belong to the scope of protection of the invention.
The embodiment of the present invention provides a kind of adaptive network method of attachment, comprising:
The request message whether network interface of monitoring client has network to connect, if so, judges whether described request message is PADI message, if so, starts PPPoE server and connects for client provides PPPoE network; If not, starting Dynamic Host Configuration Protocol server connects for client provides DHCP network.
It should be noted that, can know by the protocol type field of read requests message and code field the type of request message, if the protocol fields of request message is 0x8863, and code field is 0x09, this request message is PADI message, otherwise is DHCP DISCOVER or DHCP INFORM message.
When detecting after PADI message, search PPPoE server, client and PPPoE server carry out data interaction, complete the proof procedure of PPPoE dialing procedure and user name and password.After the request message detecting is non-PADI message, search Dynamic Host Configuration Protocol server, if and this request message is dhcp discover, Dynamic Host Configuration Protocol server is client distributing IP address and dns address, if this request message is DHCP INFORM message, Dynamic Host Configuration Protocol server is that client is distributed dns address.
Further, if starting Dynamic Host Configuration Protocol server connects for client provides DHCP network, when the packet transmitting in Sampling network after the successful connection of DHCP network, if the packet detecting is the packet of PPPoE type, the described packet detecting is transmitted, if detect, packet is the packet of non-PPPoE type, by the described data packet discarding detecting, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864.
If starting Dynamic Host Configuration Protocol server connects for client provides DHCP network, when the packet transmitting in Sampling network after the successful connection of DHCP network, if the packet detecting is the packet of non-PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of the PPPoE type of non-PADI message, by the described data packet discarding detecting, if PADI message detected, disconnect DHCP network connect data path, and start PPPoE server for client provide PPPoE network connect; Wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, and described PADI message is that protocol type field is 0x8863, and the code field packet that is 0x09.
It should be noted that, the PPPoE mode of dialling up on the telephone needs user to start pppoe client, then setting up PPPoE connects, this process just clearly shows that user is using which interconnection network, until initiatively disconnecting PPPoE, user connects, think the be through with interconnection network of which of user, therefore, in the adaptive network method of attachment that the invention process provides, the network connection priority of PPPoE dial mode connects higher than the network of DHCP mode, during PPPoE connects, do not respond the networking request of DHCP, but during DHCP connects, the networking request of response PPPoE.
Therefore, the adaptive network method of attachment that the embodiment of the present invention provides adopts the request message that client is sent to monitor, and request message is identified, in the time that request message is PADI message, starting PPPoE server connects for client provides PPPoE network, if request message is not PADI message, starts Dynamic Host Configuration Protocol server and connect for client provides DHCP network.Therefore, can carry out different networks according to the different demands of user connects; And the adaptive network method of attachment that the embodiment of the present invention provides, during setting up the connection of DHCP network, if monitor PADI message, is turn-offed the data path that DHCP network connects, and sets up PPPoE network and connects, realize the switching that network connects.
The embodiment of the present invention also provides a kind of adaptive network method of attachment, shown in Figure 1, comprising:
The request message whether network interface of S101, monitoring client has network to connect, if having, carries out step S102, if do not have, proceeds monitoring;
S102, judge whether the request message monitoring is PADI message;
Protocol type field by read requests message and code field can obtain the type of request message, if the protocol type field of request message is 0x8863, and code field is 0x09, this request message is the PADI message that request PPPoE network connects, otherwise, be dhcp discover or the DHCP INFORM message of the connection of request DHCP network.
S103a, in the time that the request message monitoring is PADI message, start PPPoE server and connect for client provides PPPoE network;
In the time setting up the connection of PPPoE network, select PPPoE data path, PPPoE data path has following functions:
A1, abandon the packet of all non-PPPoE types, prevent that flow from revealing;
A2, transmit the packet of all PPPoE types;
A3, PPPoE network connect after disconnection, forward S 101 to.
It should be noted that, the packet of PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, in addition, is all the packet of non-PPPoE type.
Connect in time-continuing process at PPPoE network, if the request message that DHCP network connects detected, this message may be DHCP DISCOVER or DHCP INFORM, now, this request message is abandoned, and continues the transmission of PPPoE categorical data report.
S103b, in the time that the request message monitoring is not PADI message, start Dynamic Host Configuration Protocol server for client provide DHCP network connect;
In the time setting up the connection of DHCP network, select DHCP data path, DHCP data path has following functions:
B1, abandon the packet of all PPPoE types, prevent that flow from revealing;
B2, transmit the packet of all non-PPPoE types;
B3, receive after PADI message, DHCP data path turn-offs, and opens PPPoE server, provides service to user.
Therefore, the request message that the adaptive network method of attachment that the embodiment of the present invention provides sends client is monitored and is identified, carrying out different networks according to the difference of request message connects, therefore the different demands of different users to internetwork connection mode have been met, can select to select adaptively internetwork connection mode according to user, and selecting a kind of internetwork connection mode to be connected to after network, if there is the data path of another internetwork connection mode, can forbid this data path transmission data, reach the beneficial effect that prevents that flow from revealing.
The embodiment of the present invention also provides a kind of adaptive network connected system, comprising:
Monitoring modular, the request message that whether has network to connect for monitoring the network interface of client, if so, sends to judge module by described request message;
Judge module, for judging whether described request message is PADI message, and sends to administration module by judged result;
Administration module, connects for client provides PPPoE network for start PPPoE server during for PADI message when described request message, starts Dynamic Host Configuration Protocol server and connect for client provides DHCP network in the time that described request message is not PADI message.
It should be noted that, described judge module obtains type field and the code field of described request message, if the protocol type field of described request message is 0x8863, and code field is 0x09, determines that described request message is PADI message;
Further, this adaptive network connected system can comprise first detection module, be connected with administration module, when first detection module provides PPPoE network to connect for start PPPoE server when administration module for client, if the successful connection of PPPoE network detects the packet transmitting in network, if the packet detecting is the packet of PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of non-PPPoE type, by the described data packet discarding detecting, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864.
Further, this adaptive network connected system can also comprise the second detection module, be connected with administration module, when the second detection module provides DHCP network to connect for start Dynamic Host Configuration Protocol server when administration module for client, if the successful connection of DHCP network detects the packet transmitting in network, if the packet detecting is the packet of non-PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of the PPPoE type of non-PADI message, by the described data packet discarding detecting, if PADI message detected, disconnect the data path that DHCP network connects, and start PPPoE server for client provide PPPoE network connect, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, and described PADI message is that protocol type field is 0x8863, and the code word segment value packet that is 0x09.
Therefore, judge module in the adaptive network connected system that the embodiment of the present invention provides to monitoring module monitors to request message distinguish, and in the time that request message is PADI message, starting PPPoE server by administration module connects for client provides PPPoE network, in the time that request message is not PADI message, administration module starts Dynamic Host Configuration Protocol server and connects for client provides DHCP network.Therefore, this adaptive network connected system can carry out different network connections according to the different demands of user.And, first detection module in the adaptive network connected system that the embodiment of the present invention provides and the second detection module can detect the datagram in Internet Transmission, unwanted packet is abandoned timely, reach the beneficial effect that prevents that flow from revealing, and the second detection module can receive after PADI message, turn-off adaptively the data path that DHCP network connects, start PPPoE server and connect for client provides PPPoE network, realized the switching that network connects.
The embodiment of the present invention also provides a kind of adaptive network connected system, described in Fig. 2, comprising:
Monitoring modular 201, the request message that whether has the network of client transmission to connect for detection of network interface end, if having, sends to judge module 202 by described request message;
Judge module 202, for judging whether the request message receiving is PADI message, and sends to administration module 203 by judged result;
Administration module 203, in the time that described request message is PADI message, starts PPPoE server and connects for client provides PPPoE network, in the time that described request message is not PADI message, starts Dynamic Host Configuration Protocol server and connects for client provides DHCP network.
Further, shown in Figure 3, the embodiment of the present invention also provides a kind of adaptive network connected system, this adaptive network connected system also comprises first detection module 204 and the second detection module 205 on the basis of the adaptive network connected system shown in Fig. 2, and described first detection module 204 is connected with administration module 203 respectively with the second detection module 205;
First detection module 204 is for when receiving after the signal of the PPPoE network successful connection that administration module 203 sends, the packet transmitting in network is detected, if the packet detecting is the packet of PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of non-PPPoE type,, by the described data packet discarding detecting, wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864;
The second detection module 205 is for when receiving after the signal of the DHCP network successful connection that administration module 203 sends, the packet transmitting in network is detected, if the packet detecting is the packet of non-PPPoE type, the described packet detecting is transmitted, if the packet detecting is the packet of the PPPoE type of non-PADI message, by the described data packet discarding detecting, if PADI message detected, disconnect DHCP network connect data path, and start PPPoE server for client provide PPPoE network connect; Wherein, the packet of described PPPoE type is that protocol type field is the packet of 0x8863 or 0x8864, and described PADI message is that protocol type field is 0x8863, and the code word segment value packet that is 0x09.
Therefore, the request message that judge module 202 in the adaptive network connected system that the embodiment of the present invention provides monitors monitoring modular 201 is distinguished, and in the time that request message is PADI message, starting PPPoE server by administration module 203 connects for client provides PPPoE network, in the time that request message is not PADI message, administration module 203 starts Dynamic Host Configuration Protocol server and connects for client provides DHCP network.Therefore, this adaptive network connected system can carry out different network connections according to the different demands of user.And the first detection module 204 in the embodiment of the present invention and the second detection module 205 carry out discard processing to packet unnecessary in Internet Transmission, reach the beneficial effect that prevents that flow from revealing.
One of ordinary skill in the art will appreciate that all or part of step in the whole bag of tricks of above-described embodiment is can carry out the hardware that instruction is relevant by program to complete, this program can be stored in a computer-readable recording medium, storage medium can comprise: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), disk or CD etc.
, in the above-described embodiments, the description of each embodiment is all emphasized particularly on different fields meanwhile, in certain embodiment, there is no the part of detailed description, can be referring to the associated description of other embodiment.
The adaptive network method of attachment and the system that above the embodiment of the present invention are provided are described in detail, applied specific case herein principle of the present invention and execution mode are set forth, the explanation of above embodiment is just for helping to understand method of the present invention and core concept thereof; , for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention meanwhile.