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

Port to Android #19

Open
McCITS opened this issue Mar 20, 2017 · 34 comments
Open

Port to Android #19

McCITS opened this issue Mar 20, 2017 · 34 comments

Comments

@McCITS
Copy link

McCITS commented Mar 20, 2017

Hay ;)

I really like your cnping on PC,

Would it be possible to port it to Android?
It would be really handy to have it mobile for wireless testing.
Unfortunately i do not have the skills to figure it out on my own,

thanks in advance for your help
McC

@dreua
Copy link
Member

dreua commented Mar 20, 2017

I think it would be like writing a new Andrid app with the same functinality as cnping. There would be little to no reusable code from cnping. (Except for the idea and maybe the calculation of "Avg"/"Std"/"Loss".)

Additionaly one had to check if pinging that fast (i.e. without waiting for the previous ping to return or timeout) is possible on Android. Same goes for the "extra size" function if that should be implemented as well. (It is possible to ping like the standard ping tools as there are already Apps for that.)

@cnlohr: If someone wrote an Android app, would you approve of a name like cnping-android or should it have its own name without relation to cnping?

@cnlohr
Copy link
Member

cnlohr commented Mar 20, 2017

I would absolutely approve the name, even moreso if it used the same convention of white bars on a blue-or-black background that turn red when they breach some timeout with horizontal average and/or standard of deviation bars.

I am just SO SICK of people trying to use command-line ping tools to debug wireless problems. Tools like HR-ping help, but they just don't cut it for real-time updates! Any platform, anywhere. I don't care if it's me, people just need to have cnping-like tools available and need to know they're there to be used.

@dreua
Copy link
Member

dreua commented Mar 20, 2017

I have done a little bit of research and it seems that my Android knowledge was outdated and my first statement may be wrong (sorry):
It may well be possible to reuse quite some C code using Googles Android Native Development Kit (NDK) and one might have to use native code anyway to get the fast pings!

I really like cnping as well as the idea to port it to Android and I am planing to try this: If anyone want's to join me please get in touch!

@cnlohr
Copy link
Member

cnlohr commented Mar 20, 2017

I have literally zero experience with it. I can only support you emotionally :-p. Also, is there any reason not to make it free? And not require permissions to all your contacts and camera and to send/receive text messages and phone calls?

@dreua
Copy link
Member

dreua commented Mar 20, 2017

My Android experience is more than zero, but also very limited so I will just give it a try. Your emotional support is greatly appreciated 😄
A reason not to make it free would be making money but FOSS is just so much cooler, so I'll donate any work and hope for good karma instead.
There won't be any unnecessary permissions, I promise! Let's hope we don't need root to get a fast ping...

@cnlohr
Copy link
Member

cnlohr commented Mar 20, 2017

Not native, but http://stackoverflow.com/questions/3905358/how-to-ping-external-ip-from-java-android

P.S. If you can get RawDraw to work in the Android NDK that would be super cool! Though I do need to update CNPing's RawDraw API. RawDraw has been cookin' along. https://github.com/cnlohr/rawdraw

@hackrid
Copy link
Contributor

hackrid commented Mar 20, 2017

From the Android terminal:

2|FulmicsROM:/ $ ping -i 0.1 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
ping: cannot flood; minimal interval, allowed for user, is 200ms

@cnlohr
Copy link
Member

cnlohr commented Mar 20, 2017

That's only because the "ping" program restricts that.

@dreua
Copy link
Member

dreua commented Mar 21, 2017

@hackrid What phone are you using? On my devices, HTC One S (not rooted) and Fairphone 1 (root by default), there is no limit. ping -i 0 <IP> pings like crazy!

@cnlohr
Copy link
Member

cnlohr commented Mar 21, 2017

I updated to the newest version of rawdraw. You guys can feel to knock yourselves out now :-D

@cnlohr
Copy link
Member

cnlohr commented Mar 21, 2017

P.S. I would be willing to put $25 of my own $ toward someone making a cnping-type tool for android (provided it works well)

@dreua
Copy link
Member

dreua commented Mar 27, 2017

Like on Linux and Windows you need root access to open a socket with SOCK_RAW flag so I'm wondering which way to go:

  1. Require CNPing-Users on Android to root their phone and grant root access to the app. (This would have the best performance and will most likely work best and be closest to cnping.)
  2. Try abusing the system provided ping. (Like using many instances of it. May be unreliable or run into performance issues.)
  3. Ping by TCP (or maybe UDP?) instead of ICMP. This would require cooperation of the destination device, but many devices already have a web server listening on port 80. Edit: This would be quite similar to a SYN flood so maybe not a good idea.
  4. Other ideas?

(Using Java's InetAddress#isReachable()method is most likely not a good idea.)

Which one would you guys prefer?

@hackrid
Copy link
Contributor

hackrid commented May 25, 2017

Hi @dreua,

If I read your last message correctly, there's only one option left how to get a cnping Derivate working on android :)

Or did I miss a point?

@dreua
Copy link
Member

dreua commented May 25, 2017

The problem is, none of the options is perfect. Number one would be best for my own use, but other potential users might not be able or wiling to root their phones. Additionally I'm not sure if running an executable with su will work the same on different devices.

btw: I was able to compile most of the C-Code for Android, run it as root (with su) from an Android App and do the pinging. (Just ping, no graphics, no user-interface.) So I think its doable with root but currently the summer term is taking all my time. I hope to continue development in a few months (around August) when I'm done with my exams.

@hackrid
Copy link
Contributor

hackrid commented May 25, 2017

Great! That's a starting point!
Would you like to share your efforts you made so far with the app?

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

img_1584

@hackrid
Copy link
Contributor

hackrid commented Jun 8, 2017

:D nice

@hackrid
Copy link
Contributor

hackrid commented Jun 8, 2017

Does this mean you ported cnlohrs rawdraw to Android?

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

Not exactly :)
I turned it inside out. Rasterizer (in native code) draws on pixel-buffer from android Bitmap.

@cnlohr
Copy link
Member

cnlohr commented Jun 8, 2017

@Viknet that makes me cringe a little inside :-p. But how can I try this?

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

It's a little unstable and unfinished at so many levels... And needs rooted android.
If you are brave enough, I can create apk in an hour.

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

@cnlohr I have not tried to install it manually (only through adb).
https://github.com/Viknet/cnping-android/releases/tag/0.0.1

@hackrid
Copy link
Contributor

hackrid commented Jun 8, 2017

I get some errors regarding the pie checks in Android
According to https://stackoverflow.com/questions/30498776/position-independent-executables-and-android-lollipop you need to add to lines to your make file
LOCAL_CFLAGS += -fPIE
LOCAL_LDFLAGS += -fPIE -pie

capture _2017-06-08-10-23-31

Edit:
I changed the /system/bin/linker on my phone to ignore the missing pie condition but it still doesn't work. I noticed these log messages:

[ 3176.251686 / 06-08 13:42:45.689] type=1400 audit(1496943765.689:447): avc: denied { connectto } for pid=17076 comm="Binder_4" path="/dev/socket/mpctl" scontext=u:r:zygote:s0 tcontext=u:r:mpdecision:s0 tclass=unix_stream_socket permissive=1
[ 3276.911308 / 06-08 13:44:26.349] type=1400 audit(1496943866.349:451): avc: denied { write } for pid=4914 comm="Binder_1" name="mpctl" dev="tmpfs" ino=25921 scontext=u:r:zygote:s0 tcontext=u:object_r:mpdecision_socket:s0 tclass=sock_file permissive=1

It might be necessary to tweak some permissions for newer Android versions. Until now I could not get it to run on android 6.0

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

Thank you for some bad news :)
It is SELinux and I know nothing about it... but I will try to write policies on emulator.

@hackrid
Copy link
Contributor

hackrid commented Jun 8, 2017

I tried to disable selinux as good as possible. But as far I found out there is not much more than setting it to permissive mode.

Regarding the PIE problem:
This situation changed with the security policyies introduced in and rid 4.1.

What version so you have on your phone?

@Viknet
Copy link
Contributor

Viknet commented Jun 8, 2017

I will create PIE build in an hour. It raises minimal android version to 4.1 (target was 4.0.2).

"su root setenforce 0" in adb shell should be enough for Unix Domain Socket.
Maybe local Inet socket will work without bothering SELinux.

My phone is under 4.4.2 and not have SELinux.

@hackrid
Copy link
Contributor

hackrid commented Jun 8, 2017

I tried to setenforce 0.had no luck

@Viknet
Copy link
Contributor

Viknet commented Jun 9, 2017

@Viknet
Copy link
Contributor

Viknet commented Jun 9, 2017

If device rooted with SuperSU, new build should work around SELinux: https://github.com/Viknet/cnping-android/releases/tag/0.0.1b

@Viknet
Copy link
Contributor

Viknet commented Jun 11, 2017

@cnlohr You can try last build: cnping-android-0.0.2

@cnlohr
Copy link
Member

cnlohr commented Jun 14, 2017

I don't have a rooted phone, tho. I guess it's time.

@cnlohr
Copy link
Member

cnlohr commented Sep 24, 2019

I know it's been forever, but we've since added support for HTTP Pinging. It would be very cool if this was something someone did want to work on.

@dreua
Copy link
Member

dreua commented Sep 24, 2019

Yeah, since Http ping would not require root, that would be the way to go now. Unfortunately I don't have the time to do this...

@ChristianRomberg would you like another Android project? ;)

@cnlohr
Copy link
Member

cnlohr commented May 16, 2020

Now, that I have rawdraw as a first class citizen on Android, and cnping supports httpping, this has become much more tenable. @dreua would you be interested in chatting on Discord? I want to get your feelings on if this should be a paid app with more bells and whistles or just a bare bones dead simple app for free.

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

5 participants