I am new to NS3, learning NS3 from its tutorial. In the tutorial example first.cc, it shows how to use PointToPointHelper
and UdpEchoClientHelper
to make a P2P test, we can find how to set Data Rate
and Delay
of channel. But I want to set jitter and loss rate of channel, is there any method?
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
....
The good news is that the tutorial already covers this
ns-3 provides ErrorModel objects which can be attached to Channels. We are using the RateErrorModel which allows us to introduce errors into a Channel at a given rate.
Ptr<RateErrorModel> em = CreateObject<RateErrorModel> (); em->SetAttribute ("ErrorRate", DoubleValue (0.00001)); devices.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (em));
The above code instantiates a RateErrorModel Object, and we set the “ErrorRate” Attribute to the desired value. We then set the resulting instantiated RateErrorModel as the error model used by the point-to-point NetDevice. This will give us some retransmissions and make our plot a little more interesting.
Jitter is a function of the processing and queuing delay encountered by the packets. It's not a quantity that you set directly. Rather, it is calculated based on measurements of latency of all packets across the life of a connection. The typical definition of jitter is the standard deviation of latency of all packets across the life a connection.
So, ns-3 does not offer a way to set jitter directly (though it could since it's a simulator, but I digress).
But there is hope: if you want to change the jitter, you need to change the processing and queuing delays. Processing delay is a bit iffy, but queuing delays can easily be changed by choosing the type of Queue on the NetDevice. Refer to the TxQueue
Attribute of the PointToPointNetDevice.