Overview
Send a series of pings to remote-host, useful for troubleshooting MTU/MSS issues. This applies to SLAX version 1.1 and higher.
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
- Copy the op-pingsweep.slax script to the /var/db/scripts/op directory on the router.
- 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.
1 |
[edit system scripts op ] |
- Commit the configuration:
How to Run
- To run this script, issue the command op op-pingsweep from the CLI operational mode:
1 |
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
- The output will appear similar to this:
01 |
user@cli> op pingsweep remote - host waffy min - size 1400 max - size 1600 step 100 |
03 |
Executing command: ping waffy size 1400 count 1 do - not - fragment |
06 |
Executing command: ping waffy size 1500 count 1 do - not - frament |
09 |
Executing command: ping waffy size 1600 count 1 do - not - frament |
- To see a list of all arguments for the script, type “?” after the command op op-pingsweep:
01 |
user@host> op op -pingsweep ? |
04 |
<[Enter]> Execute this command |
06 |
detail Display detailed output |
07 |
max-size Maximum packet size |
08 |
min-size Minimum packet size |
09 |
remote-host Host name or ip-address to ping |
10 |
step Packet size difference |
Source Code
GitHub Links
Example Output
01 |
user@cli> op pingsweep remote - host waffy min - size 1400 max - size 1600 step 100 |
03 |
Executing command: ping waffy size 1400 count 1 do - not - fragment |
06 |
Executing command: ping waffy size 1500 count 1 do - not - frament |
09 |
Executing command: ping waffy size 1600 count 1 do - not - frament |
SLAX Script Contents
01
/*
02
* Op script to send series of pings to remote-host, each one increasing in
03
* size, may be useful for troubleshooting MTU/MSS issues.
04
*
05
* Size of the packet starts from $min-size, increases by $step and
06
* ends at $max-size
07
*
08
* E.g
09
* user1@chennai> op pingsweep remote-host waffy min-size 1400 max-size 1600
10
* step 100
11
* Executing command: ping waffy size 1400 count 1 do-not-fragment
12
* Ping Success!!!
13
* Executing command: ping waffy size 1500 count 1 do-not-fragment
14
* Ping Failed!!!
15
* Executing command: ping waffy size 1600 count 1 do-not-fragment
16
* Ping Failed!!!
17
*/
18
19
version 1.1;
20
21
ns junos = "http://xml.juniper.net/junos/*/junos";
22
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
23
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
24
25
import "../import/junos.xsl";
26
27
var $arguments = {
28
<argument> {
29
<name> "remote-host";
30
<description> "Host name or ip-address to ping";
31
}
32
<argument> {
33
<name> "min-size";
34
<description> "Minimum packet size";
35
}
36
<argument> {
37
<name> "max-size";
38
<description> "Maximum packet size";
39
}
40
<argument> {
41
<name> "step";
42
<description> "Packet size difference";
43
}
44
}
45
46
param $remote-host;
47
param $min-size;
48
param $max-size;
49
param $step;
50
51
match / {
52
53
call ping($remote-host, $cur-size = $min-size, $max-size, $step);
54
55
}
56
57
template ping ($remote-host, $cur-size, $max-size, $step) {
58
59
if ($cur-size <= $max-size) {
60
var $ping-rpc = {
61
<ping> {
62
<host> $remote-host;
63
<size> $cur-size;
64
<count> 1;
65
<do-not-fragment>;
66
}
67
}
68
69
expr jcs:output("Executing command: ping ", $remote-host, " size ",
70
$cur-size, " count 1 do-not-fragment");
71
72
var $ping-out = jcs:invoke($ping-rpc);
73
74
if ($ping-out/ping-success) {
75
expr jcs:output("Ping Success!!!");
76
} else {
77
expr jcs:output("Ping Failed!!!");
78
}
79
80
call ping($remote-host, $cur-size = $cur-size + $step, $max-size,
81
$step);
82
}
83
}
XML Script Contents
03 |
< title >op-pingsweep.slax</ title > |
04 |
< author >rsankar</ author > |
06 |
Send a series of ping to remote-host, useful for troubleshooting MTU/MSS issues |
12 |
This script performs pings to remote-host, which may be useful for troubleshooting MTU/MSS issues. |
13 |
Size of the packet starts from $min-size, increases by $step and ends at $max-size. |
18 |
< title >Sample Output</ title > |
19 |
< description >Output of "op pingsweep" command</ description > |
20 |
< output >example-1.output</ output > |
24 |
src = "../../../../../web/leaf.js" |
25 |
type = "text/javascript" /> |