Skip to content

Commit

Permalink
Add ping mac examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHabets committed Jun 13, 2024
1 parent d8b725a commit b160738
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/run
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ run_test() {


CAP="$(mktemp)"
# TODO: in the future also capture icmp. But we need regex matching for that.
ip netns exec arping_test1 \
tcpdump \
-s0 \
-nlpi veth1 \
--immediate-mode \
-w "${CAP?}" arp \
-w "${CAP?}" \
arp \
2>/dev/null &
PID=$!

Expand Down Expand Up @@ -100,11 +102,19 @@ run_tests() {
run_test "h" 0 -h
run_test "help" 0 --help

# Simple examples.
# Simple IP examples.
run_test "simple" 0 -c 1 192.0.2.101
run_test "simple_verbose" 0 -v -c 1 192.0.2.101
run_test "no_reply" 1 -c 1 192.0.2.1

# Simple MAC examples.
run_test "simplemac_timeout" 1 -c 1 -i veth0 00:01:02:33:44:01
run_test "simplemac_target" 0 -c 1 -T 192.0.2.101 00:01:02:33:44:01

ip netns exec arping_test1 sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=0
run_test "simplemac_noignore" 0 -c 1 -i veth0 00:01:02:33:44:01
ip netns exec arping_test1 sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1

# TODO: ping mac address.

# -0
Expand Down
6 changes: 6 additions & 0 deletions tests/simplemac_noignore.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARPING 00:01:02:33:44:01
62 bytes from 192[.]0[.]2[.]101 \(00:01:02:33:44:01\): icmp_seq=0 time=\d+[.]\d+ usec

--- 00:01:02:33:44:01 statistics ---
1 packets transmitted, 1 packets received, 0% unanswered \(0 extra\)
rtt min/avg/max/std-dev = 0[.]\d+/0[.]\d+/0[.]\d+/0[.]000 ms
6 changes: 6 additions & 0 deletions tests/simplemac_target.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARPING 00:01:02:33:44:01
62 bytes from 192[.]0[.]2[.]101 \(00:01:02:33:44:01\): icmp_seq=0 time=\d+[.]\d+ usec

--- 00:01:02:33:44:01 statistics ---
1 packets transmitted, 1 packets received, 0% unanswered \(0 extra\)
rtt min/avg/max/std-dev = 0[.]\d+/0[.]\d+/0[.]\d+/0[.]000 ms
4 changes: 4 additions & 0 deletions tests/simplemac_timeout.cap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
IP 192.0.2.100 > 255.255.255.255: ICMP echo request, id 27006, seq 0, length 28
0x0000: 4500 0030 697e 0000 4001 4eeb c000 0264
0x0010: ffff ffff 0800 113f 697e 0000 06f7 0000
0x0020: 0000 0000 b25a f716 0000 0000 fabf d219
5 changes: 5 additions & 0 deletions tests/simplemac_timeout.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARPING 00:01:02:33:44:01
Timeout

--- 00:01:02:33:44:01 statistics ---
1 packets transmitted, 0 packets received, 100% unanswered \(0 extra\)

0 comments on commit b160738

Please sign in to comment.