Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more


Router Uptime.

Posted on 2006-07-18
Medium Priority
Last Modified: 2010-04-05

How can i get router uptime ?
Question by:CodedK
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 6
  • 3
  • +1
LVL 28

Assisted Solution

2266180 earned 660 total points
ID: 17129040
I would look at SNMP (Simple Network Management Protocol). I found this program that you can look into for information:
it might help, I didn't check.
LVL 16

Author Comment

ID: 17129052
Thanks ciuly, i'll check it.
LVL 17

Accepted Solution

TheRealLoki earned 660 total points
ID: 17135480
some routers support telnet, and you can usually find this information with a simple command
What make is the router, or are you looking for a more generic solution?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 16

Author Comment

ID: 17136548
Hi theRealLoki, please tell me the commands .
LVL 26

Assisted Solution

by:Russell Libby
Russell Libby earned 680 total points
ID: 17138172
The project mentioned above:

will only return the uptime of the computers local area network interface. (My computer | My Network places | View network connections | Select local area connection | Right click | Status | See duration item).

Unfortunately, there is no "generic" solution for determining a router's uptime. Some routers will allow telnet, but many do not. Most allow http/https management, but the layout of the pages is wildly different from one manufacturer to another. Then there is the issue that some routers, eg (I can speak from experience) the older WRT54G from Linksys does not support any uptime information in the firmware. Can't say about the latest models though.
Point is, not all routers even HAVE an uptime in the firmware, couple that with the fact that interfacing directly with the device requires different protocols depending on vendor, along with the lack of any common standards, and the best you could hope for is developing something that worked specifically for your router.


LVL 17

Expert Comment

ID: 17142088
>Hi theRealLoki, please tell me the commands .
I need to know what router it is
for mine,
i go
try it in dos first and see if you have the info in there you need

Russel, yes i know this, this is why I asked if he wanted a generic method, and what his router was...
LVL 16

Author Comment

ID: 17142121
>> Whats "1" ?
LVL 26

Expert Comment

by:Russell Libby
ID: 17142135

The post was mainly for CodedK's benefit, so it was understood that a generic method (for all routers) was not possible, at least not very easily.

Btw, is the IP addr you list in your example just an example? (its not in the private range of 10.x.x.x or 192.x.x.x) Just curious....

LVL 16

Author Comment

ID: 17142233
Ok mine differs a little.
I got a "menu" command.
I got in and saw that no uptime info is available on general info menu.
Nevertheless on the browser page i can see info like uptime and other things that dont exist in telnet command.
This all question thing was more about GetAdapterInfo.
I wanted to know just one thing... a list of what GetAdapterInfo can bring...

I've managed to gather this info :

interface caption
index of the interfaces
type of interface
max transmission unit
speed of the interfaces
length of physical address
physical address of adapter
administrative status
operational status
read time operational status changed
octets received
unicast packets received
non unicast packets received
received packets discarded
erroneous packets received
unknown protocol packets received
octets sent
unicast packets sent
non unicast packets sent
outgoing packets discarded
erroneous packets sent
output queue length
length of bDescr more member
interface description
If DHCP Enabled
Current Ip Address
Ip Address List
Gateway List
DHCP Server
Have Wins
Primary Wins Server
Secondary Wins Server
Lease Obtained
Lease Expires
Is there anything more info i can get ????

Some of that info raise errors, some not.
I thought that uptime would be easy to get...
I see that this is not the case...  :)

LVL 17

Expert Comment

ID: 17142371
if snmp is not an option, and you don't mind this solution only working for your particular router, then you can use TIdHTTP and login to the router's web interface and scrape the uptime off that page.
rllibby should be able to point you in the right direction on how to do that... it's not something I've had much experience with :-)
LVL 26

Expert Comment

by:Russell Libby
ID: 17142375

The list of the field elements and their descriptions for the return buffer from GetAdaptersInfo can be found here:

This data only applies to the PC's network adapter interface. As to the router, have you Googled your router brand to see if you can locate any info regarding the command set available via remote admin?

LVL 16

Author Comment

ID: 17142379
Its generic or nothing.... I dont want this app to work only in my pc. :)
LVL 16

Author Comment

ID: 17142393
Wait a second Russell ... I am lost here :)
>>This data only applies to the PC's network adapter interface
I've connected my modem/router through usb and i get this info through getadaptersinfo.
I get all the adapters in my pc along with my modem... And i can get all that info like that.
LVL 16

Author Comment

ID: 17142399
I know that if i connect it through the lan card i wont see the router any more...
I will only see my lan card...Is that right ?
LVL 26

Expert Comment

by:Russell Libby
ID: 17142437
This should clear some of the confusion up:

- go to cmd prompt
- type > ipconfig /all
- read the results

This is the info you will get back from GetAdaptersInfo. It has nothing to do with the router and everything to do with the network interfaces. (be it usb, modem, loopback interface, or lan card). The only thing even related to the router will be the DHCP info, if your router is set up to hand out dynamic ip's


LVL 16

Author Comment

ID: 17142472
Where is the ball...?

Ok sorry for the mess i made :)
Lets say that i wanted to ask how can i get network adapter uptime :P
does this change anything or not ?
LVL 16

Author Comment

ID: 17142558
Thank you for the time and sorry for the mess :)
Increasing and splitting...
(Although i didnt understand much :) ) anyway thank you all for you time.
LVL 26

Expert Comment

by:Russell Libby
ID: 17151209

>> Lets say that i wanted to ask how can i get network adapter uptime :P
>> does this change anything or not ?

Absolutely. This information is available for each of the network interfaces on the PC, and this functionality works with Win98 on up. The only "undocumented" aspect is how to take the dwLastChange field and convert it into something meaningful, which I have done for you.



program Project1;


//   Include Units (IP Helper units:

// Totally undocumented as to how you take the DWORD value and convert it into a useable date time value.
function LastChangeTimeToDateTime(ChangeTime: DWORD): TDateTime;
var  lpSysTime:     TSystemTime;
     lpFileTime:    TFileTime;

  // Get system time as file time

  // Convert to useable format
  Int64(lpFileTime):=Int64(lpFileTime)  div 100000;

  // Check low part of date against change time
  if (lpFileTime.dwLowDateTime < ChangeTime) then Dec(lpFileTime.dwHighDateTime);

  // Set new low part

  // Convert back to 100-nanosecond intervals
  Int64(lpFileTime):=Int64(lpFileTime) * 100000;

  // Convert result to local time
  FileTimeToLocalFileTime(lpFileTime, lpFileTime);

  // Convert to system time
  FileTimeToSystemTime(lpFileTime, lpSysTime);

  // Convert to delphi date time


  lpIfTable:     PMibIfTable;
  dtElapse:      TDateTime;
  wDays:         Word;
  wTime:         Array [0..3] of Word;
  dwSize:        DWORD;
  dwIndex:       DWORD;


  if (GetIfTable(lpIfTable, dwSize, False) = ERROR_INSUFFICIENT_BUFFER) and (dwSize > 0) then
        if (GetIfTable(lpIfTable, dwSize, True) = ERROR_SUCCESS) and (lpIfTable^.dwNumEntries > 0) then
           for dwIndex:=0 to Pred(lpIfTable^.dwNumEntries) do
              // Display the interface description
              // Display the last change time
              // Decode days
              // Remove days
              dtElapse:=dtElapse - wDays;
              // Decode time
              DecodeTime(dtElapse, wTime[0], wTime[1], wTime[2], wTime[3]);
              // Check days
              if (wDays > 0) then
                 // Print with days
                 WriteLn('Duration : ', wDays, ' days, ', Format('%.2d:%.2d:%.2d', [wTime[0], wTime[1], wTime[2]]))
                 // Print without days
                 WriteLn('Duration : ', Format('%.2d:%.2d:%.2d', [wTime[0], wTime[1], wTime[2]]));
              // Space

LVL 16

Author Comment

ID: 17152183
Thank you Russell, i really wanted to ask that :
>>dwLastChange field and convert it into something meaningful

I thought that i was doing something wrong and i got this @#%@# values.

I also thought that since i got my router name(Description = SpeedTouch) among the list of Network Adapters
then a Modem/Router=a Network adapter. This is what i dont understand.

Thank you very much :)
LVL 16

Author Comment

ID: 17152490
Russell i've tried it...
For all network adapters (including my SpeedTouch) it shows the time that windows started.
LVL 26

Expert Comment

by:Russell Libby
ID: 17153079

Yep, thats usually the case. In case you curious, go to the following:

- My Computer
- My Network Places
- View Network Connections
- Select a connection
- Right Click
- Select Status
- Check the duration

If you want to test my program, disable then renable the connection and check again



Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : All lightning effects with instructions : http://www.mediaf…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question