Store incoming packet duration time to do some operation

50 views
Skip to first unread message

phil Lin

unread,
Jan 7, 2020, 12:06:37 AM1/7/20
to ns-3-users
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?

Thanks,
Best regards.

Phil

Tom Henderson

unread,
Jan 7, 2020, 12:38:04 AM1/7/20
to ns-3-...@googlegroups.com, phil Lin
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

phil Lin

unread,
Jan 7, 2020, 4:54:22 AM1/7/20
to ns-3-users
Hi Tom,

Thank you for your reply.

So, you mean that I can't create an array to buffer the incoming packet a duration time?

Is it possible if I want to do the enqueue function repeatedly using the Simulator:: schedule function as you said?

Thanks,
Best regards.

Phil
Tom Henderson於 2020年1月7日星期二 UTC+8下午1時38分04秒寫道:

NINJA INFO

unread,
Jan 9, 2020, 10:12:39 AM1/9/20
to ns-3-...@googlegroups.com
Hi,

Please check this link. This page have some NS3 source code. It may helpful for you.


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/e7c5db54-6a7e-48aa-baf3-ce933b442444%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages