Skip to content
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

BUG: Error setting DSCP/ToS field for IPv6 ICMP packets #2

Open
olafayomi opened this issue Mar 22, 2023 · 3 comments
Open

BUG: Error setting DSCP/ToS field for IPv6 ICMP packets #2

olafayomi opened this issue Mar 22, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@olafayomi
Copy link

Describe the issue:

Hi,
I'm trying to set the DSCP/ToS field for outgoing IPv6 ICMP packets with gufo-ping but I am getting a 'Protocol not available (os error 92)' . It seems IPv4 uses IPPROTO_IP/IP_TOS while IPv6 uses IPPROTO_IPV6/IPV6_TCLASS. I was wondering if this has been encountered before?

regards
Dimeji

Reproduce the code example:

import asyncio
import sys

from gufo.ping import Ping


async def main(address: str, size: int = 64, count: int = 10) -> None:
    ping = Ping(size=size, tos=48)
    n = 0
    print(f"PING {address}: {size} bytes")
    received = 0
    async for r in ping.iter_rtt(address):
        if r is None:
            print(f"Request timeout for icmp_seq {n}")
        else:
            print(
                f"{size} bytes from {address}: "
                f"icmp_seq={n} time={r*1000.0:.3f}ms"
            )
            received += 1
        n += 1
        if n >= count:
            break
    print(f"--- {address} ping statistics ---")
    loss = float(count - received) / float(count) * 100.0
    print(
        f"{count} packets transmitted, "
        f"{received} packets received, "
        f"{loss:.1f}% packet loss"
        )


if __name__ == "__main__":
        asyncio.run(main(sys.argv[1]))

Error message:

python gufo-ping.py  2001:df01::1
PING 2001:df01::1: 64 bytes
Traceback (most recent call last):
  File "gufo-ping.py", line 34, in <module>
    asyncio.run(main(sys.argv[1]))
  File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "gufo-ping.py", line 12, in main
    async for r in ping.iter_rtt(address):
  File "/home/ubuntu/gufo-ping/lib/python3.8/site-packages/gufo/ping/ping.py", line 195, in iter_rtt
    sock = self.__get_socket(addr)
  File "/home/ubuntu/gufo-ping/lib/python3.8/site-packages/gufo/ping/ping.py", line 120, in __get_socket
    sock = PingSocket(
  File "/home/ubuntu/gufo-ping/lib/python3.8/site-packages/gufo/ping/socket.py", line 69, in __init__
    self.__sock.set_tos(tos)
OSError: Protocol not available (os error 92)

Python version information

python print-version.py
3.8.0 (default, Dec 9 2021, 17:53:27)
[GCC 8.4.0]

Gufo Ping version information

gufo-ping version: 0.2.4

Operation system version

Ubuntu 18.04

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic

@olafayomi olafayomi added the bug Something isn't working label Mar 22, 2023
@dvolodin7 dvolodin7 self-assigned this Mar 22, 2023
@olafayomi
Copy link
Author

@dvolodin7 Hi Dmitry,
How can I help with fixing this bug ? I don't know much about Rust but I could help with the Python side of it. Fixing this bug or adding the source address feature will greatly help with what I'm trying to do.

@dvolodin7
Copy link
Contributor

Hi,

I have reproduced this error. BTW, setting ttl on IPv6 is also fails.

@dvolodin7
Copy link
Contributor

I have open the issue rust-lang/socket2#420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants