-
Notifications
You must be signed in to change notification settings - Fork 48
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
Feature request: DSCP/TOS Flags #11
Comments
Hi @onkelbeh, ICMP must use the value 0 for the Type of Service field according to the RFC 792. I'm not sure it's a good idea to modify this field. In addition, routers manage themselves the priority of ICMP packets. Therefore, this field is certainly ignored. |
Hi Valentin, oh, thats not entirely correct. You mention RFC 792, which was written 1981, a long time before RFC 2474. Best Overview: https://en.wikipedia.org/wiki/Type_of_service, take a closer look at reference 1. Only bit 0 has always to be zero :-) ip utils ping and traceroute can set them ( Having a larger VPN setup with lots of internet connections, I have to use DSCP and TOS for path selection. For user traffic, we currently use 6 different classes for our internal traffic, eg. Voice, Video, Transactional, Interactive, Bulk and Scavenger. Thats only 6 at the moment because we have now enough bandwidth (our Bosses have been generous during the virus). But this will change again. Our routers for example will honor 2 bits of DSCP for adjusting the drop propability of packets on overloaded links. And, since the virus, we have a lots of This is the best table I found: Many of our management scripts are written in Python, and after I discovered your library through the Home Assistant Component, I hoped I could use and improve it to fit our needs, it's lightweighted and easy to integrate. I'm not sure how complex this is in python to correctly call setsockopt. I played around a bit with socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_ICMP)
socket.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, 184) to mark them with DSCP Anyway, there must be a way in Python, because Scapy can do it. I'd like to avoid using Scapy as a library for it, because this thing is the overkill and has a complex API. And, for regular checks, it's way too big to be loaded several times a second. If you have 70 sites and an average of 4 paths then I have to run ~4 checks/second to get one measurement per path and minute. Perhaps you can take a look at it. I would be glad to help / test ... |
Thank you for taking the time to cite use cases, information about existing implementations, and QoS details 👍 It's really interesting. I will try to implement this feature. Otherwise, Scapy doesn't use As for icmplib, it only manages the ICMP header. |
I have successfully set the TOS field on Linux and macOS. However, I see that it doesn't work on Windows. From what I've read, Windows now ignores this field:
It is now necessary to use the Quality of Service API, which is not possible in Python. The alternative solution would be to manipulate the full IP header, which is overkill for current needs.
Last solution and I may prefer this one, provide this feature only for Unix systems. What do you think? |
For me it would be OK if it's not working on Windows. 🥇 I'm the Python on Linux guy :-) And yes, Windows is not designed to forward packets. Thanks for thinking about it. |
OK! I love Linux too 😄 I will try to implement this feature for the next version of icmplib ( Do you have any idea of the name we could give to the property of the Examples: # Ping
ping('1.1.1.1', priority=184)
# Traceroute
traceroute('1.1.1.1', priority=184)
# ICMPRequest (low level)
ICMPRequest('1.1.1.1', id=1000, sequence=1, priority=184) |
So true 😅 ... but I finally thought long and hard and the name of the property will be icmplib 1.2, including this feature, will be released tomorrow with more features and fixes. I am currently doing the last tests. |
icmplib 1.2 is available! You can now define the
I've tested on several platforms and it works, except on Windows of course (the value is ignored). |
Yeah, thats cool. Thank you very much. |
Did you have time to test? |
Hi, Have a very busy time, still a lot are on vacation, and some fool killed one of the backup servers last week, Also, Currently thinking about a way to use your multiping feature, this could avoid a lot of load/import time. In the example below you can see the different loop time for AF21 traffic, root@lnx-monitoring:/usr/lib/python3.7/site-packages/icmplib # traceroute -I 192.168.96.65 -t 70
traceroute to 192.168.96.65 (192.168.96.65), 30 hops max, 60 byte packets
1 vt3.dgn.in.streicher.de (192.168.57.97) 1.952 ms 2.018 ms 2.270 ms
2 isr-dgn1.router.in.streicher.de (192.168.95.36) 1.001 ms 1.239 ms 1.348 ms
3 isr-deg01.router.in.streicher.de (192.168.249.1) 25.213 ms 25.460 ms 25.666 ms
4 isr-jena01.router.in.streicher.de (192.168.249.97) 68.089 ms 68.404 ms 68.605 ms
5 vt1-1.jena.in.streicher.de (192.168.96.65) 101.025 ms 101.298 ms 101.527 ms
root@lnx-monitoring:/usr/lib/python3.7/site-packages/icmplib # traceroute -I 192.168.96.65 -t 72
traceroute to 192.168.96.65 (192.168.96.65), 30 hops max, 60 byte packets
1 vt3.dgn.in.streicher.de (192.168.57.97) 1.777 ms 1.902 ms 2.154 ms
2 isr-dgn1.router.in.streicher.de (192.168.95.36) 0.647 ms 0.944 ms 1.053 ms
3 isr-dgn02.router.in.streicher.de (192.168.248.65) 1.379 ms 1.562 ms 1.687 ms
4 isr-jena02.router.in.streicher.de (192.168.250.98) 17.480 ms 18.101 ms 18.361 ms
5 vt1-1.jena.in.streicher.de (192.168.96.65) 35.467 ms 35.666 ms 35.803 ms
root@lnx-monitoring:/usr/lib/python3.7/site-packages/icmplib # ping 192.168.96.65 -Q 70 -c3
PING 192.168.96.65 (192.168.96.65) 56(84) bytes of data.
64 bytes from 192.168.96.65: icmp_seq=1 ttl=251 time=79.9 ms
64 bytes from 192.168.96.65: icmp_seq=2 ttl=251 time=73.0 ms
64 bytes from 192.168.96.65: icmp_seq=3 ttl=251 time=84.9 ms
--- 192.168.96.65 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 73.046/79.276/84.874/4.849 ms
root@lnx-monitoring:/usr/lib/python3.7/site-packages/icmplib # ping 192.168.96.65 -Q 72 -c3
PING 192.168.96.65 (192.168.96.65) 56(84) bytes of data.
64 bytes from 192.168.96.65: icmp_seq=1 ttl=251 time=33.8 ms
64 bytes from 192.168.96.65: icmp_seq=2 ttl=251 time=48.3 ms
64 bytes from 192.168.96.65: icmp_seq=3 ttl=251 time=29.3 ms
--- 192.168.96.65 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2018ms
rtt min/avg/max/mdev = 29.349/37.176/48.346/8.107 ms root@lnx-monitoring:/usr/lib/python3.7/site-packages/icmplib # python
Python 3.7.8 (default, Sep 2 2020, 17:07:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from icmplib import ping, traceroute, Host, Hop
>>> host = ping('192.168.96.65', count=3, interval=0.1, traffic_class=70)
>>> print (host.avg_rtt)
75.801
>>> host = ping('192.168.96.65', count=3, interval=0.1, traffic_class=72)
>>> print (host.avg_rtt)
29.756
>>> hops = traceroute('192.168.96.65', count=3, interval=0.1, traffic_class=70)
>>> hops2 = traceroute('192.168.96.65', count=3, interval=0.1, traffic_class=72)
>>> print (f"{hops}\n{hops2}")
[<Hop 1 [192.168.57.97]>, <Hop 2 [192.168.95.36]>, <Hop 3 [192.168.249.1]>, <Hop 4 [192.168.249.97]>, <Hop 5 [192.168.96.65]>]
[<Hop 1 [192.168.57.97]>, <Hop 2 [192.168.95.36]>, <Hop 3 [192.168.248.65]>, <Hop 4 [192.168.250.98]>, <Hop 5 [192.168.96.65]>]
>>> |
I'm glad to hear that everything is working fine. 👍 However, what do you mean by "load/import time"? |
Ah, sorry, did not explain: |
OK I better understand 😃 If you have other requests afterwards do not hesitate to open new issues. |
Would be a great feature to have the possibilty to set DSCP/TOS bits for ICMP and traceroute.
Thanks in advance.
The text was updated successfully, but these errors were encountered: