lukasz.bromirski.net

aviate, navigate, communicate

ip sla and shell scripting

i had a problem yesterday - i needed to generate at least a dozen packets per second minimum between two connected devices (without ability to insert PC or traffic generator between them - that was Catalyst 3550 and 4900M). traffic needed to be exchanged over a time frame of several hours, so ping from console line wasn’t feasible either.

the solution was pretty straightfoward - IP SLA.

as Catalyst 4900M was to be under test, on Catalyst 3550 i created two VRFs:

ip vrf TEST100
 rd 100:100

ip vrf TEST200
 rd 200:200

then on Fa0/17 and Fa0/18 of Catalyst 3550 i created IP interfaces and added VRF routing information:

interface fa0/17
 no switchport
 ip vrf forwarding TEST100
 ip address 10.10.100.254 255.255.255.0

interface fa0/18
 no switchport
 ip vrf forwarding TEST200
 ip address 10.10.200.254 255.255.255.0

ip route vrf TEST100 0.0.0.0 0.0.0.0 10.10.100.1
ip route vrf TEST200 0.0.0.0 0.0.0.0 10.10.200.1

on the Catalyst 4900M side config was pretty similar, minus the VRF trick:

interface Gi2/1
 no switchport
 ip address 10.10.100.1 255.255.255.0

interface Gi2/2
 no switchport
 ip address 10.10.200.1 255.255.255.0

ip routing

so i had “lab” setup running, the only thing left was IP SLA. as Catalyst 3550 can generate maximum of 1pps for single IP SLA, i had to generate couple of them. so, shell-level scripting came to rescue:

#!/usr/local/bin/bash

echo > ipsla_vrf.txt

for (( x=100; x<=199; x++ ))
do
 echo "ip sla $x" >> ipsla_vrf.txt
 echo " icmp-echo 10.10.200.254 source-ip 10.10.100.254" >> ipsla_vrf.txt
 echo " request-data-size 1400" >> ipsla_vrf.txt
 echo " timeout 15" >> ipsla_vrf.txt
 echo " vrf TEST100" >> ipsla_vrf.txt
 echo " frequency 1" >> ipsla_vrf.txt
 echo "ip sla schedule $x life forever start-time now" >> ipsla_vrf.txt
 echo " " >> ipsla_vrf.txt
done

for (( x=200; x<=299; x++ ))
do
 echo "ip sla $x" >> ipsla_vrf.txt
 echo " icmp-echo 10.10.100.254 source-ip 10.10.200.254" >> ipsla_vrf.txt
 echo " request-data-size 1400" >> ipsla_vrf.txt
 echo " timeout 15" >> ipsla_vrf.txt
 echo " vrf TEST200" >> ipsla_vrf.txt
 echo " frequency 1" >> ipsla_vrf.txt
 echo "ip sla schedule $x life forever start-time now" >> ipsla_vrf.txt
 echo " " >> ipsla_vrf.txt
done

once you have it in the ipsla_vrf.txt file, you can copy & paste it to Catalyst 3550 console. while it generated 30% CPU load when starting, it was solid 200 probes per second. that was quick, dirty and made all the difference i needed at the moment.


Share