Skip to content

Commit 4c8f5bf

Browse files
tzaeschkeTilmann Zäschke
andauthored
JPAN 0.4.0 (#5)
* JPAN 0.4.0 --------- Co-authored-by: Tilmann Zäschke <[email protected]>
1 parent 718a3f4 commit 4c8f5bf

File tree

7 files changed

+138
-178
lines changed

7 files changed

+138
-178
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
[#3](https://github.com/netsec-ethz/scion-java-multiping/pull/3)
1313
- Regression: fixed pom.xml
1414
[#4](https://github.com/netsec-ethz/scion-java-multiping/pull/4)
15+
- Bumped dependency on JPAN to 0.4.0
16+
[#5](https://github.com/netsec-ethz/scion-java-multiping/pull/5)
1517

1618
## [0.2.0] - 2024-09-30
1719

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ arguments:
7676
"tryICMP": false,
7777
"isdAsInputFile": "ping-repeat-destinations.csv",
7878
"outputFile": "ping-repeat-output.csv",
79-
"localPort": 30041,
79+
"localPort": 30041, // This is only used by the PingResponder
8080
"consoleOutput": true
8181
}
8282
```

ping-repeat-output.csv

Lines changed: 123 additions & 147 deletions
Large diffs are not rendered by default.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<dependency>
8484
<groupId>org.scion</groupId>
8585
<artifactId>jpan</artifactId>
86-
<version>0.3.0</version>
86+
<version>0.4.0</version>
8787
</dependency>
8888

8989
<dependency>

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ public class PingAll {
4949
config.tryICMP = false;
5050
}
5151

52-
private final int localPort;
53-
5452
private int nAsTried = 0;
5553
private int nAsSuccess = 0;
5654
private int nAsError = 0;
@@ -79,16 +77,11 @@ private enum Policy {
7977
private static final Policy POLICY = Policy.SHORTEST_TR;
8078
private static final boolean SHOW_PATH = true;
8179

82-
public PingAll(int localPort) {
83-
this.localPort = localPort;
84-
}
85-
8680
public static void main(String[] args) throws IOException {
8781
PRINT = true;
8882
// System.setProperty(Constants.PROPERTY_DNS_SEARCH_DOMAINS, "ethz.ch.");
8983

90-
// Local port must be 30041 for networks that expect a dispatcher
91-
PingAll demo = new PingAll(30041);
84+
PingAll demo = new PingAll();
9285
List<ParseAssignments.HostEntry> list = DownloadAssignmentsFromWeb.getList();
9386
for (ParseAssignments.HostEntry e : list) {
9487
print(ScionUtil.toStringIA(e.getIsdAs()) + " \"" + e.getName() + "\" ");
@@ -206,7 +199,7 @@ private Scmp.EchoMessage findShortestEcho(List<Path> paths, Ref<Path> refBest) {
206199
Path path = PathPolicy.MIN_HOPS.filter(paths);
207200
refBest.set(path);
208201
ByteBuffer bb = ByteBuffer.allocate(0);
209-
try (ScmpSender sender = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
202+
try (ScmpSender sender = Scmp.newSenderBuilder().build()) {
210203
nPathTried++;
211204
Scmp.EchoMessage msg = sender.sendEchoRequest(path, bb);
212205
if (msg == null) {
@@ -233,7 +226,7 @@ private Scmp.EchoMessage findShortestEcho(List<Path> paths, Ref<Path> refBest) {
233226
private Scmp.TracerouteMessage findShortestTR(List<Path> paths, Ref<Path> refBest) {
234227
Path path = PathPolicy.MIN_HOPS.filter(paths);
235228
refBest.set(path);
236-
try (ScmpSender sender = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
229+
try (ScmpSender sender = Scmp.newSenderBuilder().build()) {
237230
nPathTried++;
238231
List<Scmp.TracerouteMessage> messages = sender.sendTracerouteRequest(path);
239232
if (messages.isEmpty()) {
@@ -264,7 +257,7 @@ private Scmp.TracerouteMessage findShortestTR(List<Path> paths, Ref<Path> refBes
264257

265258
private Scmp.TracerouteMessage findFastestTR(List<Path> paths, Ref<Path> refBest) {
266259
Scmp.TracerouteMessage best = null;
267-
try (ScmpSender sender = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
260+
try (ScmpSender sender = Scmp.newSenderBuilder().build()) {
268261
for (Path path : paths) {
269262
nPathTried++;
270263
List<Scmp.TracerouteMessage> messages = sender.sendTracerouteRequest(path);

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public class PingRepeat {
4949
private static final String FILE_CONFIG = "ping-repeat-config.json";
5050

5151
private final InetSocketAddress dummyIP;
52-
private final int localPort;
5352

5453
private int nPingTried = 0;
5554
private int nPingSuccess = 0;
@@ -61,8 +60,7 @@ public class PingRepeat {
6160

6261
private static final boolean SHOW_PATH = true;
6362

64-
public PingRepeat(int localPort) throws UnknownHostException {
65-
this.localPort = localPort;
63+
public PingRepeat() throws UnknownHostException {
6664
this.dummyIP = new InetSocketAddress(InetAddress.getByAddress(new byte[] {1, 2, 3, 4}), 12345);
6765
}
6866

@@ -75,8 +73,7 @@ public static void main(String[] args) throws IOException {
7573
// Output: ISD/AS, remote IP, time, hopCount, path, [pings]
7674
fileWriter = new FileWriter(config.outputFile);
7775

78-
// Local port must be 30041 for networks that expect a dispatcher
79-
PingRepeat demo = new PingRepeat(config.localPort);
76+
PingRepeat demo = new PingRepeat();
8077
List<ParseAssignments.HostEntry> list = ParseAssignments.getList(config.isdAsInputFile);
8178
for (int i = 0; i < config.roundRepeatCnt; i++) {
8279
Instant start = Instant.now();
@@ -164,8 +161,7 @@ private Record measureLatency(List<Path> paths, Ref<Record.Attempt> refBest) {
164161
Record best = null;
165162
double currentBestMs = Double.MAX_VALUE;
166163
ResponseHandler handler = new ResponseHandler();
167-
try (ScmpSenderAsync sender =
168-
Scmp.newSenderAsyncBuilder(handler).setLocalPort(localPort).build()) {
164+
try (ScmpSenderAsync sender = Scmp.newSenderAsyncBuilder(handler).build()) {
169165
for (int attemptCount = 0; attemptCount < config.attemptRepeatCnt; attemptCount++) {
170166
Instant start = Instant.now();
171167
Map<Integer, Record> seqToPathMap = new HashMap<>();

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
public class PingRepeatBlocking {
5050
private static final String FILE_CONFIG = "ping-repeat-config.json";
5151

52-
private final int localPort;
53-
5452
private int nAsTried = 0;
5553
private int nAsSuccess = 0;
5654
private int nAsError = 0;
@@ -80,10 +78,6 @@ private enum Policy {
8078
private static final Policy POLICY = Policy.FASTEST_TR;
8179
private static final boolean SHOW_PATH = true;
8280

83-
public PingRepeatBlocking(int localPort) {
84-
this.localPort = localPort;
85-
}
86-
8781
public static void main(String[] args) throws IOException {
8882
// System.setProperty(Constants.PROPERTY_DNS_SEARCH_DOMAINS, "ethz.ch.");
8983

@@ -93,8 +87,7 @@ public static void main(String[] args) throws IOException {
9387
// Output: ISD/AS, remote IP, time, hopCount, path, [pings]
9488
fileWriter = new FileWriter(config.outputFile);
9589

96-
// Local port must be 30041 for networks that expect a dispatcher
97-
PingRepeatBlocking demo = new PingRepeatBlocking(config.localPort);
90+
PingRepeatBlocking demo = new PingRepeatBlocking();
9891
List<ParseAssignments.HostEntry> list = ParseAssignments.getList(config.isdAsInputFile);
9992
for (int i = 0; i < config.roundRepeatCnt; i++) {
10093
Instant start = Instant.now();
@@ -210,7 +203,7 @@ private Scmp.EchoMessage findShortestEcho(List<Path> paths, Ref<Path> refBest) {
210203
Path path = PathPolicy.MIN_HOPS.filter(paths);
211204
refBest.set(path);
212205
ByteBuffer bb = ByteBuffer.allocate(0);
213-
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
206+
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().build()) {
214207
nPathTried++;
215208
Scmp.EchoMessage msg = scmpChannel.sendEchoRequest(path, bb);
216209
if (msg == null) {
@@ -237,7 +230,7 @@ private Scmp.EchoMessage findShortestEcho(List<Path> paths, Ref<Path> refBest) {
237230
private Scmp.TracerouteMessage findShortestTR(List<Path> paths, Ref<Path> refBest) {
238231
Path path = PathPolicy.MIN_HOPS.filter(paths);
239232
refBest.set(path);
240-
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
233+
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().build()) {
241234
nPathTried++;
242235
List<Scmp.TracerouteMessage> messages = scmpChannel.sendTracerouteRequest(path);
243236
if (messages.isEmpty()) {
@@ -264,7 +257,7 @@ private Scmp.TracerouteMessage findShortestTR(List<Path> paths, Ref<Path> refBes
264257

265258
private Scmp.TracerouteMessage findFastestTR(List<Path> paths, Ref<Path> refBest) {
266259
Scmp.TracerouteMessage best = null;
267-
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().setLocalPort(localPort).build()) {
260+
try (ScmpSender scmpChannel = Scmp.newSenderBuilder().build()) {
268261
for (int i = 0; i < paths.size() && i < config.maxPathsPerDestination; i++) {
269262
Path path = paths.get(i);
270263
nPathTried++;

0 commit comments

Comments
 (0)