On 1/6/20 9:06 PM, phil Lin wrote:
> Dear all,
>
> I want to ask that how can I buffer every incoming packet in duration time?
> When netdevice received the packet from the upper layer, how can I store
> these packet in a few seconds then send it to down layer?
There is no built-in support for doing that, but if you want to just
have a fixed delay, you can possibly modify one of the functions to
schedule an event that would normally be directly called.
For instance, in the forwarding method for IPv4:
void
Ipv4L3Protocol::IpForward (Ptr<Ipv4Route> rtentry, Ptr<const Packet> p,
const Ipv4Header &header)
you can see that the last statement calls a method called SendRealOut():
SendRealOut (rtentry, packet, ipHeader);
Now, any method that returns void can be turned into a simulation event
in ns-3, so if you want to impose a 1 ms delay on forwarding, for
example, you can try something like this instead of the direct call to
SendRealOut:
Simulator::Schedule (MilliSeconds (1), &Ipv4L3Protocol::SendRealOut,
this, rtentry, packet, ipHeader);
The packet is 'stored' not in a queue in this case, but in a simulation
event that is scheduled to execute 1ms of virtual time later than the
current virtual time.
You can apply the similar technique to some other method in the
NetDevice if you want to place the delay there. Just remember that you
want to look for some method that returns type 'void' and schedule it
like above.
- Tom