How to set the TOS value from Application layer?

Skip to first unread message


Feb 10, 2012, 9:28:43 AM2/10/12
to ns-3-users
I want to set the TOS value according to the application type in the
application layer, not set TOS value directly in IP header. It means
the TOS value must pass from application layer.
Does anyone can tell me how to do that?

Tommaso Pecorella

Feb 11, 2012, 8:39:42 PM2/11/12
to ns-3-users

you can't, Yet. Sorry.

I'll open a enhancement request about it.



tran the son

Feb 12, 2012, 5:17:31 AM2/12/12

Thank you for your reply. It seem to me that ns-3 is hard to build up a hetorogeneous network configuration

You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Tommaso Pecorella

Feb 12, 2012, 6:34:25 AM2/12/12
to ns-3-users

it's not easy, but if that can help, it's not easy in a real network

Even if setting SO_PRIORITY on a socket is possible on linux, usually
the TOS is set up by accessor elements not under user's control, in
order to prevent easy network hacking. ISPs (and local networks)
preferred way to setup TOS is by using 802.1q or by marking the
packets in the proper network element, as is a border network element
like a router.

Inside the router, packets are not flowing through L4 protocols, only
IP layer is decoded (i.e., you'd use Raw sockets, exposing the IP
layer and, only if necessary, peeling the L4 ports info from the
packet. So, basically, marking is done *without* application's aid.

Now, consider that ns-3 is a simulator. Its functionalities are built
according to user's needs, so when someone find something that is not
yet possible, the feature will be (might be) added. Some features of
real networks are not in ns-3 simply because they're not useful for a
simulation, and they'd slow down the code execution or they'd make the
code more complex to maintain. Our rule is: don't add if it's not

To be able to mark TOS packets might, as a matter of fact, be useful.
Plus it can fit nicely in an ongoing code change (meant to add a
different feature, but we can grab 2 birds with one stone). Hence,
soon it will be possible. Probably in the next release.

If you want to contribute to the code change, this is the reference:



On Feb 12, 11:17 am, tran the son <> wrote:
> Thank you for your reply. It seem to me that ns-3 is hard to build up a
> hetorogeneous network configuration

tran the son

Feb 12, 2012, 7:17:56 AM2/12/12

Thank you so much for your reply, Tommaso.
Hopefully we have interesting chat late on.


On Feb 12, 2012 11:34 AM, "Tommaso Pecorella" <> wrote:

Peng Wang

Mar 5, 2015, 10:34:05 AM3/5/15
Hi Tommaso,

To make my question be clear, I replied you in this question without posting a new one.

I am also have problem to set TOS from application layer. I notice that the latest ns3 already integrated IP_TOS into socket options. But I am not clear how to set the value of IP_TOS form specific kind of application like onoffapplication. Could you provide some hints on it if you know something. 

Thanks for your time and looking forward to your reply.  

Best Regards,

Tommaso Pecorella

Mar 5, 2015, 12:04:22 PM3/5/15

over the years things may get simpler.
Use Socket::SetIpTos (uint8_t tos).
You need to find the Socket being used by the Application tho, or to modify the application code. By default the OnOffApplication doesn't set the IP TOS.

Hope this helps,

Reply all
Reply to author
0 new messages