Re: Monitor an Internet connection with Arduino
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.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.