One of the changes between ns-3 ver 3.25 and ver 3.26 is that it is possible to set TOS value to the address. Doxygen states following:
https://www.nsnam.org/docs/release/3.26/models/html/sockets-api.html
The native sockets API for ns-3 provides two public methods (of the Socket base class):
- void SetIpTos (uint8_t ipTos);
- uint8_t GetIpTos (void) const;
to set and get, respectively, the type of service associated with the socket. These methods are equivalent to using the IP_TOS option of BSD sockets. Clearly, setting the type of service only applies to sockets using the IPv4 protocol. However, users typically do not set the type of service associated with a socket through ns3::Socket::SetIpTos() because sockets are normally created by application helpers and users cannot get a pointer to the sockets. Instead, users can create an address of type ns3::InetSocketAddress with the desired type of service value and pass it to the application helpers:
- InetSocketAddress destAddress (ipv4Address, udpPort);
- destAddress.SetTos (tos);
- OnOffHelper onoff ("ns3::UdpSocketFactory", destAddress);
For this to work, the application must eventually call the ns3::Socket::Connect() method to connect to the provided destAddress and the Connect method of the particular socket type must support setting the type of service associated with a socket (by using the ns3::Socket::SetIpTos() method). Currently, the socket types that support setting the type of service in such a way are ns3::UdpSocketImpl and ns3::TcpSocketBase.
The type of service associated with a socket is then used to determine the value of the Type of Service field (renamed as Differentiated Services field by RFC 2474) of the IPv4 header of the packets sent through that socket, as detailed in the next sections...
m_sendSocket->Connect (m_peer);
//setIPtos to top priority
m_sendSocket->SetIpTos(16);
//setIPtos to top priority
m_peer.SetTos(16)
m_sendSocket->Connect (m_peer);
error: ‘class ns3::Address’ has no member named ‘SetTos’
m_peer.SetTos(16);void ns3::InetSocketAddress::SetTos ( uint8_t tos ) /* Inherit from Socket class: Initiate connection to a remote address:port */
int
TcpSocketBase::Connect (const Address & address)
OnOffHelper::OnOffHelper (std::string protocol, Address address)
{
m_factory.SetTypeId ("ns3::OnOffApplication");
m_factory.Set ("Protocol", StringValue (protocol));
m_factory.Set ("Remote", AddressValue (address));
}
NS_LOG_INFO ("Create Applications.");
uint16_t port = 9; // Discard port (RFC 863)
OnOffHelper onoff ("ns3::UdpSocketFactory",
Address (InetSocketAddress (i3i2.GetAddress (0), port)));
onoff.SetConstantRate (DataRate ("448kb/s"));
ApplicationContainer apps = onoff.Install (c.Get (0));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
//setIPtos to top priority
m_peer.SetTos(16)
m_sendSocket->Connect (m_peer);
//setIPtos to top priority
m_peer.SetTos(24)
m_sendSocket2->Connect (m_peer);
Does it solve your problem?
Stefano