22
22
public class Main {
23
23
24
24
public static void main (String [] args ) throws IOException {
25
- if (args .length != 1 ) {
26
- printUsage ();
27
- System .exit (1 );
28
- }
25
+ checkArgs (args , 1 , Integer .MAX_VALUE );
29
26
String mode = args [0 ].toLowerCase (Locale .ROOT );
30
27
String [] newArgs = Arrays .copyOfRange (args , 1 , args .length );
31
28
switch (mode ) {
32
29
case "download-assignments" :
33
30
{
31
+ checkArgs (args , 1 , 1 );
34
32
DownloadAssignments .main (newArgs );
35
33
return ;
36
34
}
35
+ case "help" :
36
+ {
37
+ printHelp (args .length == 1 ? "" : args [1 ]);
38
+ return ;
39
+ }
37
40
case "ping-all" :
38
41
{
39
42
PingAll .main (newArgs );
40
43
return ;
41
44
}
42
45
case "ping-repeat" :
43
46
{
47
+ checkArgs (args , 1 , 1 );
44
48
PingRepeat .main (newArgs );
45
49
return ;
46
50
}
47
51
case "ping-responder" :
48
52
{
53
+ checkArgs (args , 1 , 1 );
49
54
PingResponder .main (newArgs );
50
55
return ;
51
56
}
@@ -55,6 +60,33 @@ public static void main(String[] args) throws IOException {
55
60
}
56
61
}
57
62
63
+ private static void checkArgs (String [] args , int minArgs , int maxArgs ) {
64
+ if (args .length < minArgs || args .length > maxArgs ) {
65
+ Util .println ("Invalid number of arguments." );
66
+ printUsage ();
67
+ System .exit (1 );
68
+ }
69
+ }
70
+
71
+ private static void printHelp (String mode ) {
72
+ switch (mode ) {
73
+ case "download-assignments" :
74
+ printUsageDownloadAssignments ();
75
+ return ;
76
+ case "ping-all" :
77
+ printUsagePingAll ();
78
+ return ;
79
+ case "ping-repeat" :
80
+ printUsagePingRepeat ();
81
+ return ;
82
+ case "ping-responder" :
83
+ printUsagePingResponder ();
84
+ return ;
85
+ default :
86
+ printUsage ();
87
+ }
88
+ }
89
+
58
90
private static void printUsage () {
59
91
Util .println ("Usage: scion-multiping [MODE]" );
60
92
Util .println ("where MODE is one of: " );
@@ -65,6 +97,53 @@ private static void printUsage() {
65
97
" - `ping-repeat` for repeatedly probing (traceroute) multiple paths to multiple ASes." );
66
98
Util .println (
67
99
" - `ping-responder` for starting a server that responds to incoming echo requests." );
100
+ Util .println (" - `help [MODE]` for getting more help for a given mode." );
101
+ Util .println ("" );
102
+ }
103
+
104
+ private static void printUsageDownloadAssignments () {
105
+ Util .println ("Usage: scion-multiping download-assignments" );
106
+ Util .println ();
107
+ Util .println (
108
+ " This tool downloads a list of known ISD/AS assignments and saves it to a file." );
109
+ Util .println (" The output file is called `isd-as-assignments.csv`." );
110
+ Util .println ("" );
111
+ }
112
+
113
+ static void printUsagePingAll () {
114
+ Util .println (
115
+ "Usage: ping-all [--help] [--fastest|--shortest|--shortest_echo|--fastest_sync] [--port <port>] [--shim]" );
116
+ Util .println (" --help Show this help message." );
117
+ Util .println (" --fastest Use fastest path with SCMP traceroute (default)." );
118
+ Util .println (
119
+ " The fastest path is determined by running a single traceroute on all path." );
120
+ // Util.println(" --fastest_sync Use fastest path with SCMP traceroute (synchronous)");
121
+ Util .println (" --shortest Use shortest path (fewest hops) with SCMP traceroute." );
122
+ // Util.println(" --shortest_echo Use shortest path with SCMP echo");
123
+ Util .println (
124
+ " --port <port> Use specified local port (default " + PingAll .localPort + ")." );
125
+ Util .println (" --shim Start with SHIM enabled (default disabled)." );
126
+ Util .println ("" );
127
+ }
128
+
129
+ private static void printUsagePingRepeat () {
130
+ Util .println ("Usage: scion-multiping ping-repeat" );
131
+ Util .println ();
132
+ Util .println (
133
+ " This tool is used for repeatedly probing (traceroute) multiple paths to multiple ASes." );
134
+ Util .println (" The destination ASes are read from a file `isd-as-assignments.csv`." );
135
+ Util .println (" Other configuration options can be defined in `ping-repeat-config.json`." );
136
+ Util .println (" Results are written to a CSV file `ping-results.csv`." );
137
+ Util .println (" See README.md for more information." );
138
+ Util .println ("" );
139
+ }
140
+
141
+ private static void printUsagePingResponder () {
142
+ Util .println ("Usage: scion-multiping ping-responder" );
143
+ Util .println ();
144
+ Util .println (" This command starts a server that responds to incoming echo requests." );
145
+ Util .println (" It takes a configuration file `ping-responder-config.json` as input." );
146
+ Util .println (" See README.md for more information." );
68
147
Util .println ("" );
69
148
}
70
149
}
0 commit comments