Pinging the first hop

click to enlarge

In a previous blog post, I described that I had set up a smart plug that pings a pre-arranged IP address, and if the ping fails, the smart plug will power-cycle our modem and main router in our office.

The world we live in is enriched because there are smart people around us (not only smart plugs!).  One of those smart people is alert reader Manuel Fortin, who commented:

Very interesting, but I see a problem with the ping feature. What address will you use? If the address is unreachable for any reason that is unrelated to your modem and router, you will just end up with an endless loop of resets. Pinging an address within your network will not reset the system in case you lose internet access. Pinging an address outside of your network would completely disable your network if that address only, or a subset of the internet, cannot be accessed. It happens that servers, even from the most reputable companies, experience problems, or that problems make some part of the internet impossible to access.

Of course he is exactly right.  It is the Goldilocks problem.  Ping a host that is too close, and the ping result tells you nothing of interest.  Ping a host that is too far away, and the ping result might get overwhelmed with noise from Internet connectivity failures that have nothing to do with any good reason for power-cycling of your own modem or router.  It needs to be “just right”.  So how to do it “just right”?

The answer that I offer to Mr. Fortin is to ping the “first hop in the traceroute”.  The traceroute (Wikipedia article), shown above, is a good way to learn the IP address of the CMTS (Wikipedia article), which is the piece of equipment at the other end of the RF link for our cable Internet connection.  Prompted by Mr. Fortin’s comment, I have performed the traceroute, learned the IP address of the CMTS, and configured our smart switch to ping that IP address instead of the far-away IP address that I had previously used.

For a customer using DSL rather than cable Internet, the “first hop” will give you the DSLAM (Wikipedia article) which is also, I think, “just right” for this purpose.

I think that I have now done what is “just right”.  Thank you to Mr. Fortin.

2 thoughts on “Pinging the first hop

  1. Carl – The first hop is the current IP address for the CMTS device. If (for whatever reason) your provider changes the IP of that CMTS, then your smart plug will repeatedly recycle your modem. If your smart plug allows more complicated logic consider a double check. If the ping fails for the IP address for the CMTS device, then check to see if some other reliable address, like google’s 8.8.8.8 also fails. If so, power cycle to reboot the modem. If not, send yourself an email to check the IP address for the CMTS device.

    • Of course you are right that my programming the IP address of the CMTS into the smart plug takes a risk, namely that the ISP might change the IP address of the CMTS. I think that the smart plug is able to do DNS lookups. And maybe I can configure the ping to be based upon a domain name rather than an IP address. As such, I can configure the smart plug to use the domain name of the CMTS (which as you can see from the screen shot is “cm-1-acr19.arvada.co.denver.comcast.net”). So prompted by your comment, that is what I will do.

      No unfortunately the smart plug does not have the ability to do more complicated logic.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.