cnping

Minimal Graphical Ping Tool
git clone https://git.sinitax.com/cnlohr/cnping
Log | Files | Refs | Submodules | README | LICENSE | sfeed.txt

commit 9ae6ad450a3bd01f5b10238aad39f86642197f5d
parent f435ca92fbca170d60f4823191893ddd4a4986ef
Author: CNLohr <charles@cnlohr.com>
Date:   Sat,  9 Apr 2016 13:54:36 -0400

Merge pull request #5 from hackrid/master

adding a gui scale factor to make small ping response times better visible
Diffstat:
MREADME.md | 7++++++-
Mcnping.c | 58+++++++++++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 53 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md @@ -3,7 +3,12 @@ cnping Minimal Graphical IPV4 Ping Tool. (also comes with searchnet, like nmap but smaller and simpler). It uses rawdraw so it is OS independent. -Usage: cnping [IP address] [seconds between pings (decimal OK)] [additional size to increase] +Usage: cnping [host] [period] [extra size] [y-axis scaling] + + [host] -- domain or IP address of ping target + [period] -- period in seconds (optional), default 0.02 + [extra size] -- ping packet extra size (above 12), optional, default = 0 + [y-axis scaling] -- see more swing for small values (optional), default = 1 Picture: diff --git a/cnping.c b/cnping.c @@ -24,6 +24,7 @@ unsigned long iframeno = 0; short screenx, screeny; const char * pinghost; float pingperiod; +float GuiYScaleFactor; uint8_t pattern[8]; @@ -35,7 +36,7 @@ double PingSendTimes[PINGCYCLEWIDTH]; double PingRecvTimes[PINGCYCLEWIDTH]; int current_cycle = 0; -int ExtraPingSize = 0; +int ExtraPingSize; void display(uint8_t *buf, int bytes) { @@ -132,7 +133,7 @@ void DrawFrame( void ) if( last < 0 && rt > st ) last = dt; - int h = dt; + int h = dt*GuiYScaleFactor; int top = screeny - h; if( top < 0 ) top = 0; CNFGTackSegment( i, screeny-1, i, top ); @@ -159,12 +160,17 @@ void DrawFrame( void ) stddev = sqrt(stddev); + int avg_gui = avg*GuiYScaleFactor; + int stddev_gui = stddev*GuiYScaleFactor; + CNFGColor( 0xff00 ); - int l = avg; + + + int l = avg_gui; CNFGTackSegment( 0, screeny-l, screenx, screeny - l ); - l = avg + stddev; + l = (avg_gui) + (stddev_gui); CNFGTackSegment( 0, screeny-l, screenx, screeny - l ); - l = avg - stddev; + l = (avg_gui) - (stddev_gui); CNFGTackSegment( 0, screeny-l, screenx, screeny - l ); char stbuf[1024]; @@ -216,26 +222,56 @@ int main( int argc, const char ** argv ) PingRecvTimes[i] = 0; } + if( argc < 2 ) { - ERRM( "Usage: cnping [host] [ping period in seconds (optional) default 0.02] [ping packet extra size (above 12), default = 0]\n" ); + ERRM( "Usage: cnping [host] [period] [extra size] [y-axis scaling]\n" + + " [host] -- domain or IP address of ping target \n" + " [period] -- period in seconds (optional), default 0.02 \n" + " [extra size] -- ping packet extra size (above 12), optional, default = 0 \n" + " [y-axis scaling] -- see more swing for small values (optional), default = 1\n"); return -1; } + + if( argc > 2 ) + { + pingperiod = atof( argv[2] ); + printf( "Extra ping period: %f\n", pingperiod ); + } + else + { + pingperiod = 0.02; + } + if( argc > 3 ) { ExtraPingSize = atoi( argv[3] ); - printf( "Extra ping size added: %d\n", ExtraPingSize ); + printf( "Extra ping size: %d\n", ExtraPingSize ); + } + else + { + ExtraPingSize = 0; } - sprintf( title, "%s - cnping", argv[1] ); + if( argc > 4 ) + { + GuiYScaleFactor = atof( argv[4] ); + printf( "GuiYScaleFactor: %f\n", GuiYScaleFactor ); + } + else + { + GuiYScaleFactor = 1; + } + + pinghost = argv[1]; + + sprintf( title, "%s - cnping", pinghost ); CNFGSetup( title, 320, 155 ); ping_setup(); - pinghost = argv[1]; - pingperiod = (argc>=3)?atof( argv[2] ):.02; - OGCreateThread( PingSend, 0 ); OGCreateThread( PingListen, 0 );