Monitor an Internet connection with Arduino

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

Monitor an Internet connection with Arduino

Post by mustang65 »

I did some searching, but was unable to locate the information that I need. I am having issues with the local cable company regarding my "Internet Connection". I have 30MB wide band service and I keep getting pop-ups that say "Lost the Internet connection...". The cable to the computer is OK and the wireless connections are OK. Both hardwired/wireless drop connections. I want to use an extra Boarduino that I have to monitor the internet connection. I have an Ethernet shield (PID 201) and a DS1307 Real Time Clock (PID 264) and was wondering if anyone has accomplished this before. The output that I am looking for is to log the date and the start/end time for each time that the service was dropped, and store the data on the Ethernet shield's micro SD card. The Ethernet shield would be plugged into an extra Internet connection on the cable modem. I will search a little more to see if I missed any topics. I am VERY new at this Arduino prototyping, and any assistance would be GREATLY APPRECIATED!!!
Thanks again,
Don

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Monitor an Internet connection with Arduino

Post by adafruit_support_mike »

Phoo.. tough one. The nature of TCP/IP networks makes it hard to say whether your connection exists at any given moment.

It's easy to find out whether a cable is connected.. just measure the voltages on the wires.. but that's down at the 'physical' network layer. TCP operates at a higher level of abstraction: the 'transport layer' in official jargon.

TCP was explicitly designed to be robust in situations where the physical layer is unreliable. The basic mode of operation is, "I'm going to keep retransmitting this information until I get a signal that tells me it's been received." There are all sorts of delays baked into the basic protocol, and a normally-operating TCP/IP network drops packets and retransmits information all the time.

There's no simple "network is connected" signal either. TCP/IP connections only exist while you're using them, so you can only monitor a network's behavior while machines are actually making requests.

There are three ways to do that, one of which is bad, one of which would be punching above your weight, and one of which doesn't involve an Arduino.

The bad way is to flood the network with something called 'ICMP requests' or 'pings'. The basic idea is that you try to open a connection, then close it as soon as the computer at the other end responds or time out after a short interval. To network admins, that's precisely equivalent to having a kid in the back seat saying, "are we there yet? are we there yet? are we there yet?" It can get you kicked off a network, or they'll just configure their servers to ignore those requests.

The good way involves building a device that watches TCP/IP traffic moving back and forth through the wires, but knows how to match "I want to send this" requests with "okay, I got that" replies. That involves a lot of background knowledge, and would be tricky to fit into the limited programming space of an Arduino.

The non-Arduino way is to use software that does the same as above, but runs on a general-purpose computer. Most Unix-alike operating systems have the program 'tcpdump' which prints network traffic to the screen, or logs it to a file. You can also get programs that run on your desktop computer that analyze the connection while your machine is talking to the network.

User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

Re: Monitor an Internet connection with Arduino

Post by mustang65 »

Thank you,
You confirmed what I was thinking. I originally thought of using the "PING" method, but like you said, that would flood my network. As I was typing the last sentence, I just looked up and noticed that the cable modem has an "Online" light. I think I will try disconnecting the coax from the cable modem and see if the "Online" light goes off. If it does, I will place a "Photocell" over the light and monitor the status with the Arduino. Ahhh, it also has "Telephone Line 1 & Line 2" lights. I believe I just expanded my project to include them. This sounds a lot easier that any of my other options.
Thanks again,
Don

User avatar
tastewar
 
Posts: 408
Joined: Thu Mar 17, 2011 10:16 am

Re: Monitor an Internet connection with Arduino

Post by tastewar »

Have you seen a correlation between times when you feel effectively disconnected from the internet, and the light on the router being off? Certainly, if the light is off, you aren't going to be connected, but just because the light is on doesn't mean you're all set. There can be problems at many, many layers. I doubt the light you're seeing is any more sophisticated than telling you that the other end of the cable is connected, but I suppose it could be indicative of having received an IP address from upstream, or something like that. Anyway, it won't cover all cases, but it may cover the ones important to you, if you know there's a correlation there.

User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

Re: Monitor an Internet connection with Arduino

Post by mustang65 »

I know that there are different levels that may be causing the disconnect, so I will address it starting with the easiest method. There is also a LINK light. I will research the CISCO documentation to see what the lights actually monitor and take it from there. Just thought of another way to get info. The TV cable box, i can access it and look at its log, to see if the entire cable was having issues. Probably no, but it is worth a try."

User avatar
cstratton
 
Posts: 294
Joined: Wed Sep 29, 2010 3:52 pm

Re: Monitor an Internet connection with Arduino

Post by cstratton »

The link light probably monitors the physical connection between the router and your PC, hence it really says nothing about the quality of service upstream of the router.

User avatar
tastewar
 
Posts: 408
Joined: Thu Mar 17, 2011 10:16 am

Re: Monitor an Internet connection with Arduino

Post by tastewar »

I think if you want to know if the basic connection between your router and the wider internet is healthy, you might take an approach where you periodically attempt to connect to a service that you would expect to be available, like making a TCP connection to a highly-available web server. You could do this once a minute or so and get a good idea of the health of your internet connection. The libraries for the Arduino Ethernet shield would make this pretty straightforward. Are the outages you experience very ephemeral, or do they last for a noticeable period?

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”