Bug 1361

Summary: Set TOS from Application level (sockets)
Product: ns-3 Reporter: Tommaso Pecorella <tommaso.pecorella>
Component: internetAssignee: George Riley <riley>
Status: RESOLVED FIXED    
Severity: enhancement CC: nikkipui, ns-bugs, tomh
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   

Description Tommaso Pecorella 2012-02-11 20:44:12 EST
http://groups.google.com/group/ns-3-users/browse_thread/thread/5be010835c4b5b71

Sockets should have an option like Linux's one:
-----
SO_PRIORITY
Set the protocol-defined priority for all packets to be sent on this socket. Linux uses this value to order the networking queues: packets with a higher priority may be processed first depending on the selected device queueing discipline. For ip(7), this also sets the IP type-of-service (TOS) field for outgoing packets. Setting a priority outside the range 0 to 6 requires the CAP_NET_ADMIN capability.
-----

IPv4 and IPv6 should honor the SO_PRIORITY.

Filing the bug with "enhancement" priority as a reminder.
Comment 1 Daniel L. 2012-09-04 13:25:19 EDT
Not sure if anyone is still interested in setting ToS.

Setting the ToS field on the socket should not a problem.

I'm not sure about IPv4 and IPv6 honoring the ToS field as it seems to me that the support is ambiguous and is OS/device specific.
Comment 2 Tom Henderson 2012-09-04 23:36:03 EDT
(In reply to comment #1)
> Not sure if anyone is still interested in setting ToS.
> 
> Setting the ToS field on the socket should not a problem.
> 
> I'm not sure about IPv4 and IPv6 honoring the ToS field as it seems to me that
> the support is ambiguous and is OS/device specific.

I would be interested if someone provided a patch for this.

I would suggest first to propose the API, get some agreement, then work on the implementation. 

We tend to try to align with Linux in the ns-3 IP implementation, so I would suggest to look at how IP_TOS, IP_RECVTOS, IPV6_TCLASS, and IPV6_RECVTCLASS are supported and try to mimic the behavior, as a first step.
Comment 3 Daniel L. 2012-09-07 09:40:57 EDT
I will think about the API for this. How do you want me to propose the API? Directly in here or the code review?
Comment 4 Daniel L. 2012-09-17 14:30:15 EDT
Please refer to: http://codereview.appspot.com/6488134/

I could not find an option to set IP_TCLASS for IPv6 in the Linux kernel. Not sure if I missed it. As far as I know, the current Linux kernel still using IP TOS, not DSCP.
Comment 5 Daniel L. 2012-09-24 16:37:19 EDT
Sorry for the re-post. I made some changes to support IPv6 IPV6_TCLASS option.

http://codereview.appspot.com/6543061/
Comment 6 Daniel L. 2012-11-20 18:00:49 EST
Changeset: 9145:5752b425cdf5