Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ TODO

### Fixed

- Fixed error handling for additional rounds. Cleanup.
[#32](https://github.com/netsec-ethz/scion-java-multiping/pull/32)

### Fixed

- Fixed mangled output with mode SHOW_SCMP_ONLY
[#31](https://github.com/netsec-ethz/scion-java-multiping/pull/31)
- Fixed occurrence of ISD=0 / "AS not listed"
[#32](https://github.com/netsec-ethz/scion-java-multiping/pull/32)
- Fixed error handling for additional rounds. Cleanup.
[#33](https://github.com/netsec-ethz/scion-java-multiping/pull/33)

### Changed

- Refactored for JPAN 1.6.2 and Use new endhost API.
[#34](https://github.com/netsec-ethz/scion-java-multiping/pull/34)


## [0.6.1] - 2025-12-12

Expand Down
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<scion.slf4j.version>2.0.17</scion.slf4j.version>
<scion.fmt-maven.version>2.23</scion.fmt-maven.version>
<scion.maven-enforcer-plugin.version>3.5.0</scion.maven-enforcer-plugin.version>
<scion.fmt-maven.version>2.29</scion.fmt-maven.version>
<scion.maven-enforcer-plugin.version>3.6.2</scion.maven-enforcer-plugin.version>
</properties>

<name>SCION Java API Examples</name>
Expand Down Expand Up @@ -70,20 +70,20 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.14.1</version>
<version>5.14.4</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.googlejavaformat</groupId>
<artifactId>google-java-format</artifactId>
<version>1.33.0</version>
<version>1.35.0</version>
</dependency>

<dependency>
<groupId>org.scion</groupId>
<artifactId>jpan</artifactId>
<version>0.6.1</version>
<version>0.7.0</version>
</dependency>

<dependency>
Expand All @@ -95,21 +95,21 @@
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.21.2</version>
<version>1.22.2</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.13.2</version>
<version>2.14.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<version>3.15.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down Expand Up @@ -141,12 +141,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
<version>3.5.5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<version>0.8.14</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand Down Expand Up @@ -273,7 +273,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<version>3.6.2</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
24 changes: 10 additions & 14 deletions src/main/java/org/scion/multiping/PingAll.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import org.scion.jpan.*;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.Shim;
import org.scion.jpan.internal.header.PathRawParser;
import org.scion.multiping.util.*;

/**
Expand Down Expand Up @@ -96,7 +96,8 @@ public static void main(String[] argsArray) throws IOException {
localPort = config.getLocalPortOr30041();
Policy policy = parseArgs(argsArray);

System.setProperty(Constants.PROPERTY_SHIM, startShim ? "true" : "false"); // disable SHIM
System.setProperty(Constants.PROPERTY_BOOTSTRAP_PATH_SERVICE, "192.168.53.19:48080");
System.setProperty(Constants.PROPERTY_SHIM, Boolean.toString(startShim)); // disable SHIM

println("Settings:");
println(" Path policy = " + policy);
Expand Down Expand Up @@ -212,18 +213,13 @@ private void runAS(ParseAssignments.HostEntry remote) throws IOException {
if (msgs[0] != null && bestPath.get() != null && REPEAT > 1) {
try (ScionProvider.Sync sender = service.getSync()) {
for (int i = 1; i < msgs.length; i++) {
try {
List<Scmp.TracerouteMessage> messages = sender.sendTracerouteRequest(bestPath.get());
msgs[i] = messages.get(messages.size() - 1);
} catch (IOException e) {
msgs[i] = Scmp.TracerouteMessage.createEmpty(bestPath.get());
msgs[i].setTimedOut(1_000_000_000);
}
List<Scmp.TracerouteMessage> messages = sender.sendTracerouteRequest(bestPath.get());
msgs[i] = messages.get(messages.size() - 1);
}
}
}
} catch (ScionRuntimeException e) {
println("ERROR: " + e.getMessage());
printlnERROR(e.getMessage());
summary.incAsError(remote.getIsdAs());
summary.add(new Result(remote, Result.State.ERROR));
return;
Expand Down Expand Up @@ -315,7 +311,7 @@ private Scmp.EchoMessage findShortestEcho(List<Path> paths, Ref<Path> refBest, l
summary.incPathSuccess();
return msg;
} catch (IOException e) {
println("ERROR: " + e.getMessage());
printlnERROR(e.getMessage());
summary.incAsError(isdAs);
return null;
}
Expand All @@ -341,7 +337,7 @@ private Scmp.TracerouteMessage findShortestTR(List<Path> paths, Ref<Path> refBes
summary.incPathSuccess();
return msg;
} catch (IOException e) {
println("ERROR: " + e.getMessage());
printlnERROR(e.getMessage());
summary.incAsError(isdAs);
return null;
}
Expand Down Expand Up @@ -373,7 +369,7 @@ private Scmp.TracerouteMessage findFastestTR(List<Path> paths, Ref<Path> refBest
}
return best;
} catch (IOException e) {
println("ERROR: " + e.getMessage());
printlnERROR(e.getMessage());
summary.incAsError(isdAs);
return null;
}
Expand All @@ -393,7 +389,7 @@ private Scmp.TracerouteMessage findFastestTraceAsync(
// Wait for all messages to be received, BEFORE closing the "sender".
handler.await();
} catch (IOException e) {
println("ERROR: " + e.getMessage());
printlnERROR(e.getMessage());
summary.incAsError(isdAs);
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/scion/multiping/PingRepeat.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.scion.jpan.*;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.Shim;
import org.scion.jpan.internal.header.PathRawParser;
import org.scion.multiping.util.*;
import org.scion.multiping.util.Record;

Expand Down Expand Up @@ -121,7 +121,7 @@ private void runRepeat(ParseAssignments.HostEntry remote) {
try {
List<Path> paths = service.getPaths(remote.getIsdAs(), dstIP);
if (paths.isEmpty()) {
String src = ScionUtil.toStringIA(service.getLocalIsdAs());
String src = ScionUtil.toStringIA(service.getLocalIsdAses().iterator().next());
String dst = ScionUtil.toStringIA(remote.getIsdAs());
println("WARNING: No path found from " + src + " to " + dst);
Record.createNoPathRecord(remote.getIsdAs(), fileWriter);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/scion/multiping/PingRepeatBlocking.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.Comparator;
import java.util.List;
import org.scion.jpan.*;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.header.PathRawParser;
import org.scion.multiping.util.*;
import org.scion.multiping.util.Record;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/scion/multiping/util/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.scion.jpan.Path;
import org.scion.jpan.ScionUtil;
import org.scion.jpan.Scmp;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.header.PathRawParser;

public class Record {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/scion/multiping/util/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.scion.jpan.Path;
import org.scion.jpan.ScionUtil;
import org.scion.jpan.Scmp;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.header.PathRawParser;

public class Result {
public enum State {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/scion/multiping/util/ResultSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.stream.Collectors;
import org.scion.jpan.ScionUtil;
import org.scion.jpan.Scmp;
import org.scion.jpan.internal.PathRawParser;
import org.scion.jpan.internal.header.PathRawParser;

public class ResultSummary {

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/scion/multiping/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class Util {
public static boolean DELAYED_PRINT = false; // print only at newlines
private static final StringBuilder sb = new StringBuilder();

private Util() {}

public static void sleep(long millis) {
try {
Thread.sleep(millis);
Expand All @@ -44,6 +46,10 @@ public static void println(String msg) {
println();
}

public static void printlnERROR(String msg) {
println("ERROR: " + msg);
}

public static void println() {
if (PRINT) {
if (DELAYED_PRINT) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/scion/jpan/PathHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

package org.scion.jpan;

import com.google.protobuf.ByteString;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import org.scion.jpan.proto.daemon.Daemon;

public class PathHelper {

Expand All @@ -28,11 +26,13 @@ private PathHelper() {}
public static List<Path> createPaths(int n) {
List<Path> paths = new ArrayList<>();
for (int i = 0; i < n; i++) {
Daemon.Path.Builder builder = Daemon.Path.newBuilder();
builder.setRaw(ByteString.copyFrom(new byte[] {}));
PathMetadata.Builder builder = PathMetadata.newBuilder();
builder.setRaw(new byte[] {});
builder.setSrcIsdAs(1000);
builder.setDstIsdAs(n + 1);
try {
InetAddress dst = InetAddress.getByAddress(new byte[] {123, 123, 123, 123});
paths.add(RequestPath.create(builder.build(), n + 1, dst, 12345));
paths.add(RequestPath.create(builder.build(), dst, 12345));
} catch (UnknownHostException e) {
throw new ScionRuntimeException("Unable to create test path", e);
}
Expand Down
15 changes: 8 additions & 7 deletions src/test/java/org/scion/multiping/PingAllTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ static class MySync implements ScionProvider.Sync {

@Override
public Scmp.EchoMessage sendEchoRequest(Path path, ByteBuffer bb) throws IOException {
Scmp.EchoMessage msg = Scmp.EchoMessage.createEmpty(path);
msg.setMessageArgs(Scmp.TypeCode.TYPE_129, seqId++, seqId);
Scmp.EchoMessage msg = Scmp.EchoMessage.create(Scmp.TypeCode.TYPE_129, seqId++, seqId, path);
msg.assignRequest(msg, 1_000_000); // Hack: assign to itself
return msg;
}
Expand All @@ -98,7 +97,9 @@ public List<Scmp.TracerouteMessage> sendTracerouteRequest(Path path) throws IOEx
}

@Override
public void close() {}
public void close() {
/* Nothing to do */
}
}

@Test
Expand All @@ -110,9 +111,9 @@ class MyWithHandler extends WithHandler {
handler,
hdl -> {
for (int i = 0; i < 3; i++) {
Scmp.TimedMessage req = Scmp.TracerouteMessage.createRequest(i, paths.get(i));
Scmp.TimedMessage msg = Scmp.TracerouteMessage.createEmpty(paths.get(i));
msg.setMessageArgs(Scmp.TypeCode.TYPE_131, i, i);
Scmp.TracerouteMessage req = Scmp.TracerouteMessage.createRequest(i, paths.get(i));
Scmp.TracerouteMessage msg =
Scmp.TracerouteMessage.create(Scmp.TypeCode.TYPE_131, i, i, paths.get(i));
msg.assignRequest(req, 1_000_000); // Hack: assign to itself
msg.setTimedOut(1000 * 1000 * 1000);
hdl.onTimeout(msg);
Expand Down Expand Up @@ -144,7 +145,7 @@ class MyWithHandler extends WithHandler {
hdl -> {
for (int i = 0; i < 3; i++) {
Scmp.ErrorMessage msg =
Scmp.ErrorMessage.createEmpty(Scmp.TypeCode.TYPE_5, paths.get(i));
Scmp.ErrorMessage.create(Scmp.TypeCode.TYPE_5, paths.get(i));
hdl.onError(msg);
}
});
Expand Down
Loading