Closed tolysz closed 10 years ago
What are you trying to do? This changes the semantics of -c from "perform this many attempts" to "wait for this many replies" without waiting to see if the last reply had any duplicates. But it only does this for pinging MAC addresses.
The -c
in conjunction with -w
is what I want to get i.e. terminate on whichever event will occur first either we reach the count or the timeout.
The patch only affects the the pingmac which is highly unlikely to have duplicates i.e. two identical MAC addresses having a different address each. The semantic for normal pingip was unchanged.
Sounds like you actually want just the first reply, and a different feature from simply throwing -w and -c together.
:) Yes, I want just the first reply -c 1
but with -c 10
will it be the first 10 replies:
arping -i eth0 -w 30000000 -qrc10 'FF:FF:FF:FF:FF:FF'
would print first 10 IP addresses on the net or wait 30s whichever will be first.
So I guess it needs to be some new option i.e.
-C n
only listen the first n responses
(but funny enough numrecvd@pingmac_recv
counts just that)
If you're not in a hurry you can just do: arping -c 10 -r | head -1
But otherwise it sounds like "exit at first reply", without parameters should work.
arping -i eth0 -w 10000000 -qrc1 'FF:FF:FF:FF:FF:FF' | head -1
Does print 1 line but after waiting 10s
stdbuf -o 0 arping -i eth0 -w 10000000 -qrc1 'FF:FF:FF:FF:FF:FF' | head -1
quits aftrer 1 but only because it still has something to write thus is killed by SIGPIPE
stdbuf -o 0 arping1 -i eth0 -w 10000000 -qrc1 '01:23:45:67:89:AB' | head -1
print 1 line then waits 10s (as is not killed because is not writing)
There is a new pull which adds -C n
Sorry for the delay. I've been thinking about how this feature should best be implemented, and if needs a "wait for a total of X time" as well, and how that should look.
This was bug #13. I've implemented something close to this pull request, replacing it. Thanks.
https://github.com/ThomasHabets/arping/commit/850c5a4b81969956efef6ed30a0df47bd57afe7c
Nice.
Make
arping -c n
exit after receiving n IPsarping -i eth0 -w 3000000 -qrc1 '00:11:22:33:44:55'
will try at most for 3 seconds to get the IP.