Skip to content

Commit a2f57a2

Browse files
committed
Responder
1 parent d5735b6 commit a2f57a2

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,5 @@ replay_pid*
2525

2626
.idea
2727
target/
28-
cert.crt
29-
cert.csr
30-
cert.key
31-
http3-response.*
3228

3329
dependency-reduced-pom.xml

EchoResponderConfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"localPort": 30041,
3+
"consoleOutput": true
4+
}

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ MultiPing provides several tools:
77
* `DownloadAssignmentList` for downloading a list of known ISD/AS assignment
88
* `EchoAll` for sending a single traceroute to all known ASes along the shortest path (default behaviour)
99
* `EchoRepeat` for repeatedly probing (traceroute) multiple paths to multiple ASes.
10+
* `EchoResponder` for responding to incoming echo requests.
1011

1112
# `DownloadAssignmentList`
1213

@@ -102,6 +103,17 @@ This shows a LOCAL_AS and a NO_PATH event:
102103
71-2:0:4a,,2024-09-13T15:46:16.554705200Z,NO_PATH,0,[]
103104
```
104105

106+
# `EchoResponder`
107+
108+
The `EchoResponder` can be configured with a configuration file `EchoResponderConfig.json`, it has two options:
109+
110+
```json
111+
{
112+
"localPort": 30041,
113+
"consoleOutput": true
114+
}
115+
```
116+
105117
# Troubleshooting
106118

107119
## No DNS search domain found. Please check your /etc/resolv.conf or similar.
@@ -110,5 +122,5 @@ This happens, for example, on Windows when using a VPN. One solution is to execu
110122
the example works only for `ethz.ch`):
111123

112124
```
113-
java -DSCION_DNS_SEARCH_DOMAINS=ethz.ch. -jar target/scion-multiping-0.0.1-ALPHA-SNAPSHOT-shaded.jar
125+
java -Dorg.scion.dnsSearchDomains=ethz.ch. -jar target/scion-multiping-0.0.1-ALPHA-SNAPSHOT-shaded.jar
114126
```

src/main/java/org/scion/multiping/EchoRepeat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public EchoRepeat(int localPort) {
6363
}
6464

6565
public static void main(String[] args) throws IOException {
66-
// System.setProperty(Constants.PROPERTY_DNS_SEARCH_DOMAINS, "ethz.ch.");
66+
// System.setProperty(Constants.PROPERTY_DNS_SEARCH_DOMAINS, "ethz.ch.");
6767

6868
config = Config.read(FILE_CONFIG);
6969
PRINT = config.consoleOutput;

src/main/java/org/scion/multiping/EchoRepeatBlocking.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
*/
4848
public class EchoRepeatBlocking {
4949
private static final String FILE_CONFIG = "EchoRepeatConfig.json";
50-
private static final String FILE_INPUT = "EchoRepeatDestinations-short.csv";
51-
private static final String FILE_OUTPUT = "EchoRepeatOutput.csv";
5250

5351
private final int localPort;
5452

@@ -63,9 +61,10 @@ public class EchoRepeatBlocking {
6361
private int nPathTimeout = 0;
6462

6563
private static Config config;
64+
private static FileWriter fileWriter;
65+
6666
private static final List<Result> results = new ArrayList<>();
6767
private static final List<org.scion.multiping.util.Record> records = new ArrayList<>();
68-
private static FileWriter fileWriter;
6968

7069
private enum Policy {
7170
/** Fastest path using SCMP traceroute */
@@ -86,17 +85,17 @@ public EchoRepeatBlocking(int localPort) {
8685
}
8786

8887
public static void main(String[] args) throws IOException {
89-
PRINT = true;
9088
// System.setProperty(Constants.PROPERTY_DNS_SEARCH_DOMAINS, "ethz.ch.");
9189

9290
config = Config.read(FILE_CONFIG);
91+
PRINT = config.consoleOutput;
92+
9393
// Output: ISD/AS, remote IP, time, hopCount, path, [pings]
94-
fileWriter = new FileWriter(FILE_OUTPUT);
94+
fileWriter = new FileWriter(config.outputFile);
9595

9696
// Local port must be 30041 for networks that expect a dispatcher
97-
EchoRepeatBlocking demo = new EchoRepeatBlocking(30041);
98-
List<ParseAssignments.HostEntry> list = ParseAssignments.getList(FILE_INPUT);
99-
// List<ParseAssignments.HostEntry> list = DownloadAssignments.getList();
97+
EchoRepeatBlocking demo = new EchoRepeatBlocking(config.localPort);
98+
List<ParseAssignments.HostEntry> list = ParseAssignments.getList(config.isdAsFile);
10099
for (int i = 0; i < config.roundRepeatCnt; i++) {
101100
Instant start = Instant.now();
102101
for (ParseAssignments.HostEntry e : list) {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2024 ETH Zurich
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package org.scion.multiping;
16+
17+
import org.scion.jpan.*;
18+
import org.scion.multiping.util.Config;
19+
import org.scion.multiping.util.Util;
20+
21+
import java.io.IOException;
22+
23+
import static org.scion.multiping.util.Util.PRINT;
24+
import static org.scion.multiping.util.Util.println;
25+
26+
/**
27+
* A simple echo responder that responds to SCMP echo requests.
28+
*/
29+
public class EchoResponder {
30+
private static final String FILE_CONFIG = "EchoResponderConfig.json";
31+
32+
public static void main(String[] args) throws IOException {
33+
Config config = Config.read(FILE_CONFIG);
34+
PRINT = config.consoleOutput;
35+
36+
try (ScmpChannel responder = Scmp.createChannel(Constants.SCMP_PORT)) {
37+
responder.setScmpErrorListener(EchoResponder::printError);
38+
responder.setOption(ScionSocketOptions.SCION_API_THROW_PARSER_FAILURE, true);
39+
responder.setScmpEchoListener(EchoResponder::print);
40+
responder.setUpScmpEchoResponder();
41+
}
42+
}
43+
44+
private static boolean print(Scmp.EchoMessage msg) {
45+
Util.print("Received: " + msg.getTypeCode().getText() + " from " + msg.getPath().getRemoteAddress() + "via ");
46+
Util.println(ScionUtil.toStringPath(msg.getPath().getMetadata()));
47+
return true;
48+
}
49+
50+
private static void printError(Scmp.Message msg) {
51+
println("ERROR: " + msg.getTypeCode().getText());
52+
}
53+
}

0 commit comments

Comments
 (0)