Summary of the invention
Goal of the invention of the present invention provides a kind of router network access detection method, and router detects network access after inserting the Internet automatically, instructs the host subscriber to finish the network service setting.
The present invention in order to realize the technical scheme that its goal of the invention adopts is: a kind of router network access detection method, after router is drawn in the Internet, the network access of the Internet is detected automatically, and may further comprise the steps:
A, carry out pppoe discovery process, confirm whether the internet connection type is pppoe, if detection of end instructs the host subscriber to fill in right user name and password, enters the PPP session stage, otherwise enters step B;
B, carry out dhcp discovery process, confirm whether the internet connection type is dhcp, if detection of end notifies the host subscriber to enter the dhcp session stage, otherwise, enter step C;
C, affirmation internet connection type are static IP, and guide the host subscriber correctly to fill in the IP address, mask, and gateway information finishes.
Further, in above-mentioned a kind of router network access detection method: in the described steps A, follow these steps to finish pppoe discovery process:
A01, router send Initial message (PADI) with broadcast mode, and accumulative total sends the number of times of Initial message (PADI), surpass setting above set point number if send the number of times of Initial message (PADI) this moment, then determine it is not the PPPOE network access, detection of end;
A02, router receive all PPPOE servers and reply effective discovery in the mode of clean culture message (PADO) is provided, if do not receive in first setting-up time then return steps A 01;
A03, the selected server end of router, and send with the clean culture send mode and to find that effectively request message (PADR) gives described selected service end, and accumulative total sends the number of times of effectively finding request message (PADR), surpass set point number if send the number of times of effectively finding request message (PADR), then change steps A 01 over to;
A04, router receive the clean culture confirmation message PADS that described selected service end sends, if do not receive in second time of setting, then change steps A 03 over to;
A05, router send and effectively stop bag (PADT), are defined as the PPOE network access, detection of end.
Further, in above-mentioned a kind of router network access detection method: in the described steps A 01: the set point that sends the number of times of Initial message (PADI) is 3 times; In the described steps A 02, when sending Initial message (PADI) for the first time, first setting-up time is 5 seconds, when sending Initial message (PADI) for the second time, first setting-up time is 10 seconds, and when sending Initial message (PADI) for the third time, first setting-up time is 20 seconds.
Further, in above-mentioned a kind of router network access detection method: in the described steps A 01: in the described steps A 03: sending the set point of effectively finding the number of times of request message (PADR) is 3 times; In the described steps A 04, send for the first time when effectively finding request message (PADR), second setting-up time is 5 seconds, send for the second time when effectively finding request message (PADR), second setting-up time is 10 seconds, send for the third time when effectively finding request message (PADR), second setting-up time is 20 seconds.
Further, in above-mentioned a kind of router network access detection method: be to finish dhcp discovery process among the described step B by following step:
B01, router send dhcp discover package in the mode of broadcasting;
B02, router receive the dhcp offer package that the dhcp server is beamed back, do not receive dhcp offer package if wait for 2 seconds, then router sends dhcp discover package again in the mode of broadcasting, waits for 4 seconds again, does not also receive dhcp offer package if wait for 4 seconds, router sends dhcp discover package in the mode of broadcasting, wait for 6 seconds again, also do not receive dhcp offer package, just no longer give out a contract for a project if wait for 6 seconds, judge it is not the dhcp connection type, finish;
B03, the selected dhcp server of router, and broadcasting dhcp request package tell all dhcp servers will select the IP address that server provides;
B04, router receive the lease of being beamed back by selected dhcp server and confirm dhcp ack package: do not receive dhcp ack package if wait for 2 seconds, then router is broadcasted dhcp request package again, do not receive dhcp ack package if wait for 4 seconds, then router is broadcasted dhcp request package again, also do not receive dhcp ack package if wait for 6 seconds, then change step B01 over to;
B05, router send the release message to server, inform that the dhcp server stops the dhcp service, confirms that connection type is the dhcp type.
The simple time of router detection network access process of the present invention is short.
Describe the present invention below in conjunction with accompanying drawing.
Embodiment
As shown in Figure 1, present embodiment is a kind of router network access detection method, after router is drawn in the Internet, the network access of the Internet is detected automatically, may further comprise the steps:
A, carry out pppoe discovery process, confirm whether the internet connection type is pppoe, if detection of end instructs the host subscriber to fill in right user name and password, enters the PPP session stage, otherwise enters step B;
Set up PPPOE passage (ADSL dialing) and divide two stages: find (Discovery) stage and PPP session stage:
The purpose in Discovery stage is to confirm that present network access is PPPOE, and subscriber's main station is sought all access devices that can connect with broadcast mode in the Discovery process, obtains its ethernet mac address.The SESSION_ID of the PPP session of selecting to need the subscriber's main station that connects then and obtaining at last to set up.Be the client-server relation between node in the Discovery process, a subscriber's main station (client, router) finally will be found an access device (server).In topology network, generally there is more than one access device to communicate by letter, the Discovery stage allows subscriber's main station to find all access devices, and therefrom selects one.When the Discovery stage finishes, all obtained to be provided with setting up the full detail that PPP connects between subscriber's main station and the access device too on the net.The Discovery stage keeps the foundation of no connection status up to a PPP session.In case PPP connects foundation, then subscriber's main station and access device all are necessary for PPP virtual port Resources allocation.
The Discovery stage may further comprise the steps:
1, subscriber's main station sends PPPOE and effectively finds initial (PADI:PPPoE active discovery initial) bag.The Ethernet destination address is broadcast address 0xffffffff, and the CODE field is 0x09, and SESSION_ID is 0x0000.The PADI bag must comprise the label (the tag types field is 0x0101) of a service name type (Service-Name) at least, and the service that provides is provided to the access device proposition.A complete PADI(comprises the PPPOE head) can not surpass 1484 bytes, increase Relay-Session-Id sign to stay the sufficient agent equipment of keeping for;
2, after access device is received PADI bag in service range, send PPPOE and effectively find to provide (PADO:PPPoE Active Discovery oder) bag with response request.Its CODE field is 0x07, and SESSION_ID still is 0x0000.PADO bag must comprise label (the tag types field is 0x0102) and one or more service name type label of an access device name type (AC-Name), and the type service that can provide to subscriber's main station is provided;
3, subscriber's main station is selected a suitable access device in a plurality of PADO bags that may receive, and the principle of selection is the content according to access device name type label among the PADO and service name type label.Send PPPOE to selected access device then and effectively find request (PADR: bag PPPoE active discovery request).Its CODE field is 0x19, and SESSION_ID still is 0x0000.The PADR bag must wrap a service name type label, determines to access device requested service kind.Do not receive PADO when a subscriber's main station in definite time, he can retransmit a PADI, waits for the time of twice simultaneously.This process can repeat repeatedly as required;
4, access device receives that PADR wraps the back and prepares beginning PPP session, and it sends a PPPOE and effectively finds session affirmation (PADS:PPPoE active discovery session confirmation) bag.Its CODE field is 0x65, and SESSION_ID is the unique PPPOE session identification number that access device produced.0xffff can not be used at present and make SESSION_ID as reserved resource.The label that PADS bag also must comprise a service name type is provided by the service that provides to subscriber's main station.After subscriber's main station received that the PADS bag is confirmed, both sides just entered the PPP session stage.If access device can not be discerned the label of the service name type among the PADR, then can return a PADS who comprises service name mistake (Service-Name-Error) label, its SESSION_ID remains 0x0000.If subscriber's main station is confiscated PADS bag in definite time, and confiscate PADO and do same the processing.
Also have a kind of PPPOE effectively to find to stop (PADT:PPPoE active discovery terminate) bag, a PPP session set up the back it either party sends at any time can be by subscriber's main station or access device, indication PPP session stops.The PADT bag is without any need for label, and its CODE field is 0xa7, and SESSION_ID is the session identification number that needs the PPP session of termination.
The judgement of pppoe connection type is such in the present embodiment, and pppoe discover has the reciprocal process of five messages:
1. PADI: router sends Initial message, is that effect is to wonder whether the PPPOE service end is arranged with the sending of broadcasting;
2. PADO: if there is the PPPOE service end to exist, after receiving the PADI message, can reply this message, show and to connect for it provide the PPPOE server end in the mode of clean culture;
3. PADR: this message sends to oneself selected service end in the mode of clean culture, and this message is used for the request server end can provide service;
4. PADS: after server is received the PADR request message, send a unicast message and confirm;
5. PADT: stop the pppoe session, in confirming net, have the server pppoe service can be provided after, stop dialogue, confirm that connection type is the pppoe type.
Matter of time in the present embodiment in the pppoe process.
Router sends the PADI packet, waits for 5 seconds, if do not receive the PADO bag, continues to send the PADI bag, waits for 10 seconds, if also do not have back, continues to send the PADI bag, waits for 20 seconds, if also do not have back, judges that type is not the pppoe type.
If receive the pado bag in the superincumbent stand-by period, router just sends the PADR bag, wait for 5 seconds,, continue to send the PADR bag if do not receive the PADS bag, wait for 10 seconds then, if do not receive the PADS bag, continue to send the PADR bag, wait for 20 seconds, if do not receive the PADS bag, judge that type is not the PPPOE type.
If receive the PADS bag in the stand-by period in the superincumbent step, just send the PADT bag, stop the pppoe dialogue, judge that type is the pppoe connection type.
B, carry out dhcp discovery process, confirm whether the internet connection type is dhcp, if detection of end notifies the host subscriber to enter the dhcp session stage, otherwise, enter step C.
In the present embodiment: Dhcp discover has the reciprocal process of five messages:
1. dhcp discover: seek server, to a dhcp discover of Web broadcast package;
2. dhcp offer: provide an IP to rent the address, receive dhcp discover broadcast packet after, select a vacant IP and lease time to offer client;
3. dhcp request: accept the IP lease, receive the offer bag after, broadcast a dhcp request and wraps, tell all servers it will accept the IP address which station server provides;
4. dhcp ack: lease is confirmed, confirms that the IP lease comes into force, and illustrates that the dhcp server can provide a complete dhcp to serve to client;
5. dhcp release: client initiatively sends the release message to server, informs that the dhcp server stops the dhcp service, confirms that connection type is the dhcp type.
Receive that for router there is following regulation the message time: after having sent the discover bag, wait for 2 seconds, if do not receive back bag, wait for 4 seconds again,, wait for 6 seconds again if do not receive back bag, if do not receive, just no longer give out a contract for a project, judge it is not the dhcp connection type.
If receive the offer bag in the process of waiting for, router just returns the request bag, and is identical with the top stand-by period, if do not receive that server returns bag, sends the discover bag again.
If in the stand-by period, received the ack bag, just send dhcp release bag and stop the dhcp service, show that connection type is the dhcp connection type.
C, affirmation internet connection type are static IP, and guide the host subscriber correctly to fill in the IP address, mask, and gateway information finishes.