Skip to content

Commit

Permalink
squash-24
Browse files Browse the repository at this point in the history
  • Loading branch information
Tilmann Zäschke committed Aug 12, 2024
1 parent 0908252 commit f43400e
Show file tree
Hide file tree
Showing 16 changed files with 769 additions and 407 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]

### TODO for 0.3.0
- BUG: System.setProperty(Constants.PROPERTY_DAEMON, "127.0.0.1");
leads to exception about missing TRC (instead of complaining about missing ":30255")
-> DOes this work with an IPv6 address (separaeting the port?)
-> Think about making the port optional, it is standardized to 30255 anyway
-> Move port to separate environment variable????
- Make ResponsePath/RequestPath classes private. Make at least create() private...
- Demo that connects to Francois' website
- Fix @Disabled tests
- Support topofile port range
- `ResponsePath` is now package private (not public anymore)
- remove ScionAddress?
Expand All @@ -28,6 +35,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Support for bootstrapper TRC metadata. [#110](https://github.com/scionproto-contrib/jpan/pull/110)
- Added `copy(...)` method for paths. [#111](https://github.com/scionproto-contrib/jpan/pull/111)
- Added Scenario builder for unit tests. [#112](https://github.com/scionproto-contrib/jpan/pull/112)
- Support shortcut and on-path detection during path construction. Also:
- New option `SCION_RESOLVER_MINIMIZE_REQUESTS`
- Fixed MTU calculations for link level MTU
- Path lists are ordered by hop count
- Path lists contain no duplicates
[#104](https://github.com/scionproto-contrib/jpan/pull/104)

### Changed
- Clean up TODO and deprecation info. [#100](https://github.com/scionproto-contrib/jpan/pull/100)
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,18 @@ is configurable, see next section.

### Other Options

| Option | Java property | Environment variable | Default value |
|----------------------------------------------------------------------------------------------------------------------|-------------------------|----------------------|--------------------|
| Path expiry margin. Before sending a packet a new path is requested if the path is about to expire within X seconds. | `org.scion.pathExpiryMargin` | `SCION_PATH_EXPIRY_MARGIN` | 10 |
| Location of `hosts` file. Multiple location can be specified separated by `;`. | `org.scion.hostsFiles` | `SCION_HOSTS_FILES` | `/etc/scion/hosts` |
| Option | Java property | Environment variable | Default value |
|----------------------------------------------------------------------------------------------------------------------|---------------------------------------|--------------------------------------|--------------------|
| Path expiry margin. Before sending a packet a new path is requested if the path is about to expire within X seconds. | `org.scion.pathExpiryMargin` | `SCION_PATH_EXPIRY_MARGIN` | 10 |
| Location of `hosts` file. Multiple location can be specified separated by `;`. | `org.scion.hostsFiles` | `SCION_HOSTS_FILES` | `/etc/scion/hosts` |
| Minimize segment requests to local AS at the cost of reduced range of path available. | `org.scion.resolver.minimizeRequests` | `SCION_RESOLVER_MINIMIZE_REQUESTS` | `false` |

`SCION_RESOLVER_MINIMIZE_REQUESTS` is a non-standard option that request CORE segments only of other
path can be constructed. This may reduce response time when requesting new paths. It is very likely,
but not guaranteed, that the shortest path (fewest hops) will be available.
If this property is not set (= default), CORE segments are always requested, resulting in additional
path options. While these additional path options almost always result in longer paths, they may have
other advantages.

## FAQ / Troubleshooting

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/scion/jpan/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public final class Constants {
public static final int SCMP_PORT = 30041;

/**
* @deprecated Dispatcher support will be removed soon.
*/
Expand Down Expand Up @@ -64,6 +65,15 @@ public final class Constants {
/** Time (in seconds) before expiration at which a paths is automatically renewed. */
public static final int DEFAULT_PATH_EXPIRY_MARGIN = 10;

/** Enable minimization of segment requests during path construction. */
public static final String PROPERTY_RESOLVER_MINIMIZE_REQUESTS =
"SCION_RESOLVER_MINIMIZE_REQUESTS";

/** Enable minimization of segment requests during path construction. */
public static final String ENV_RESOLVER_MINIMIZE_REQUESTS = "org.scion.resolver.minimizeRequests";

public static final boolean DEFAULT_RESOLVER_MINIMIZE_REQUESTS = false;

/**
* Disable usage of OS search domains for DNS lookup, e.g. from /etc/resolv.conf. This needs to be
* disabled for JUnit testing.
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/org/scion/jpan/ScionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class ScionService {
private final DaemonServiceGrpc.DaemonServiceBlockingStub daemonStub;
private final SegmentLookupServiceGrpc.SegmentLookupServiceBlockingStub segmentStub;

private final boolean minimizeRequests;
private final ManagedChannel channel;
private static final long ISD_AS_NOT_SET = -1;
private final AtomicLong localIsdAs = new AtomicLong(ISD_AS_NOT_SET);
Expand All @@ -89,6 +90,11 @@ protected enum Mode {
}

protected ScionService(String addressOrHost, Mode mode) {
minimizeRequests =
ScionUtil.getPropertyOrEnv(
Constants.PROPERTY_RESOLVER_MINIMIZE_REQUESTS,
Constants.ENV_RESOLVER_MINIMIZE_REQUESTS,
Constants.DEFAULT_RESOLVER_MINIMIZE_REQUESTS);
if (mode == Mode.DAEMON) {
LOG.info("Bootstrapping with daemon: target={}", addressOrHost);
channel = Grpc.newChannelBuilder(addressOrHost, InsecureChannelCredentials.create()).build();
Expand Down Expand Up @@ -596,7 +602,16 @@ private Long parseTxtRecordToIA(String txtEntry) {

// Do not expose protobuf types on API!
List<Daemon.Path> getPathListCS(long srcIsdAs, long dstIsdAs) {
return Segments.getPaths(segmentStub, bootstrapper, srcIsdAs, dstIsdAs);
List<Daemon.Path> list =
Segments.getPaths(segmentStub, bootstrapper, srcIsdAs, dstIsdAs, minimizeRequests);
if (LOG.isInfoEnabled()) {
LOG.info(

Check warning on line 608 in src/main/java/org/scion/jpan/ScionService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/scion/jpan/ScionService.java#L608

Added line #L608 was not covered by tests
"Path found between {} and {}: {}",
ScionUtil.toStringIA(srcIsdAs),
ScionUtil.toStringIA(dstIsdAs),
list.size());

Check warning on line 612 in src/main/java/org/scion/jpan/ScionService.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/scion/jpan/ScionService.java#L610-L612

Added lines #L610 - L612 were not covered by tests
}
return list;
}

/**
Expand Down
Loading

0 comments on commit f43400e

Please sign in to comment.