0

In my network I have one linux host as a default gateway located at 192.168.150.1. On another host at 192.168.150.4 I have this script to measure time between sending an arp request and receiving it:

#!/usr/bin/env bash

for i in $(seq 30 $END); do
        sudo ifconfig enp3s0 up
        sleep 5s;
        arping -I enp3s0 -c 1 192.168.150.1
        echo $(date +%s.%5N) | tee -a ./ifuptimes.txt;
        sleep 55s;
        sudo ifconfig enp3s0 down;
        sleep 1m;
done;

Strangely, when sending arping in the script the target at 192.168.150.1 responds to it only occasionally whereas when manually running it in terminal gets a response every time. Why does this happen and how can I fix it?

Fleuri
  • 255
  • 3
  • 12

2 Answers2

1

Turns out 5s interval between enabling the interface and sending an arp request is not enough for the interface to be ready (My empirical testing gives approximately ten seconds). Increasing the interval caused the script to work correctly.

Fleuri
  • 255
  • 3
  • 12
0

I have this script to measure time between sending an arp request and receiving it

Maybe it would be better to start wireshark (or tcpdump), drop the arp-table and run arping. In wireshark you can see the arp request and arp response including the times.

I hope this helps you.

Why do you disconnect the ethernet interface and run it in a loop?

I would guess the problem is based on ifup is to slow or something like that (DHCP, ...).

Why not "cron" or "at" or "watch"?

User8461
  • 101
  • 2
  • Yes, I also figured that it was because of the interface not being ready and arping thus failing silently. Increasing the time between enabling the interface and sending the arp solved the problem. – Fleuri Mar 07 '19 at 19:30