arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.16k stars 994 forks source link

TOS isn't being applied #6812

Open tiagogaspar8 opened 2 years ago

tiagogaspar8 commented 2 years ago

libtorrent version (or branch): 2.0.5 (in qbittorrent)

platform/architecture: Windows 11

compiler and compiler version: N/A

please describe what symptoms you see, what you would expect to see instead and how to reproduce it.

The TOS doesn't seem to be applying correctly, it is configured to 4 by default but in wireshark the DSCP isn't changed and stays at CS0 (0). I'd also like to suggest the change from the name TOS to DSCP since TOS is deprecated.

Thanks!

arvidn commented 2 years ago

did you look at all traffic or just some connections? I believe DSCP is only meant to apply to peer connections, not DHT or tracker connections for instance.

arvidn commented 2 years ago

are you looking at both TCP and UDP peer connections? The DSCP is set via slightly different code paths for those.

arvidn commented 2 years ago

do you see the SET_TOS messages in the log?

arvidn commented 2 years ago

https://github.com/arvidn/libtorrent/pull/6822

tiagogaspar8 commented 2 years ago

Hi,

My setup only has μtp enabled, and that doesn't have any dscp, I can't say about TCP, but I believe I can try if you'd like!

cas-- commented 2 years ago

@arvidn This rename has broken compatibility and generating errors in Deluge with latest lt 1.2 code, was this applied to the wrong branch (for 2.0 not 1.2) and missing setting deprecated in settings_pack.cpp?

self.session.apply_settings(settings)
builtins.KeyError: 'unknown name in settings_pack: peer_tos'
arvidn commented 2 years ago

good point. I need to fix the binding to support the old name as well.

arvidn commented 2 years ago

https://github.com/arvidn/libtorrent/pull/6874

tiagogaspar8 commented 2 years ago

Hi @arvidn , I'd just like to let you know that TCP also suffers from the same issue, dscp isn't marked

arvidn commented 2 years ago

is it possible the process need a special privilege to set it? Do you have any error messages in the log for setting DSCP?

tiagogaspar8 commented 2 years ago

I have tried to run it as an admin but it didn't help

arvidn commented 2 years ago

@tiagogaspar8 can you get the log? Do you see entries saying SET_TOS or SET_DSCP? If so, they will contain error codes.

tiagogaspar8 commented 2 years ago

I'm using qbittorrent and I have no idea how to enable extra debug logging 😞 Do you have any idea?

mzz2017 commented 1 year ago

In the implementation of libtorrent, dscp/tos is always set after the application handshake instead of the TCP handshake. This behavior breaks possibility of traffic split via tos by proxy, because the traffic split in proxy application always happens at the moment TCP syn=1.

We have to solve the problem with some inelegant methods, see https://github.com/daeuniverse/dae/discussions/295.

The tos setting is wonderful, but the current timing of the option setting is preventing it from being used, hope you can fix it, thanks!

mzz2017 commented 2 months ago

@arvidn Any progress please?

arvidn commented 2 months ago

I see that it's currently applied after the TCP handshake (and in the case of SSL, after the SSL handshake). I can move it to before connecting, but that only affects outgoing connections. Is there a way to be applied earlier for incoming connections? Should I set TOS/DSCP on the listen socket as well?

arvidn commented 2 months ago

does this make a difference? https://github.com/arvidn/libtorrent/pull/7696