dtaht / Diffserv

An attempt to fully classify packets on a home router into diffserv
5 stars 4 forks source link

P2P DSCP in DB #1

Open Hacklin opened 13 years ago

Hacklin commented 13 years ago

The DSCP value for P2P in db/dscp.sql (33) and scripts/codepoints.sh (9) differ.

dtaht commented 13 years ago

Harmonizing all this stuff is really important. I note also http://www.bufferbloat.net/issues/249 introduces a problem with ipv6 that I have not verified exists on linux 3.03. harmonizing 802.1p and 802.11e does introduce a problem with the differences on how queuing works on pfifo_fast vs mq, and also vs mq_prio.

Similarly, harmonizing with http://www.bufferbloat.net/projects/bloat/wiki/Diffserv_RFC

Hacklin commented 13 years ago

IPv6 DiffServ

IPv4   IPPROTO_IP     IP_TOS
IPv6   IPPROTO_IPV6   IPV6_TCLASS

So, to set the DSCP in IPv6 you must use IPv6 Traffic Class field.

int ds = IPTOS_DSCP_AF11;
int rc = setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &ds, sizeof(ds));
if (rc < 0) do_log_error(L_WARN, errno, "Couldn't set TC");

Notes:

  1. You use 'socket_prio' instead of 'ds'. You are aware that the DS field is an IP level option and that there is a socket level 'SO_PRIORITY' option? You're not mistakenly setting the socket's priority value as the DSCP?
  2. You use an option length of '1'. However, the setsockopt() code that I've seen use an optlen of 'sizeof(int)'.
  3. Hopefully you this will close Issue 249.
dtaht commented 13 years ago

1) IPV6_TCLASS??? jeeze, never heard of it. And recently there was a bug against that too, fixed in linux.

that said, I suspect I'm not the only one that doesn't get this difference:

https://lists.bufferbloat.net/pipermail/bloat-devel/2011-August/000215.html

Secondly I'm aware of the difference between SO_PRIORITY and dscp, and am using both in various places. SO_PRIORITY can be used for example to tweak mac80211 classes directly, without affecting the packet.

  1. Some places it's an int, other places it's a char, I'll poke into it.
  2. After I patch all the apps I'd intended to patch and see shapers 'doing the right thing'.
Hacklin commented 13 years ago

1) There is almost no overlap in IPv4 and IPv6 socket options. And the socket API defines a seperate set of options for each protocol (socket level). Therefore, to set IPv4 options you use IPPROTO_IP and to set IPv6 options you use IPPROTOIPV6. And IPv4 options are named IP* (netinet/in.h) and the IPv6 ones IPV6_* (netinet/in6.h).

The exception is the DiffServ (DS) field; it's the same for IPv4 and IPv6. IPv4 has a Type-of-Service (ToS) field and IPv6 has a Traffic Class (TC) field. And only later have both the ToS and TC fields been redefined as the DS field (netinet/ip.h).

That's why you have seperate IP_TOS and IPV6_TCLASS options instead of an IP_DS.

2) When I saw the char, I was surprised. Because usually it's an int and a char may not work on a non-Linux OS. When I googled a little around, the code I found used an int. (I prefer applications to be as cross platform as possible.)

Manuel Stol

E-mail: ManuelStol@operamail.com

On Monday, September 19, 2011 6:47 PM, "Dave Täht" reply@reply.github.com wrote:

1) IPV6_TCLASS??? jeeze, never heard of it. And recently there was a bug against that too, fixed in linux.

that said, I suspect I'm not the only one that doesn't get this difference:

https://lists.bufferbloat.net/pipermail/bloat-devel/2011-August/000215.html

Secondly I'm aware of the difference between SO_PRIORITY and dscp, and am using both in various places. SO_PRIORITY can be used for example to tweak mac80211 classes directly, without affecting the packet.

  1. Some places it's an int, other places it's a char, I'll poke into it.
  2. After I patch all the apps I'd intended to patch and see shapers 'doing the right thing'.

Reply to this email directly or view it on GitHub: https://github.com/dtaht/Diffserv/issues/1#issuecomment-2140773

http://www.fastmail.fm - Or how I learned to stop worrying and love email again

zenczykowski commented 12 years ago

btw. for IPv6 sockets which may be serving IPv4 connections, you want to set both IP_TOS and IPV6_TCLASS.

The kernel will use IPV6_TCLASS for native ipv6 wire format traffic and IP_TOS for native ipv4 wire format when building outgoing packets from a socket.

zenczykowski commented 12 years ago

(you may also want to make sure that any tunnels (gre/sit/ipip/etc) have ttl inherit option set, not even sure atm if this is doable for ipv6 in ipv4 encapsulation (ie. sit))

dtaht commented 12 years ago

I have done my best to push the TCLASS concept out into multiple open source projects, and alert others as to the correct procedure. So, since alerted to how to do this, it's now in openssh, quagga, quagga-re, babel, dropbear, and dnsmasq.

One thing I'm really happy about is that it is not only now in netperf svn, but it can be set for both local and remote tests, via remote control, via the -Y option. It was very interesting to observe that for ipv4, most diffserv classification schemes do not survive transit over the internet, but ipv6, they do.

TCLASS support is not in polipo (and I'd like it to be), nor named (and I'd like it to be), at present. There are dozens of other applications such as apache, lighttpd, ngnix,etc where it could be added. But ENOTIME.

dtaht commented 12 years ago

As for the tunnelling issue, I'll try to remember it.More important is getting the darn mtus right...