Skip to content
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ TODO
- Why two arguments for bestMessage and bestPath for Result? The path should be in the message.
- Create Result inside async traceroute, not outside.

### Changed

- Bump jnb-ping to 3.0.0 and JPAN to 0.6.2-SNAPSHOT
[#20](https://github.com/netsec-ethz/scion-java-multiping/pull/20)


### Fixed

- Fixed mangled output with mode SHOW_SCMP_ONLY
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,14 @@ the example works only for `ethz.ch`):
```
java -Dorg.scion.dnsSearchDomains=ethz.ch. -jar scion-multiping-0.6.1-executable.jar
```

## ICMP requires port access

```
# show group names
$ id -nG
# get a group id
$ getent group <some-group-name>
# enable port
$ sudo sysctl net.ipv4.ping_group_range='<id> <id>'
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>jnb-ping</artifactId>
<version>1.3.2</version>
<version>3.0.0</version>
</dependency>

<dependency>
Expand Down
62 changes: 62 additions & 0 deletions src/main/java/org/scion/multiping/PingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2025 ETH Zurich
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.scion.multiping;

import com.zaxxer.ping.FailureReason;
import com.zaxxer.ping.IcmpPinger;
import com.zaxxer.ping.PingResponseHandler;
import com.zaxxer.ping.PingTarget;
import org.jetbrains.annotations.NotNull;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;

import static org.scion.multiping.util.Util.*;

public class PingTest {
public static void main(String[] args) throws UnknownHostException {
PingResponseHandler handler =
new PingResponseHandler() {
@Override
public void onFailure(
@NotNull PingTarget pingTarget, @NotNull FailureReason failureReason) {
System.out.println("ICMP failed: " + failureReason);
}

@Override
public void onResponse(@NotNull PingTarget pingTarget, double v, int i, int i1) {
System.out.println("ICMP success: " + v + " " + i + " " + i1);
}
};

//InetAddress address1 = Inet4Address.getByAddress(new byte[]{1, 1, 1, 1});
//InetAddress address = Inet4Address.getByAddress(new byte[]{130, 59, 44, 218});
InetAddress address = Inet4Address.getByName("130.59.44.218");
IcmpPinger pinger = new IcmpPinger(handler);
PingTarget target = new PingTarget(address);
Thread t = new Thread(pinger::runSelector);
t.start();
// sleep(50);

pinger.ping(target);
while (pinger.isPendingWork()) {
sleep(100);
}
pinger.stopSelector();


}
}
17 changes: 11 additions & 6 deletions src/main/java/org/scion/multiping/util/ICMP.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

package org.scion.multiping.util;

import static org.scion.multiping.util.Util.round;
import static org.scion.multiping.util.Util.sleep;
import static org.scion.multiping.util.Util.*;

import com.google.common.util.concurrent.AtomicDouble;
import com.zaxxer.ping.FailureReason;
import com.zaxxer.ping.IcmpPinger;
import com.zaxxer.ping.PingResponseHandler;
import com.zaxxer.ping.PingTarget;
Expand Down Expand Up @@ -60,20 +60,25 @@ public static String pingICMP(InetAddress address, Config config) {
PingResponseHandler handler =
new PingResponseHandler() {
@Override
public void onResponse(@NotNull PingTarget pingTarget, double v, int i, int i1) {
seconds.set(v);
public void onFailure(
@NotNull PingTarget pingTarget, @NotNull FailureReason failureReason) {
if (!FailureReason.TimedOut.equals(failureReason)) {
println("ICMP failed: " + failureReason);
}
seconds.set(-1);
}

@Override
public void onTimeout(@NotNull PingTarget pingTarget) {
seconds.set(-1);
public void onResponse(@NotNull PingTarget pingTarget, double v, int i, int i1) {
seconds.set(v);
}
};

IcmpPinger pinger = new IcmpPinger(handler);
PingTarget target = new PingTarget(address);
Thread t = new Thread(pinger::runSelector);
t.start();
sleep(50);
nIcmpTried++;

pinger.ping(target);
Expand Down
Loading