Compile a modified ping

jonmcg

New Member
Joined
Jan 22, 2021
Messages
8
Reaction score
0
Credits
55
I would like to get ping to output data differently to how it currently does. I have installed the source and headers but have no idea what options gcc needs to compile ping.c.
Any help appreciated.
 


I am using a Raspberry PI at the moment and used rpi_source
 
The ping command has a good set of options to adjust output. You could first try some selective arguments for ping and set up an alias.

Depending, of course on your goal for how the output looks.
 
Maybe some idea of what you are expecting your version of ping to do would be helpful!
 
It will not help. I want ping to do 2 different IP addresses at same time.
 
I can't help with that, as my coding skills have long since faded, but there are a lot of very good folks. Maybe ask in one of the other forums here.
 
This forum will work, although we're not specifically focused at coding. However, I do code, so I can help you. :)

Look at the source directory tree. If you see a file "CMakeLists.txt", you'll need to build with CMake. If you see a file called "Makefile", you'll need to use Make (unless there is also a CMakeLists.txt, in which case the Makefile is probably auto-generated and not for your use). If there is a script called "configure", you'll want to do the
Code:
./configure
make
# optional
sudo make install
routine.

If you're not sure which route to take, please post back the results of running ls in the source directory.
 
You can do this with nping which is part of the nmap package.
nping -c 2 8.8.8.8 8.8.4.4

Starting Nping 0.7.91 ( https://nmap.org/nping ) at 2021-01-24 10:10 CET
SENT (0.0197s) ICMP [10.31.251.11 > 8.8.8.8 Echo request (type=8/code=0) id=50352 seq=1] IP [ttl=64 id=62756 iplen=28 ]
RCVD (0.0279s) ICMP [8.8.8.8 > 10.31.251.11 Echo reply (type=0/code=0) id=50352 seq=1] IP [ttl=117 id=0 iplen=28 ]
SENT (1.0199s) ICMP [10.31.251.11 > 8.8.8.8 Echo request (type=8/code=0) id=50352 seq=2] IP [ttl=64 id=62756 iplen=28 ]
RCVD (1.0279s) ICMP [8.8.8.8 > 10.31.251.11 Echo reply (type=0/code=0) id=50352 seq=2] IP [ttl=117 id=0 iplen=28 ]
SENT (2.0210s) ICMP [10.31.251.11 > 8.8.8.8 Echo request (type=8/code=0) id=50352 seq=2] IP [ttl=64 id=62756 iplen=28 ]
RCVD (2.0306s) ICMP [8.8.8.8 > 10.31.251.11 Echo reply (type=0/code=0) id=50352 seq=2] IP [ttl=117 id=0 iplen=28 ]
SENT (3.0217s) ICMP [10.31.251.11 > 8.8.4.4 Echo request (type=8/code=0) id=39122 seq=2] IP [ttl=64 id=62756 iplen=28 ]
RCVD (3.0305s) ICMP [8.8.4.4 > 10.31.251.11 Echo reply (type=0/code=0) id=39122 seq=2] IP [ttl=117 id=0 iplen=28 ]

Statistics for host 8.8.8.8:
| Probes Sent: 2 | Rcvd: 3 | Lost: -1 (922337203685477580800.00%)
|_ Max rtt: 1008.116ms | Min rtt: 8.146ms | Avg rtt: 341.922ms
Statistics for host 8.8.4.4:
| Probes Sent: 2 | Rcvd: 1 | Lost: 1 (50.00%)
|_ Max rtt: 8.712ms | Min rtt: 8.712ms | Avg rtt: 8.712ms
Raw packets sent: 4 (112B) | Rcvd: 4 (184B) | Lost: 0 (0.00%)
Nping done: 2 IP addresses pinged in 3.06 seconds
 
LorenDB post may get me there. If I run make from the linux source directory and wait a few hours I see it compiles ping but I don't know if it links it, ie there is ping.o. The make puts out very little info on what the gcc command it is using. I don't see a log file anywhere but it may exist and there may be an option to make that will output more detail but have not found it yet.
 
make V=1 has given me a lot of stuff so hopefully can extract what I need to compile my own ping or work out where it puts the executable and then just change the original ping.c
 
I want to do conditional analysis and ping continually depending on results of the previous pings. I need to do computation on the results. It is more of an interest if I can get a version of ping to do this . I can do it by writing a program to call ping with the right arguments but wondered how hard it would be to change what ping does.
 

Members online


Top