Giter VIP home page Giter VIP logo

connectivitypinger's Introduction

connectivitypinger - Check Internet Connectivity State


Background

To explore how Exponential backoff works, I wrote this script that helps check if the system is connected to the Internet of not. Another reason for making the script is, I was fed up with my ISP resetting my connection, since I'm on ssh, it kept timing out and the only way to find/notify disconnection was through Dropbox, and it takes forever.

Exponential back-off states that:

Given a uniform distribution of backoff times, the expected backoff time is the mean of the possibilities.

That is, after c collisions, the number of backoff slots is in

[0, 1, ..., N], where N = 2c - 1 

and the expected backoff time (in slots) is:

(1/(N+1))*(n∑i,i=0), where (n∑i,i=0) = ((n*(n+1))/2)

Working

The script checks if the system is connected, by getting www.google.com. If true, backs off for x seconds, if false backs out for y secs.

On a successful:

  • connection-after-disconnection
  • disconnection-after-connection

the script send a notification using notify-send.

PS: Do remember, this will silently run in the background :)

Requirements

  • python3
  • notify-send
    • install using sudo apt-get install notify-osd

To Do:

  • check socket timeout issue and fix
  • clean and make code legible
  • Implement backoff of both disconnection and connection
  • make notifications audible
  • back it as a shell callable
  • Way to get kill the script form terminal, one command

I'm open to all suggestion and feedback.

Also, I have a very faint feeling I'm doing it wrong, if so, please do let me know

connectivitypinger's People

Contributors

roopesh90 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.