Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for devices with ARM processor (Raspberry Pi, Smartphones, IoT,...) #1

Open
hellyberry opened this issue Nov 12, 2017 · 3 comments
Milestone

Comments

@hellyberry
Copy link

hellyberry commented Nov 12, 2017

Thank you for this tool, it is the best open source project of its kind!

What do you think about supporting devices with ARM processor and architecture (Raspberry Pi, Smartphones, IoT,...)?

Tried to get OVTR working on ARM devices (Raspberry Pi 2/3), but the 'install' aborted.
Can this be made to work on these processors and archs, too?

All non-Java libs are available as far as I can tell ...

@hellyberry
Copy link
Author

hellyberry commented Nov 12, 2017

$bash ./ovtr.sh

localuser:root being added to access control list
starting OpenVisualTraceroute...
18:21:54.958 [main] INFO  org.leo.traceroute.Main - Open Visual Traceroute 1.6.5 
18:21:55.075 [main] INFO  org.leo.traceroute.install.Env - Java run-time version: 1.8.0_151
18:21:55.087 [main] INFO  org.leo.traceroute.install.Env - NASA World Wind Java 2.0 2.0.0
18:21:55.090 [main] INFO  org.leo.traceroute.install.Env - /usr/java/packages/lib/arm:/usr/lib/arm-linux-gnueabihf/jni:/lib/arm-linux-gnueabihf:/usr/lib/arm-linux-gnueabihf:/usr/lib/jni:/lib:/usr/lib
18:21:55.094 [main] INFO  org.leo.traceroute.install.Env - OS:Linux / arch:arm
18:21:55.153 [main] ERROR org.leo.traceroute.Main - Error while starting the application
org.leo.traceroute.install.EnvException: Unsupported os/architecture : Linux/arm
	at org.leo.traceroute.install.Env.checkArchAndOs(Env.java:328) ~[org.leo.traceroute.jar:na]
	at org.leo.traceroute.install.Env.initEnv(Env.java:282) ~[org.leo.traceroute.jar:na]
	at org.leo.traceroute.Main.main(Main.java:72) ~[org.leo.traceroute.jar:na]
18:21:55.163 [main] ERROR org.leo.traceroute.Main - Uncaught error
java.lang.NullPointerException: null
	at org.leo.traceroute.resources.Resources.getLabel(Resources.java:95) ~[org.leo.traceroute.jar:na]
	at org.leo.traceroute.resources.Resources.getLabel(Resources.java:164) ~[org.leo.traceroute.jar:na]
	at org.leo.traceroute.Main.main(Main.java:138) ~[org.leo.traceroute.jar:na]
localuser:root being removed from access control list

java -Xmx512m -Djava.awt.headless=false -jar ./org.leo.traceroute.jar --help

I tracked it down to this file:

[~/_TEMP/src-repos/_NET/openvisualtraceroute/org.leo.traceroute]
└──╼ $nano src/org/leo/traceroute/install/Env.java 

 File: src/org/leo/traceroute/install/Env.java   
 
           final Pair<OS, Arch> archOs = checkArchAndOs();
                try {
                        final Field usrPathFiled = ClassLoader.class.getDeclare$
                        usrPathFiled.setAccessible(true);
                        final String[] usrPath = (String[]) usrPathFiled.get(nu$
                        final String[] newUsrPath = new String[usrPath.length +$
                        System.arraycopy(usrPath, 0, newUsrPath, 0, usrPath.len$
                        newUsrPath[usrPath.length] = new File(NATIVE_FOLDER + U$
                        usrPathFiled.set(null, newUsrPath);
                } catch (final Exception e) {
                        throw new EnvException(e);
                }
                _os = archOs.getLeft();
                _arch = archOs.getRight();

       private Pair<OS, Arch> checkArchAndOs() throws EnvException {
                final String osName = System.getProperty("os.name");
                final String archName = System.getProperty("os.arch");
                LOGGER.info("OS:" + osName + " / arch:" + archName);
                OS os = null;
                Arch arch = null;
                if (archName.toLowerCase().contains("86")) {
                        arch = Arch.x86;
                } else if (archName.toLowerCase().contains("64")) {
                        arch = Arch.x64;
                }
                if (osName.toLowerCase().contains("win")) {
                        os = OS.win;
                } else if (osName.toLowerCase().contains("linux")) {
                        os = OS.linux;
                } else if (osName.toLowerCase().contains("mac")) {
                        os = OS.mac;
                }
                if (arch == null || os == null) {
                        throw new EnvException("Unsupported os/architecture : "$
                }
                return Pair.of(os, arch);
        }


in ovtr_run_as_root.sh I added:

  elif [ `uname -m` == "armv7l" ]; then
    echo "It is an ARM-device: Raspberry Pi?"
    LINK="/usr/lib/arm-linux-gnueabihf/libpcap.so.0.8" ## $(ldconfig -p | grep libpcap.so | head -1 | awk {'print $4'}) ## "/usr/lib/arm-linux-gnueabihf/libpcap.so.0.8"

Full script:

#!/bin/sh
SCRIPT=$(readlink -f "$0")
DIR=$(dirname "$SCRIPT")
xhost +SI:localuser:root
LIBPCAP08=`ldconfig -p | grep libpcap.so.0.8`

if [ -e "$LIBPCAP08" ]; then
  LIBPCAP1=`ldconfig -p | grep libpcap.so | head -1 | awk {'print $4'}`
  if [ `uname -m` == "x86_64" ]; then
    LINK="/usr/lib64/libpcap.so.0.8"
   elif [ `uname -m` == "armv7l" ]; then
    echo "It is an ARM-device: Raspberry Pi?"
    LINK="/usr/lib/arm-linux-gnueabihf/libpcap.so.0.8" ## $(ldconfig -p | grep libpcap.so | head -1 | awk {'print $4'}) ## "/usr/lib/arm-linux-gnueabihf/libpcap.so.0.8"
  else 
    LINK="/usr/lib/libpcap.so.0.8"
  fi
  echo "set symbolic link $LINK => $LIBPCAP1"
  ln -s "$LIBPCAP1" "$LINK"
fi
echo "starting OpenVisualTraceroute..."
export PATH="$PATH:/usr/sbin/"; java -Xmx512m -Djava.awt.headless=false -jar $DIR/org.leo.traceroute.jar
xhost -SI:localuser:root

exit 0

Raspberry Pi 3:
uname -a: Linux parrot-armhf 4.9.61-v7+ #1049 SMP Fri Nov 10 15:32:51 GMT 2017 armv7l GNU/Linux
uname -m:
armv7l
name -p:
unknown

Can this be made compatible?
If not directly, maybe via WINE or QEMU with the x86 or x86_64 versions?

@leolewis
Copy link
Owner

Hi there,

Thanks for the feedback. Unfortunately the issue in running ovtr with an ARM arch is not libpcap but the 2 native bridge libraries between libpcap and ovtr, which are jpcap and jnetpcap.
Both libraries don't have an ARM version available out of the box, so additional work would be needed to compile these libraries on an ARM architecture.
Here is a link to jnetpcap source http://jnetpcap.com/download
and jpcap source https://sourceforge.net/projects/jpcap/files/jpcap/v0.01.16/
If you have some time to compile a ARM version of these two libraries, you should be able to just put them under your /usr/share/OpenVisualTraceroute/native/linux/amr/ like it is done here https://github.com/leolewis/openvisualtraceroute/tree/master/org.leo.traceroute/native/linux/x86
and try and start the application.
If you manage to have it running, I would be happy to integrate the two arm.so in the next release and to extend the coverage to this architecture.

Thanks,
Leo

@leolewis leolewis added this to the 2.1.0 milestone Jan 3, 2022
@leolewis
Copy link
Owner

leolewis commented Jan 4, 2022

In case you are still around or for anyone with an ARM chip, can you please try the latest universal package and see if it runs there?
https://sourceforge.net/projects/openvisualtrace/files/2.0.0/OpenVisualTraceRoute2.0.0.zip/download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants