Network Traffic

Post your questions and help other users.

Moderator: Martin

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Network Traffic

Post by digitalstone » 24 Jan 2018 00:03

I found the Init Variables Network Traffic block.
With it i'd like to try and extract data from it.

I only seem to miss (on obvious level, perhaps i'm looking right at it) "wifi_received_bytes" and "wifi_transmitted_bytes"
Am i to make the subtraction formula myself?

Subtraction being:
total_received_bytes - mobile_received_bytes = wifi_received_bytes
AND
total_transmitted_bytes - mobile_transmitted_bytes = wifi_transmitted_bytes
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Network Traffic

Post by Desmanto » 24 Jan 2018 08:30

Yeah, it supposed be correct. Try to send some file via wifi and check the statistic again, see if it is very close.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Network Traffic

Post by digitalstone » 24 Jan 2018 23:20

Hmm no, my idea couldn't be more wrong (must have been really sleepy when i wrote that).
Mobile received bytes does that and only that. And when switching to wifi, these 2 values turn to '0'.

My new approach will be just storing the total transferred/received bytes, and x-amount time later subtract the new value with the stored value.
Then whole of that has to be divided by the amount of seconds of wait-time in between to get the 'per sec' correct.
*fingers crossed*
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Network Traffic

Post by digitalstone » 25 Jan 2018 00:20

Confirmed (for sharing purposes i guess):

The actually important part:

Code: Select all

if (divider == null) {divider = 1000}
if (timeout == null) {timeout = 1}

downSpeed = (totDownBytes-totDownBytes_old)/divider/timeout;
upSpeed = (totUpBytes-totUpBytes_old)/divider/timeout;
var = "Download: {downSpeed} kB/s\nUpload: {upSpeed} kB/s";
setWidgetElementProperty("Network Traffic", "Text_1", "text", var);
Note that the division by timeout part, would be working for whole seconds only.
You would have to create a separate code for that.

Also, the divider is set to 1000 to get the amount of kilobytes.
To get Megabytes, just make that 1000000 and so on.
Attachments
example.xml
(5.51 KiB) Downloaded 839 times
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Network Traffic

Post by Desmanto » 25 Jan 2018 14:52

Oh, your idea is to make a widget to show the connection speed. I actually don't know about it never use the init network traffic before.
It is one of the neat way to get the network speed without installing additional network monitor. (why waste space for something that we can create in Automagic)
I don't have the need, as I have Xposed + GravityBox to show the connection speed already in the status bar. Thus never make effort to make it :D

As usual, I have seen your flow, can't help not to give suggestion. :) I am sorry first because I am going to comment a lot. :|

The initialization of the divider and timeout doesn't need to be protected, you can just init as divider = 1000;

You have 4 elements in the loop. Actually you only need 2.
I almost never use sleep action outside of script anymore, unless the consecutive elements are not one of the script, expression, or Control UI.
You can simply replace the sleep timeout, into a single line script, sleep(timeout*1000), removing the sleep.

Next is you don't need two init element. As you can see, without the script, both init are back to back.. You can just save them to another var temporary. Of course you have to init it first at the script before, by set it to zero.
This way, the first you start the flow, it will show a very huge number. But afterward it will be normal. I don't think it will be annoying, as only the first number affected.

AEP number can be set to a very high number. But I suggest you increase it sparely. You don't know one day you have the run away flow and it drains your battery because the AEP is too high and Automagic doesn't stop it.
There are several startup elements. Then you have 4 elements in loop, with maximum speed 1 loop/second. So total 4x60 = 240 elements execution per minute. You can set the AEP to 250, or 300 for safety.

If you have optimize to only 2 elements per loop, you only need 120, or can be set to 150 for safety. Or you can actually update the widget twice (the maximum refresh rate), by setting the sleep to 500 ms only. Thus you still have 240 elements execution perminute. By optimizing the flow, you can have a higher refresh rate using the same AEP number.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Network Traffic

Post by digitalstone » 26 Jan 2018 00:07

I really appreciate your criticism because i want to get better at anything i do (because why not?), and i need all the help i can get.

But oh god, i never meant this as a final flow :shock:
This is just a test thingy to get the core algorithm going. From there i can then work my way out to 'perfect' the flow.

Of course the sleep action would get cut out of it, as everything would get integrated inside a bit more 'global' system that i have been working on for some time (in which is also going to be build an auto-On/Off function based on profile or other factors).

I'm afraid i just shared the rawest version of this whatever-thing i could have :roll:
Like the max 1000 executions per minute... i just Homer Simpson'ed it into it without actually calculating :lol:
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Network Traffic

Post by Desmanto » 26 Jan 2018 05:23

Hahaha, that's why I beg for sorry first. :D Still can't help to comment on example flow.

But I like the idea. If we don't have any network speed indicator, we can activate the flow only during certain operation, or app. Example MiXplorer sending file via TCP doesn't have any speed indication. We just "assume" it will be finished. Using the network indicator widget, we can know if the transfer has been finished or not yet. The divider can be adjusted to adapt to current speed. So speed above 1000000 will use MB divider instead.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Network Traffic

Post by digitalstone » 26 Jan 2018 11:29

MiXplorer? I'm using ES File Explorer for years now. It's a complete package including multiple forms of networking, and it includes transfer speeds an such when transmitting.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Network Traffic

Post by Desmanto » 26 Jan 2018 13:47

Off topic. I used to be EFE user too. But the latest version add too many bloat and shady activities (even the pro version do). I have tried to switch to MiXplorer in several occassions, probably 5-7 times. The last one was the one that stick, almost half year (it is about the same time I started posting here). I have uninstalled EFE and never looking back. MiXplorer basically has all of what EFE can offer, and even more. But of course there are some different concept. One of them is the TCP server vs Send By LAN in EFE. This one, MiX don't have the speed indicator. But other network operation such as copying to SMB, FTP etc, has the speed indicator.

It is all back to preference then.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Network Traffic

Post by digitalstone » 26 Jan 2018 15:44

Alrighty then, well that's weird. I have no experience with ads inside the pro version. Maybe they snapped that out of it. It does everything i want it to do fast and easy. But i shall take a look at MiX Explorer. Maybe there's donuts inside :)
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Post Reply