-
Notifications
You must be signed in to change notification settings - Fork 287
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
feat: Implement Tox network profiler #1885
base: master
Are you sure you want to change the base?
Conversation
b93009f
to
75fd324
Compare
84ab794
to
687d5b5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1885 +/- ##
==========================================
- Coverage 73.08% 72.99% -0.09%
==========================================
Files 149 150 +1
Lines 30531 30714 +183
==========================================
+ Hits 22313 22420 +107
- Misses 8218 8294 +76
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 19 files at r1, 8 of 9 files at r2, all commit messages.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @JFreegman)
toxcore/tox_private.h, line 60 at r1 (raw file):
Previously, JFreegman wrote…
The reason I named it ZERO is because it has a different purpose depending on the packet type (see the above comment). Any suggestions?
Ok, that's fine then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 19 files at r1.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @JFreegman)
5700751
to
53d50e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing, we should be able to inject a custom struct Network
and compare total packet numbers there.
TOX_NETPROF_DIRECTION_RECV); | ||
} | ||
|
||
const unsigned long long total_packets = total_sent_count + total_recv_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally prefer size named types like uint64_t
over unsigned long long
.
@@ -18,6 +18,7 @@ | |||
#include "DHT.h" | |||
#include "Messenger.h" | |||
#include "TCP_client.h" | |||
#include "TCP_server.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this right?
@@ -20,6 +20,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some places, like here, don't need to know the full type and a forward declaration instead would suffice.
@@ -15,6 +15,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too.
@@ -10,6 +10,7 @@ | |||
#include "crypto_core.h" | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "net_profile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here. (we only store a pointer)
@@ -15,6 +15,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or here.
@@ -20,6 +20,7 @@ | |||
#include "logger.h" | |||
#include "mem.h" | |||
#include "mono_time.h" | |||
#include "net_profile.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too ... i feel like we should forward declare it in some public places.
@@ -999,6 +1008,11 @@ int send_packet(const Networking_Core *net, const IP_Port *ip_port, Packet packe | |||
loglogdata(net->log, "O=>", packet.data, packet.length, ip_port, res); | |||
|
|||
assert(res <= INT_MAX); | |||
|
|||
if (res == packet.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i saw a data != nullptr
earlier, should it be put everywhere, like here too?
* Bootstrap info packet. | ||
*/ | ||
TOX_NETPROF_PACKET_ID_BOOTSTRAP_INFO = 0xf0, | ||
} Tox_Netprof_Packet_Id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all public facing enums in toxcore now have a *_to_string()
function. Since there are alot of values here, it would be very valuable.
Maybe it can also take in the type (tcp/udp), to print a sensible string? or maybe I am just dreaming here...
3972670
to
e740b4e
Compare
I get a lot of
supposed to be |
The beating heath of a toxcore: tomato_netprof_tableheat2.mp4 |
Are you sure that's not a custom packet ID in your client/modified toxcore? I'm not seeing the same thing with Toxic. If you disable UDP you should see that it doesn't record any UDP packets at all, so if that's the case it definitely has to be a UDP packet with an invalid ID, in which case toxcore should be logging it. Edit: It appears that you're recording 0x10 as a TCP ID as well in that bottom video. |
Yep, I am running master with netprof, no "modified" toxcore in that sense.
Well yes. BTW, I copied the names/descriptions from the enum and there are some inconsistencies. |
Ok, after setting a conditional breakpoint and not hitting any UDP, I checked your code and found this. c-toxcore/toxcore/net_profile.c Lines 83 to 86 in e740b4e
I think the way this is done leads to confusion. It should not be done at the lower level, since profile does not know whether it is UDP or TCP... |
I'm not sure what you mean. I'm not sure how your client ended up thinking those were UDP packets. It knows they're TCP packets because you passed a TCP packet ID and TCP profile to the function ( |
I prefer to use a simple for loop for |
0x00 through 0x09 are already in use. 0x10 through 0x255 are all data packet ID's, which includes custom packets. As far as forward compatibility goes, if we were to change TCP data packet ID's, we would completely break the TCP implementation regardless.
I don't think you understand how recording/querying works. There are already numerous packet ID's that are used for UDP and TCP (which is why the API enums have shared ID's). There are three distinct profiles - TCP server, TCP client, and UDP, which are queried using the |
0a0f896
to
176196c
Compare
5e00766
to
6791a8a
Compare
This change is