Metadata-Version: 2.1
Name: windows-dscp-fix
Version: 0.2.1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Summary: fix setsockopt behavior for ToS/DSCP on Windows.
Keywords: windows,network,socket,development,tos,dscp
Author-email: sudo_free <sudofree@163.com>
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/iamhyc/windows-dscp-fix
Project-URL: Bug Reports, https://github.com/iamhyc/windows-dscp-fix/issues

# Windows DSCP Fix Python Package

A Python package to fix `setsockopt(..,IP_TOS,..)` behavior on Windows.

### Why

- In the [IPPROTO_IP socket options](https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options) for `setsockopt`, `IP_TOS` is marked as **"DO NOT USE"**, and [Windows QoS2 subsystem](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/qos/introduction-to-qos2--qwave-) takes over the admission.

- ToS/DSCP value is still an important field for QoS guarantee in IEEE 802.11 network, according to [RFC 8325](https://www.rfc-editor.org/rfc/rfc8325). However, there is no existing convenient method to tune the value.

- On Windows, only DSCP value is allowed to set except ECN bits and the Administrator permission is required ([link](https://learn.microsoft.com/en-us/windows/win32/api/qos2/nf-qos2-qossetflow)). So, this functionality has to be maintained as a third-party module, which will not be accepted by mainline.

### Usage

```python
import socket
import windows_dscp_fix
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, 128) #NOTE: Administrator permission required
```
