Automation

Scripting How-To: Send a series of pings to a remote host to troubleshoot MTU/MSS issues

By Elevate posted 11-19-2015 12:45

  
This applies to SLAX version 1.1 and higher.
 

Overview

Send a series of ping to remote-host, useful for troubleshooting MTU/MSS issues.

 

Description

 

Automatically send a series of pings to the remote host. Subsequent pings send packets of increasing size so that transmission size issues are detected.

 

What it Does

 

This script sends a series of pings to a remote host, starting with a packet size of $min-size.The size of the packet is increased with each ping by specified $step increments until it reaches $max-size. The results are useful for troubleshooting issues related to maximum transmission unit (MTU) or maximum segment size (MSS).

 

Set Up

 

  1. Copy the op-pingsweep.slax script to the /var/db/scripts/op directory on the router.
  2. Enable the script by adding the file statement and script filename to the [edit system scripts op] hierarchy level in the configuration. Only superusers can enable scripts in the configuration.
    [edit system scripts op]
    user@host# set file op-pingsweep.slax
  3. Commit the configuration:
    [edit]
    user@host# commit and-quit

 

How to Run

 

  1. To run this script, issue the command op op-pingsweep from the CLI operational mode:
  2. user@host> op op-pingsweep remote-host <hostname>
    Note: The argument remote-host is mandatory. Optional arguments are min-size, max-size, and step. The default values for the optional arguments are:
    • min-size = 1400
    • max-size = 1600
    • step = 100
  3. The output will appear similar to this:
    user@cli> op pingsweep remote-host waffy min-size 1400 max-size 1600 step 100
    
    Executing command: ping waffy size 1400 count 1 do-not-fragment
    Ping Success!!!
    
    Executing command: ping waffy size 1500 count 1 do-not-frament
    Ping Success!!!
    
    Executing command: ping waffy size 1600 count 1 do-not-frament
    Ping Failed!!!
    
  4. To see a list of all arguments for the script, type “?” after the command op op-pingsweep:
    user@host> op op-pingsweep ?
    
    Possible completions:
    <[Enter]>         Execute this command
    <name>            Argument name
    detail            Display detailed output
    max-size          Maximum packet size
    min-size          Minimum packet size
    remote-host       Host name or ip-address to ping
    step              Packet size difference

Source Code

 

 

Example Output

 

user@cli> op pingsweep remote-host waffy min-size 1400 max-size 1600 step 100

Executing command: ping waffy size 1400 count 1 do-not-fragment
Ping Success!!!

Executing command: ping waffy size 1500 count 1 do-not-frament
Ping Success!!!

Executing command: ping waffy size 1600 count 1 do-not-frament
Ping Failed!!!

 

SLAX Script Contents

 

/*
 * Op script to send series of pings to remote-host, each one increasing in
 * size, may be useful for troubleshooting MTU/MSS issues.
 *
 * Size of the packet starts from $min-size, increases by $step and
 * ends at $max-size
 * 
 * E.g
 * user1@chennai> op pingsweep remote-host waffy min-size 1400 max-size 1600
 *                  step 100
 *    Executing command: ping waffy size 1400 count 1 do-not-fragment
 *    Ping Success!!!
 *    Executing command: ping waffy size 1500 count 1 do-not-fragment
 *    Ping Failed!!!
 *    Executing command: ping waffy size 1600 count 1 do-not-fragment
 *    Ping Failed!!!
 */ 

version 1.1;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

var $arguments = {
    <argument> {
	<name> "remote-host";
	<description> "Host name or ip-address to ping";
    }
    <argument> {
	<name> "min-size";
	<description> "Minimum packet size";
    }
    <argument> {
	<name> "max-size";
	<description> "Maximum packet size";
    }
    <argument> {
	<name> "step";
	<description> "Packet size difference";
    }
}

param $remote-host;
param $min-size;
param $max-size;
param $step;

match / {

    call ping($remote-host, $cur-size = $min-size, $max-size, $step);

}

template ping ($remote-host, $cur-size, $max-size, $step) {

    if ($cur-size <= $max-size) {
	var $ping-rpc = {
	    <ping> {
		<host> $remote-host;
		<size> $cur-size;
		<count> 1;
		<do-not-fragment>;
	    }
	}

        expr jcs:output("Executing command: ping ", $remote-host, " size ", 
			 $cur-size, " count 1 do-not-fragment");

	var $ping-out = jcs:invoke($ping-rpc);

	if ($ping-out/ping-success) {
	    expr jcs:output("Ping Success!!!");
	} else {
	    expr jcs:output("Ping Failed!!!");
	}

    	call ping($remote-host, $cur-size = $cur-size + $step, $max-size, 
		  $step);
    }
}

 

XML Script Contents

 

<?xml version="1.0"?>
<script>
  <title>op-pingsweep.slax</title>
  <author>rsankar</author>
  <synopsis>
	Send a series of ping to remote-host, useful for troubleshooting MTU/MSS issues
  </synopsis>
  <coe>op</coe>
  <type>diagnose</type>

  <description>
This script performs pings to remote-host, which may be useful for troubleshooting MTU/MSS issues.
Size of the packet starts from $min-size, increases by $step and ends at $max-size.

  </description>

  <example>
    <title>Sample Output</title>
    <description>Output of "op pingsweep" command</description>
    <output>example-1.output</output>
  </example>

  <xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml"
                src="../../../../../web/leaf.js" 
	        type="text/javascript"/>
</script>

#MTUMSS
#ping
#How-To
0 comments
0 views

Permalink