Monday, February 11, 2013

Measuring one-way network latency, jitter and packet loss on Linux

Ping can tell you round-trip or two-way latency, but if you want to know if it's upstream of downstream that's slowing down you need something else. You need OWAMP (One-Way Ping).



Below are my notes from setting up OWAMP on Ubuntu 12.10.

# Install ntp
apt-get update
apt-get -y install ntp


# Reconfigure NTP, remove default time sources
sed -i.bak /etc/ntp.conf \
    -e's/^server/#server/g'

# Use fixed list of time sources common for all our nodes
# You don't really need that many and likely don't want to
# use these as they're all in Finland and Sweden.
cat<<'__EOF__'>>/etc/ntp.conf
server 217.152.236.195  # time1.mikes.fi      (Stratum 2)
server 212.68.17.195    # time2.mikes.fi      (Stratum 2)
server 192.89.123.26    # ntp1.inet.fi        (Stratum 3)
server 192.89.123.230   # ntp2.inet.fi        (Stratum 3)
server 192.89.123.231   # ntp3.inet.fi        (Stratum 3)
server 194.100.2.194    # ntp1.tdc.fi         (Stratum 1) PPS
server 62.237.86.234    # ntp2.tdc.fi         (Stratum 1) PPS
server 62.237.86.238    # ntp3.tdc.fi         (Stratum 1) PPS
server 194.100.2.198    # ntp4.tdc.fi         (Stratum 1) GPS
server 62.142.10.44     # ntp1.saunalahti.fi  (Stratum 1) PPS
server 192.36.144.22    # ntp1.sth.netnod.se  (Stratum 1) PPS
server 192.36.144.23    # ntp2.sth.netnod.se  (Stratum 1) PPS
server 192.36.143.150   # time1.stupi.se      (Stratum 1) PPS
server 192.36.143.151   # time2.stupi.se      (Stratum 1) PPS
server 192.36.143.152   # time3.stupi.se      (Stratum 1) GPS
server 192.36.143.153   # time4.stupi.se      (Stratum 1) PPS
server 192.36.143.154   # time5.stupi.se      (Stratum 1) PPS
__EOF__

# Enable NTP on boot
update-rc.d ntp enable

# Restart with new settings
service ntp stop
service ntp start

# Check status, will stabilize after few minutes
ntpq -c peers
ntpq -c associations


# Grab OWAMP source
mkdir -p /opt/src/owamp
cd /opt/src/owamp
wget http://software.internet2.edu/sources/owamp/owamp-3.3rc1.tar.gz

# Compile and install
tar xvzf owamp-3.3rc1.tar.gz
cd owamp-3.3rc1
./configure --prefix=/opt
make
make install

# Add /opt to path
echo "/opt/lib" >>/etc/ld.so.conf
ldconfig
sed -i.bak /etc/environment -e's|PATH="|PATH="/opt/sbin:/opt/bin:|g'
export PATH=/opt/sbin:/opt/bin:$PATH

# Create config files to only listen on private ips
mkdir -p /opt/etc
touch /opt/etc/owampd.conf
cat<<'__EOF__'>/opt/etc/owampd.limits
limit root with disk=1000M,bandwidth=0,delete_on_fetch=on,allow_open_mode=off
limit noc with parent=root,allow_open_mode=on
assign net 127.0.0.1/32 noc
assign net 10.0.0.0/8 noc
__EOF__

# Launch owampd on next boot
sed -i.bak /etc/rc.local -e's/^exit 0/#exit 0/'
echo "/opt/bin/owampd -c /opt/etc-d /tmp -R /var/run -G nogroup -U nobody" >>/etc/rc.local

# Plus once right now on foreground for testing
/opt/bin/owampd -c /opt/etc -d /tmp -R /var/run -G nogroup -U nobody -v -Z 

# Test upstream latency to another PC with identical setup
owping -c100 -i0.1 -L10 -s0 -t -AO -nm -S10.100.1.15 10.10.1.10

--- owping statistics from [10.100.1.15]:50578 to [10.10.1.10]:50441 ---
SID:    0a0a010ad4c3dcf7620bef80c9e5e726
first:  2013-02-11T23:11:20.804
last:   2013-02-11T23:11:29.847
100 sent, 2 lost (2.000%), 0 duplicates
one-way delay min/median/max = 33.2/52.2/72.4 ms, (err=9.06 ms)
one-way jitter = 18.6 ms (P95-P50)
Hops = 1 (consistently)
no reordering
# There's WANEM network emulator between 10.100.1.15 and 10.10.1.10.
# It's configured for 50ms latency with 20ms jitter and 2% loss on upstream.
# Docs
# http://www.internet2.edu/pubs/owamp-cookbook.pdf

No comments:

Post a Comment

Got something to say?!