Giter Club home page Giter Club logo

cnping's People

Contributors

brookst avatar christianromberg avatar cnlohr avatar dependabot[bot] avatar drbachler avatar dreua avatar goeiecool9999 avatar michael137 avatar mischnic avatar mrbesen avatar sturob avatar viknet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cnping's Issues

cnping gives cryptic error message when not running as root

When running cnping as a non-root user, I get a cryptic-ish error:

$ ./cnping google.com         
GuiYScaleFactor:   dynamic
Error: Failed to set TTL option

The issue is caused by not running cnping as root (or with sudo), and it would be helpful to alert the user that it needs to be run with root privs.

Mac compile error: MSG_NOSIGNAL

Not sure whether cnping or cnping_mac is the correct target, but both don't compile on macOS (10.13):

$ make cnping
cc  -g -Os -I/opt/X11/include -Wall   -c -o httping.o httping.c
httping.c:96:36: error: use of undeclared identifier 'MSG_NOSIGNAL'
                int rs = send( httpsock, buf, n, MSG_NOSIGNAL );
                                                 ^
1 error generated.
make: *** [<builtin>: httping.o] Error 1
$ make cnping_mac
gcc -o cnping cnping.c CNFGFunctions.c CNFGCocoaCGDriver.m os_generic.c ping.c -x objective-c -framework Cocoa -framework QuartzCore -lm -lpthread
cnping.c:344:27: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                        sprintf( stbuf, "%lu", samps );
                                         ~~~   ^~~~~
                                         %llu
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
cnping.c:358:55: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                        pinghost, globmaxtime*1000.0, globinterval*1000.0, globallost, globalrx, globallost*100.0/(globalrx+globallost) );
                                                                           ^~~~~~~~~~
/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
                                                             ^~~~~~~~~~~
cnping.c:358:67: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                        pinghost, globmaxtime*1000.0, globinterval*1000.0, globallost, globalrx, globallost*100.0/(globalrx+globallost) );
                                                                                       ^~~~~~~~
/usr/include/secure/_stdio.h:57:62: note: expanded from macro 'snprintf'
  __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
                                                             ^~~~~~~~~~~
cnping.c:478:3: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                globallost, globalrx, globallost*100.0f/(globalrx+globallost), loss );
                ^~~~~~~~~~
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
cnping.c:478:15: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]
                globallost, globalrx, globallost*100.0f/(globalrx+globallost), loss );
                            ^~~~~~~~
/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                                                       ^~~~~~~~~~~
5 warnings generated.
os_generic.c:281:2: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
        sem_init( sem, 0, 0 );
        ^
/usr/include/sys/semaphore.h:55:42: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
                                         ^
/usr/include/sys/cdefs.h:176:37: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((deprecated))
                                       ^
os_generic.c:288:2: warning: 'sem_getvalue' is deprecated [-Wdeprecated-declarations]
        sem_getvalue( os, &valp );
        ^
/usr/include/sys/semaphore.h:54:56: note: 'sem_getvalue' has been explicitly marked deprecated here
int sem_getvalue(sem_t * __restrict, int * __restrict) __deprecated;
                                                       ^
/usr/include/sys/cdefs.h:176:37: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((deprecated))
                                       ^
os_generic.c:305:2: warning: 'sem_destroy' is deprecated [-Wdeprecated-declarations]
        sem_destroy( os );
        ^
/usr/include/sys/semaphore.h:53:26: note: 'sem_destroy' has been explicitly marked deprecated here
int sem_destroy(sem_t *) __deprecated;
                         ^
/usr/include/sys/cdefs.h:176:37: note: expanded from macro '__deprecated'
#define __deprecated    __attribute__((deprecated))
                                       ^
3 warnings generated.
ping.c:58:4: warning: declaration does not declare anything [-Wmissing-declarations]
                        uint16_t        __unused;
                        ^~~~~~~~
1 warning generated.
Undefined symbols for architecture x86_64:
  "_StartHTTPing", referenced from:
      _main in cnping-a4c237.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:24: cnping_mac] Error 1

The second error can be reduced to the first with:

diff --git a/Makefile b/Makefile
index 63f799e..b0c9fcc 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ cnping : cnping.o CNFGFunctions.o CNFGXDriver.o os_generic.o ping.o httping.o
 cnping-mousey : cnping-mousey.o CNFGFunctions.o CNFGXDriver.o os_generic.o ping.o
        gcc $(CFLAGS) -o $@ $^ -lX11 -lm -lpthread $(LDFLAGS)

-cnping_mac : cnping.c CNFGFunctions.c CNFGCocoaCGDriver.m os_generic.c ping.c
+cnping_mac : cnping.c CNFGFunctions.c CNFGCocoaCGDriver.m os_generic.c ping.c httping.c
        gcc -o cnping $^ -x objective-c -framework Cocoa -framework QuartzCore -lm -lpthread

 cnping-mousey_mac : cnping-mousey.c CNFGFunctions.c CNFGCocoaCGDriver.m os_generic.c ping.c

Loss statistic

Hi!
I have 2 questions:

  1. Why ping started with 100% loss?
  2. While ping in progress and screen is filled, loss value is jumping about one pixel cost (for example, 0~0.3%)
    I understand that this is not a bug, but rather a small unpleasant features of realization.

Using OpenGL

Ok, fine, @dreua You're right. OpenGL in Windows 10 is WAAAAYY better in just about every way.

This issue is here in case anyone has any issues.

Fix searchnet

Ok, I thought I wouldn't need it anymore, but man it would be super useful right now.

I am super there is no longer any way to say "Please just ping this host once"

Should we link to OpenGL?

I'm not sure what's appropriate behavior on X11, if we should setup rawdraw to use GLX or not. I think we should.

The reason I'm thinking about this is because the CI build is currently failing.

@dreua do you have an opinion here?

Add HTTPing

Need to integrate httping into this, to allow for pinging in environments where icmp is disabled.

cnping_mac blurry text

The text rendered by cnping_mac isn't quite as sharp as in the X11 version (especially on the blue background).

bildschirmfoto 2018-07-26 um 11 35 07
bildschirmfoto 2018-07-26 um 11 35 15

Windows Options Dialog Text is cut off

When running cnping without command-line options on Windows, a dialog is presented to configure the options instead. On my machine, the text looks unusually large (I'm using 100% display scaling, default text sizes, etc). This causes the text to get cut off on the right, and since the window is not resizable, this makes a lot of the options unreadable.

image

(auto) scaling vertical axis

with local ping targets, delays are really small.
might it be useful to add an option to auto scale the vertical axis ?

Precompiled binary

@dreua do you have any plans for how we would distribute cnping.exe? I am temporarily removing it from the .gitignore file, but we should find a better way to distribute, sign, etc.

Every other HTTP ping has a very low (wrong) value for some servers

This depends on the webserver or its configuration, but you can easily find examples, including homerouters or ESP8266s, which reproduce this behavior. I think it has something to do with reusing connections or failure to do so. The ping response values are ridiculously low, probably rather some runtime until the error occurs than an actual ping.

Screenshot_20210606_112425

Release 1.1.0

@cnlohr I'd like to make another release once #87 is merged, probably around the end of this year. I think I'd like to move to Github Actions, too, maybe even as first step. Any objections on your side?

Failed to set TTL option

built from current head

[developer@localhost cnping]$ ./cnping google.com
Error: Failed to set TTL option

strace output:

socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) = -1 EPERM (Operation not permitted)
setsockopt(4294967295, SOL_IP, IP_TTL, [255], 4) = -1 EBADF (Bad file descriptor)
write(2, "Error: Failed to set TTL option\n", 32Error: Failed to set TTL option

Building .exe with Travis CI

Hey,
I wanted to learn how Travis CI works and cnping came in handy as a test subject: I managed to build it on their servers and as a bonus upload the .exe to the releases page. (The exe works on Windows 10 as expected.)

If you want to integrate this in your main branch you have to sign up to Travis CI (which is free and really easy) and take my .travis.yml and customize it to your repository. (change api_key.secure, repo and branch)

I am not sure if this is worth the effort so please feel free to just close this in case you are not interested. I can provide more information, links and help if needed.

Making a release

Hey, could you start adding git tags with some kind of a versioning scheme? I'd like to package this for voidlinux, but they don't accept packages without versions. This would also be a requirement for a bunch of other distros, as mentioned in #49.

Signed exe

Is there a possibility of getting a signed exe created? I have tried self-signing on windows with no luck so far, I think I am using the wrong type of certificate, I haven't done it before. I am probably the only one using this on windows so I know it's unlikely, but I thought I would ask.

can't compile on Mac OS 10.9.5 - unknown type name n_short and n_time

make
cc  -g -Os   -c -o cnping.o cnping.c
In file included from cnping.c:13:
/usr/include/netinet/ip_icmp.h:92:4: error: unknown type name 'n_short'; did you
      mean 'u_short'?
                        n_short icd_id;
                        ^
/usr/include/sys/types.h:85:25: note: 'u_short' declared here
typedef unsigned short          u_short;
                                ^
In file included from cnping.c:13:
/usr/include/netinet/ip_icmp.h:93:4: error: unknown type name 'n_short'; did you
      mean 'u_short'?
                        n_short icd_seq;
                        ^
/usr/include/sys/types.h:85:25: note: 'u_short' declared here
typedef unsigned short          u_short;
                                ^
In file included from cnping.c:13:
/usr/include/netinet/ip_icmp.h:99:4: error: unknown type name 'n_short'; did you
      mean 'u_short'?
                        n_short ipm_void;
                        ^
/usr/include/sys/types.h:85:25: note: 'u_short' declared here
typedef unsigned short          u_short;
                                ^
In file included from cnping.c:13:
/usr/include/netinet/ip_icmp.h:100:4: error: unknown type name 'n_short'; did
      you mean 'u_short'?
                        n_short ipm_nextmtu;
                        ^
/usr/include/sys/types.h:85:25: note: 'u_short' declared here
typedef unsigned short          u_short;
                                ^
In file included from cnping.c:13:
/usr/include/netinet/ip_icmp.h:121:4: error: unknown type name 'n_time'
                        n_time its_otime;
                        ^
/usr/include/netinet/ip_icmp.h:122:4: error: unknown type name 'n_time'
                        n_time its_rtime;
                        ^
/usr/include/netinet/ip_icmp.h:123:4: error: unknown type name 'n_time'
                        n_time its_ttime;
                        ^
/usr/include/netinet/ip_icmp.h:126:14: error: field has incomplete type
      'struct ip'
                        struct ip idi_ip;
                                  ^
/usr/include/netinet/ip_icmp.h:126:11: note: forward declaration of 'struct ip'
                        struct ip idi_ip;
                               ^
8 errors generated.
make: *** [cnping.o] Error 1

cnping makes Xorg to 100% single core CPU usage

I've updated cnping 5 days ago from AUR repo, and newer version makes Xorg eat 100% cpu time for one core...

$ uname -a
Linux msi 4.19.118-1-MANJARO #1 SMP Thu Apr 23 10:54:30 UTC 2020 x86_64 GNU/Linux

support Visual Studio 2015

I have managed to compile the project with VS2015 by changing some code. I would like to push my code if it's permitted. Thanks.

some of the change is as below:

diff --git a/cnping.c b/cnping.c
index e8af643..567f596 100644
--- a/cnping.c
+++ b/cnping.c
@@ -1,5 +1,12 @@
 //Copyright (c) 2011-2019 <>< Charles Lohr - Under the MIT/x11 or NewBSD License you choose.

+#if defined( WIN32 ) || defined( WINDOWS )
+#if !defined( MINGW_BUILD ) && !defined( TCC )
+#define _CRT_SECURE_NO_WARNINGS
+#pragma warning(disable:4244 4996)
+#endif
+#endif //WIN32
+
 #define VERSION "1.0.0"

 #include <stdio.h>
@@ -282,9 +289,15 @@ void DrawFrameHistogram()
                slots = slotsmax - slotsmin;
                if( slots <= 0 ) goto nodata;

+#if defined(WIN32) && defined(_MSC_VER)
+               uint64_t *samples = _alloca((slots + 2)*sizeof(uint64_t));
+               int      *ssmsMIN = _alloca((slots + 2)*sizeof(int));
+               int      *ssmsMAX = _alloca((slots + 2)*sizeof(int));
+#else
                uint64_t samples[slots+2];
                int      ssmsMIN[slots+2];
                int      ssmsMAX[slots+2];
+#endif //WIN32 && _MSC_VER
                int samp = minpingslot - 1;

                if( slots <= 1 ) goto nodata;

FreeBSD Support

Used it on Windows and liked the tool, now wanted to port it to my freebsd machine. Changes aren't intrusive (i.e. a few ifdefs to add headers) but if anyone objects I can just leave it as a fork

Changes are in this PR: #56

New Icon?

Hey, i made a new icon for cnping.
(party because i didn't saw an icon on my setup and thought there was none. But i think i just messed up the install)

What do you guys think? Should this simplified icon replace the current one?
Its an svg. So its scaleable and can be exported to every required size as png. But AFAIK most distros prefer svg anyways.
cnping_icon

cnping shows up as "Unknown" without icon in Gnome's Task Switcher

This screenshot is already with a fix applied, previously it just displayed "Unknown". We can at least set the name by re-using some previously commented code in rawdraw. I think this would need an interface in rawdraw, to set the window class name to the desired value. I'm not sure how if and how this should be added to the rawdraw API so tell me what you think.

cnping_task_switcher

Here's the code to change: https://github.com/cntools/rawdraw/blob/2eeb8a650d54232d895b1259f4b0ff83850dac9a/CNFGXDriver.c#L147-L162

Icon

From what I just read on that topic, we would need to install a .desktop file so that Gnome can match the executable to it and use the icon specified there. And we would need an actual icon of course ;)

Port to Android

Hay ;)

I really like your cnping on PC,

Would it be possible to port it to Android?
It would be really handy to have it mobile for wireless testing.
Unfortunately i do not have the skills to figure it out on my own,

thanks in advance for your help
McC

Warn when using https://

It would be nice to get a warning when trying to ping https:// because as of now, it says the hostname can't be resolved. (It can't because DNS doesn't now https://example.com.)
I think we could catch anything containing : or // when not http:// and warn about not supported protocol.

Segmentation fault error

Build it on Android with cli tools (Terminal). But when it runs it displays segmentation fault .Maybe Android doesn't have any X11 .Or I can't use the programme properly.

Cuping in Android

HTTP thread gets maxed out

Running the command: "cnping http://192.168.1.1/" where 192.168.1.1 is my Netgear router causes CNping to max out one of it's threads. It works fine when pinging google on HTTP. It might have something to do with my router rate limiting. This is definitely an edge case but probably worth fixing. The framerate goes to ~3 seconds per frame.

Odd pattern
image
12.5% is one thread maxed out on a hyperthreaded quad-core.
image

Accessing webinterface not possible

Hi after flashing the 2 bin files all works well except the bad thing that i cant access the webinterface under 192.168.4.1, the site tells me file not found ( in the left corner, not the site is not available thing). THX in advance cyberkr33k

Instructions for compiling on Ubuntu

Just thought I'd contribute the packages needed to compile on Ubuntu 15.04:
sudo apt install libxinerama-dev libxext-dev libx11-dev build-essential
followed by
make

Perhaps they could be added to the README?

Segmentation fault on Linux

Hi I've use Debian GNU/Linux 8.10 (jessie)
Linux ... 3.16.0-5-amd64 #1 SMP Debian 3.16.51-3+deb8u1 (2018-01-08) x86_64 GNU/Linux
gcc version 4.9.2 (Debian 4.9.2-10)
Package: libxinerama-dev -> Version: 2:1.1.3-1+b1
Package: libxext-dev -> Version: 2:1.3.3-1
Package: libx11-dev -> Version: 2:1.6.2-3+deb8u1

I've done the following steps:
make clean
make cnping
(getting some unimportent warnings)
./cnping -h 8.8.8.8
Segmentation fault

[2388738.529645] cnping[6511]: segfault at e8 ip 00000000004029fd sp 00007ffefaf33a80 error 4 in cnping[400000+6000]

Same as root.

Do you have an idea?

Warnings from make cnping:
cc -g -Os -I/opt/X11/include -Wall -c -o cnping.o cnping.c
cc -g -Os -I/opt/X11/include -Wall -c -o CNFGFunctions.o CNFGFunctions.c
cc -g -Os -I/opt/X11/include -Wall -c -o CNFGXDriver.o CNFGXDriver.c
CNFGXDriver.c: In function ‘CNFGHandleInput’:
CNFGXDriver.c:217:6: warning: variable ‘r’ set but not used [-Wunused-but-set-variable]
int r;
^
CNFGXDriver.c: In function ‘CNFGUpdateScreenWithBitmap’:
CNFGXDriver.c:267:9: warning: variable ‘ls’ set but not used [-Wunused-but-set-variable]
int r, ls;
^
CNFGXDriver.c:267:6: warning: unused variable ‘r’ [-Wunused-variable]
int r, ls;
^
CNFGXDriver.c:266:25: warning: unused variable ‘lbuffer’ [-Wunused-variable]
static unsigned char * lbuffer;
^
cc -g -Os -I/opt/X11/include -Wall -c -o os_generic.o os_generic.c
cc -g -Os -I/opt/X11/include -Wall -c -o ping.o ping.c
ping.c: In function ‘ping’:
ping.c:155:21: warning: unused variable ‘r_addr’ [-Wunused-variable]
struct sockaddr_in r_addr;
^
ping.c:154:6: warning: unused variable ‘i’ [-Wunused-variable]
int i, cnt=1;
^
ping.c:152:12: warning: unused variable ‘val’ [-Wunused-variable]
const int val=255;
^
cc -g -Os -I/opt/X11/include -Wall -c -o httping.o httping.c
gcc -g -Os -I/opt/X11/include -Wall -o cnping cnping.o CNFGFunctions.o CNFGXDriver.o os_generic.o ping.o httping.o -lX11 -lm -lpthread -g -L/opt/X11/lib/

Current master version doesn't work on Windows 10 (VM)

Working on #82 I stumbled upon this other bug.

Something somewhere introduced a change that makes cnping just show up with a grey frame on my Windows 10 VM. It stays like that and quits after some time

Some bisecting later, I'm quite sure it is cntools/rawdraw@8801832

Can someone provide more data points, like whether it does or doesn't work for you?

Coding style

Reviewing the latest pull request, I noticed (agian) that the code is a bit messy, the placement of braces and parentheses is unusual (at least to my eyes) and inconsistent throughout the project. I'd like to clean that up a bit to ease further development and maintenance.
@cnlohr do you have a preferred coding style for your projects?

A full run of clang-format changes almost every line, I'm not sure that is what we want. I could probably create a .clang-format configuration changing just the stuff that is annoying me the most, would that be a good idea?

Segfault, "No protocol specified"

Hi, I recently upgraded to Ubuntu 17.10 which uses Wayland instead of X11. cnping used to work before the upgrade, and now it doesn't. I freshly installed cnping from source to make sure I got the latest version, but it segfaults after saying "No protocol specified". Screenshot below.
screenshot from 2018-01-23 20-53-50

If you need anything, my grahpics settings etc, just leave a comment. Thanks!

IPv6 support

I'm not sure how much work this is, but it would be a nice addition and it will be needed some day...

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.