CN101212364B - Method for detecting online state of host computer - Google Patents
Method for detecting online state of host computer Download PDFInfo
- Publication number
- CN101212364B CN101212364B CN2006101720630A CN200610172063A CN101212364B CN 101212364 B CN101212364 B CN 101212364B CN 2006101720630 A CN2006101720630 A CN 2006101720630A CN 200610172063 A CN200610172063 A CN 200610172063A CN 101212364 B CN101212364 B CN 101212364B
- Authority
- CN
- China
- Prior art keywords
- package
- router
- sent
- internet
- destination server
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 26
- 238000001514 detection method Methods 0.000 claims description 9
- 230000008569 process Effects 0.000 claims description 3
- 238000012545 processing Methods 0.000 abstract description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 238000012544 monitoring process Methods 0.000 description 2
- 230000008901 benefit Effects 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 238000002834 transmittance Methods 0.000 description 1
Images
Landscapes
- Computer And Data Communications (AREA)
Abstract
The invention provides a method for detecting an online state of a host and a system thereof. The method includes the steps: a seal packet with a TTL value of K is transmitted; whether or not the TTL value is less than n is judged. The system comprises a storage medium, a processing unit and a judging unit. The method for detecting the online state of the host and the system provided by the invention can not be affected by the operation state of a server and whether the server is connected with the internet can be correctly judged; besides, timeout time of the seal packet and the detecting time can be shortened.
Description
Technical field
The present invention relates to a kind of detection method, particularly a kind of method and system that detects online state of host computer.
Background technology
If want to test the on line state of the Internet, existing method is directly used " ping " usually, and this instructs and checks whether the server (Server) on the Internet has response.As utilize server that " ping " instruction inquires about this network address of correspondence " tw.yahoo.com " whether can be normally online (C: ping tw.yahoo.com), and this server can respond normal online or information that can't be online.In addition, also can utilize " InternetGetConnectedStateEx " functional expression in " wininet.dll " dynamic link library to judge whether to connect server on the Internet.If can be online, then can respond the value of a non-zero.
Yet, when utilizing " ping " instruction to judge whether to connect server on the Internet, if the on line state instability of server causes the actual the Internet that connects but to be shown as the broken string state easily.And when utilizing " InternetGetConnectedStateEx " functional expression to judge whether to connect server on the Internet, if detected server only connects the state of local area network (LAN) (Local Area Network) LAN, still can respond the value of a non-zero, but in fact it is not to connect the Internet.
Therefore, how to provide a kind of method and system that detects online state of host computer, can not be subjected to the influence of operation condition of server, and can correctly judge the server that whether connects on the Internet, become one of researcher's problem demanding prompt solution.
Summary of the invention
The purpose of this invention is to provide a kind of method and system that detects online state of host computer, can correctly judge main frame and whether connect server on the Internet.Having overcome utilization " ping " instructs when checking the server that whether connects the Internet, because of the operation condition of server instability causes showing mistake; When also having overcome utilization " InternetGetConnectedStateEx " functional expression and judging whether to connect server on the Internet, be shown as and connect the error message of going up the Internet because of detected server only connects local area network (LAN).
The invention provides a kind of method that detects online state of host computer.Described method comprises: transmit the package that a ttl value is k, and judge that whether described ttl value is less than n.If described ttl value is not less than n, represent that described package correctly is sent to described destination server by the router between a destination server on a machine and the Internet, then return an information that connects the Internet.
If described ttl value less than n, judges then whether described package correctly is sent to a router.If described package correctly is not sent to a router between described machine and described destination server, then responds an error message and return an information that does not connect the Internet.If described package correctly is sent to the router between described machine and described destination server, then responds a correct information, and k is added 1.
The present invention also provides a kind of system that detects online state of host computer.Described system comprises a storage medium, a processing unit and a judging unit.Described storage medium stores predefined k value and n value.Described processing unit is operated according to a user and is carried out a package monitoring program, in order to monitoring the transmission package that a ttl value is k, and obtains described k value and n value from described storage medium.Whether the k of the described transmission package of described judgment unit judges is less than n.When k is not less than n, represent that described package correctly is sent to described destination server by the router between a destination server on a machine and the Internet, then passback and show that in a user interface one connects the information of the Internet, when k less than n, judge then whether described package correctly is sent to the router between this machine and described destination server, if described package correctly is not sent to the router between this machine and described destination server, then respond an error message and return the information that does not connect the Internet, and be presented in the described user interface, if described package correctly is sent to the router between this machine and described destination server, then successively k is added 1.
Technique effect of the present invention is: a kind of method and system that detects online state of host computer provided by the invention, can not be subjected to the influence of operation condition of server, and can correctly judge the server that whether connects on the Internet, and can shorten overtime (Timeout) time of package and shorten detection time.
Description of drawings
Fig. 1 is the package form schematic diagram of IP;
Fig. 2 is the package form schematic diagram of ICMP;
Fig. 3 is a flow chart of steps that detects the embodiment of online state of host computer method of the present invention; And
Fig. 4 is a structural representation that detects the embodiment of online state of host computer system of the present invention.
Embodiment
For above and other objects of the present invention, feature and advantage can be become apparent, preferred embodiment of the present invention is described in detail below in conjunction with accompanying drawing.
The embodiment that the present invention detects the method and system of online state of host computer utilizes Internet protocol (Internet Protocol, be designated hereinafter simply as IP) time-to-live (Timeto Live in the package, be designated hereinafter simply as TTL) reach the purpose that detects online state of host computer, the form of IP package is as shown in Figure 1.
After being endowed ttl value, an IP package will countdown.In IP agreement, TTL is be unit to jump station number (Hop), and the IP package is every through a router (Router), and soon the ttl value of IP package subtracts 1, and the ttl value of IP package is reduced at 0 o'clock and promptly can be dropped.Therefore, when the IP package fails to reach the destination in transmittance process for some reason, just can avoid it to be present in above the network always and cause network congestion.
In addition, can utilize internet control message protocol (Internet Control MessageProtocol is designated hereinafter simply as ICMP) to judge that the IP package is because TTL returns 0 and be dropped, still because other is former thereby can't send to.ICMP is one " error detection and repayment mechanism ", can be used to detect the on-line state of network, also can guarantee online accuracy.The package form of ICMP as shown in Figure 2
When the value of the type field is 11 and the value of Code field when being 0, then notify the detected IP package of main frame to be dropped at TTL router, promptly this IP package is by TTL the router that be delivered to of safety.Therefore, the present invention designs a timer and removes to send package regularly to start circulation.The initial value of ttl value is set at 1, and ttl field is 1 when promptly for the first time sending package, and ttl field is 2 when then for the second time sending package, and ttl field is 3 when sending package for the third time.As long as wherein once package is not to be dropped because of TTL=0, i.e. representative transmits failure and jumps out window, and demonstration can't connect the Internet.
Fig. 3 is flow chart of steps that detects the embodiment of online state of host computer method of the present invention.
In embodiments of the present invention, define the value of k and n earlier.K represents that package is transmitted k router of process, and its initial value is preset as 1.N represents the router number that can pass through when package is transferred into a destination server, and its value is preset as 4, when representing promptly that package is transferred into a destination server can through 3 routers (because TTL<n).Notice that in embodiments of the present invention, the value of n is set at 4 but not as limit, " TTL<n " judgement formula also can be rewritten as " TTL≤n ".
At first, transmit the package that a ttl value is k (k=1) (step S1).Do you then, judge that ttl value is less than n (TTL<4?) (step S2).When the package that monitoring at the beginning sends out, whether TTL (=1) is sent to a router (the first router) (step S3) necessarily less than n so then judge this package.If package correctly is not sent to the first router, then ICMP responds an error message, and passback does not connect the information of the Internet.If package correctly is sent to the first router, then ICMP responds a correct information, and k is added 1 (k=k+1) (step S4), and this moment, TTL equaled 2.
Then, continuing to transmit this ttl value is the package (step S1) of k (k=2), judge that then ttl value is less than n (TTL<4?) (step S2).Whether TTL (=2) is sent to a router (the second router) (step S3) less than n so then judge this package.If package correctly is not sent to the second router, then ICMP responds an error message, and passback does not connect the information of the Internet.If package correctly is sent to the second router, then ICMP responds a correct information, and k is added 1 (k=k+1) (step S4), and this moment, TTL equaled 3.
Repeating step S1~S4 when TTL equals 4, transmits the package that this ttl value is k (k=4) (step S1), judge that then ttl value is less than n (TTL<4?) (step S2).This moment, ttl value was not less than 4, represented that this package correctly is sent to a destination server on the Internet by first, second and Third Road by device, so return the information that connects the Internet.
It should be noted that except utilizing ICMP to judge whether package transmits failure, also can judge whether package transmits failure according to the default package of a client (Client) overtime (Timeout).After package was seen off, client can start a timer (Timer), and when reaching timeout value and but also confiscate the information of relevant package, promptly represented package to transmit failure, and respond described error message.
Fig. 4 is the structural representation that the present invention detects the embodiment of online state of host computer system.
The system 200 of the detection online state of host computer of the embodiment of the invention comprises a processing unit 210 and a judging unit 230.Processing unit 210 is operated according to a user and is carried out a package monitoring program, is the transmission package of k in order to monitoring-ttl value, and obtains predefined ttl value (k) and n value from a storage medium (not shown).
Does judging unit 230 judge that the k of this transmission package is less than n (TTL<4?).When ttl value is not less than 4, represent that this package correctly is sent to a destination server on the Internet by first, second and Third Road by device, so passback and in user interface 250, show the information that connects the Internet.When ttl value less than 4, judge then then whether this package is sent to the router between this machine and this destination server.If this package correctly is not sent to the router between this machine and this destination server, then ICMP responds an error message and does not connect the information of the Internet with passback one, and is presented in the user interface 250.If this package correctly is sent to router between this machine and this destination server, then in regular turn the ttl value of package is added 1 (k=k+1).Therefore the present invention embodiment of detecting the method and system of online state of host computer utilizes the ttl value of setting package to confirm the router that package can arrive, can not be subjected to the influence of server operating state, can correctly judge the server that whether connects on the Internet, and can shorten overtime (Timeout) time of package and shorten detection time.
The present invention also provides a kind of recording medium (for example CD, disk and portable hard drive or the like), is used for writing down the authority sign-off program of an embodied on computer readable, so that carry out the method for above-mentioned detection online state of host computer.At this, be stored in the authority sign-off program on the recording medium, basically formed (for example setting up organization chart code segment, sign-off forms code segment, setting program code snippet and deployment program code snippet) by a plurality of code segment, and the function of these code segment is corresponding to the step of said method and the functional block diagram of said system.
Claims (4)
1. a method that detects online state of host computer is characterized in that, comprises the following steps:
Transmitting a ttl value is the IP package of k, and k represents that the IP package is transmitted k router of process, and its initial value is preset as 1;
Whether judge described ttl value less than n, n represents the router number that can pass through when the IP package is transferred into a destination server;
If described ttl value is not less than n, represent that described IP package correctly is sent to described destination server by the router between a destination server on a machine and the Internet, then return an information that connects the Internet;
If described ttl value less than n, judges then whether described IP package correctly is sent to a router;
If described IP package correctly is not sent to a router between described machine and described destination server, then responds an error message and return an information that does not connect the Internet simultaneously; And
If described IP package correctly is sent to the router between described machine and described destination server, then respond a correct information, and k is added 1, repeat above-mentioned steps again.
2. the method for detection online state of host computer as claimed in claim 1 is characterized in that: if described IP package correctly is not sent to the router between described machine and described destination server, then utilize ICMP to respond described error message.
3. the method for detection online state of host computer as claimed in claim 1 is characterized in that: if described IP package correctly is sent to the router between described machine and described destination server, then utilize ICMP to respond described correct information.
4. the method for detection online state of host computer as claimed in claim 3 is characterized in that, also comprises the following steps:
Set a timer and a timeout value;
After transmitting described IP package, start described timer; And
If when when reaching described timeout value, not receiving the information of relevant described package, then respond described error message.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2006101720630A CN101212364B (en) | 2006-12-30 | 2006-12-30 | Method for detecting online state of host computer |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2006101720630A CN101212364B (en) | 2006-12-30 | 2006-12-30 | Method for detecting online state of host computer |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101212364A CN101212364A (en) | 2008-07-02 |
CN101212364B true CN101212364B (en) | 2011-05-25 |
Family
ID=39612061
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2006101720630A Expired - Fee Related CN101212364B (en) | 2006-12-30 | 2006-12-30 | Method for detecting online state of host computer |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101212364B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107948989B (en) * | 2016-10-13 | 2021-02-12 | 北京国双科技有限公司 | Method and device for calculating networking time of mobile terminal |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1385989A (en) * | 2001-05-16 | 2002-12-18 | 华为技术有限公司 | Method for conrolling short message retransmission time |
CN1581813A (en) * | 2003-08-01 | 2005-02-16 | 光桥科技(中国)有限公司 | Method for conducting data transmission using logic loop network in ethernet |
-
2006
- 2006-12-30 CN CN2006101720630A patent/CN101212364B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1385989A (en) * | 2001-05-16 | 2002-12-18 | 华为技术有限公司 | Method for conrolling short message retransmission time |
CN1581813A (en) * | 2003-08-01 | 2005-02-16 | 光桥科技(中国)有限公司 | Method for conducting data transmission using logic loop network in ethernet |
Also Published As
Publication number | Publication date |
---|---|
CN101212364A (en) | 2008-07-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10003525B2 (en) | Methods and apparatus to provide redundancy in a process control system | |
US20040010627A1 (en) | Ethernet interface device for reporting status via common industrial protocols | |
US20080101218A1 (en) | Method and device for implementing active/standby gateway device in a network | |
EP3140960B1 (en) | Methods, systems, and computer readable media for providing fuzz testing functionality | |
JP4681472B2 (en) | Topology information collection program, topology information collection device, and topology information collection method | |
CN101316197A (en) | Detection method and apparatus for Ethernet port loop of MSTP equipment | |
CN102064964A (en) | Method for rapidly switching gigabit network cards in gigabit switching environment | |
US20120269068A1 (en) | Testing system | |
CN102143011B (en) | Device and method for realizing network protection | |
CN113660265B (en) | Network attack testing method and device, electronic equipment and storage medium | |
CN101212364B (en) | Method for detecting online state of host computer | |
CN113722003A (en) | Method, device and equipment for adjusting working mode of PHY chip | |
US7626937B2 (en) | System and method for network connection detection | |
TW201417548A (en) | Method of connection reliability assurance of user end to cloud and user end | |
JP4793739B2 (en) | Wireless LAN device, wireless LAN master / slave switching method, program for wireless LAN device | |
US6467041B1 (en) | Third party host packet replication | |
US7876691B2 (en) | Testing method for network device | |
JP5655533B2 (en) | Information processing apparatus control method, information processing apparatus, and information processing apparatus control program | |
JP2008124791A (en) | Layer 2 switch and network monitoring method | |
JP2005085078A (en) | Network system including power saving dealing device | |
JP5533100B2 (en) | Switch, notification program, and notification method | |
JP6819357B2 (en) | Operation confirmation device, operation confirmation program, operation confirmation method, and operation confirmation system | |
JP2021044657A (en) | Device and method for address monitoring | |
KR102387010B1 (en) | Monitoring apparatus and monitoring method | |
JP2002237827A (en) | Lan controller, driver, switching hub and lan controller automatic switching system having them |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20110525 |