GithubHelp home page GithubHelp logo

import-yuefeng / echoping Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wxiaoguang/echoping

1.0 1.0 0.0 11 KB

A golang network utility using TCP & UDP messages to detect network stability.

Go 94.09% Shell 5.91%

echoping's Introduction

echoping

A golang network utility using TCP & UDP messages to detect network stability.

Why to write this network utility

It's difficult to detect network problems in real life.

echoping uses TCP and UDP protocols instead of ICMP used by traditional ping, and send messages more frequently.

echoping works more like a real network application, and reports network problems as the real one.

How it works

  1. Start a echoping server by ./echoping -listen IP:PORT
  2. Start echoping clients to use the echoping server: ./echoping -connect SERVER_IP:SERVER_PORT
  3. Every echoping client sends TCP and/or UDP requests to the server
  4. The server sends every request as a response back to the client
  5. The client collects the responses and calculates the packet loss ratio (UDP only) and round-trip time
  6. If any network error occurs, the client will retry to connect and send requests forever.
  7. Every connection (ping session) has a unique session id which is generated by the connection time, it helps to distinguish different client connections, eg: if a network error occurs and a client re-connects, then there will be a new session id in logs.

Usage:

  -connect string
        connect to 'tcp://ip:port/,udp://ip:port/' (can be repeated, use comma as delimiter), or use 'ip:port' for both TCP and UDP
  -listen string
        listen both TCP and UDP on ip:port
  -listen-tcp string
        listen TCP on ip:port
  -listen-udp string
        listen UDP on ip:port
  -ping-interval duration
        the interval between ping requests sent by client (default 20ms)

Server output:

2020/12/26 01:24:54 server stat udp:127.0.0.1:52032 (20201226-012449.458182): pps=10.0, tmperr=0
2020/12/26 01:24:54 server stat tcp:127.0.0.1:56524 (20201226-012449.458231): pps=10.0, tmperr=0

Client output:

2020/12/26 01:24:54 client stat udp:127.0.0.1:12345 (20201226-012449.458182): pps=11.0, loss=0.0%, round-trip time (ms): avg=0.4, min=0.2, max=0.6, stddev=0.1
2020/12/26 01:24:54 client stat tcp:127.0.0.1:12345 (20201226-012449.458231): pps=11.0, loss=0.0%, round-trip time (ms): avg=0.3, min=0.2, max=0.4, stddev=0.1
  • "20201226-012449.458182" is the ping session id, which is generated by the time of the client starts the ping session.
  • pps means "ping per second"
  • TCP's loss is always 0% (of course)

Develop and debug locally

./echoping -listen :12345 -connect 127.0.0.1:12345

Simulate delayed and dropped packets on Linux: https://stackoverflow.com/questions/614795/simulate-delayed-and-dropped-packets-on-linux

echoping's People

Contributors

wxiaoguang avatar

Stargazers

 avatar

Watchers

 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.