Where has the virtual function socket::send(Ptr< Packet > p, uint32_t flags ) been actually defined?

20 views
Skip to first unread message

Jie Chen

unread,
Dec 2, 2019, 10:52:22 AM12/2/19
to ns-3-users
Hi all,

I am trying to work through a whole procedure of application at the sender sending down packets and the receiver receiving it. I am new to NS3.

I figure out that the application for example OnandOff will call the socket->send(p) to send out the packet, which eventually calls the virtual function socket::send(p,0). Can anybody kindly instruct me where to find the actual implementation of the send(Ptr<Packet> p, uint32_t flags) function in the NS3 source code? It must be defined somewhere otherwise the packets would not have been sent out.

Thanks a million in advance,

Best,

Jie Chen

Hassam Mughal

unread,
Dec 2, 2019, 1:45:47 PM12/2/19
to ns-3-users

Jie Chen

unread,
Dec 3, 2019, 4:43:46 AM12/3/19
to ns-3-users
Hi Hassam,

Thanks for getting back to me.

However, the link you sent to me display the virtual function send(p,flag)...It has not concrete definition and can not be actually called when the program runs. Suppose it was being called in the program, it actually had done nothing. In this case, the packet would have gone nowhere.

I would much appreciate it if you could let me know an implementation function of this virtual function somewhere in the codes. 

Thanks again,

Best,

Jie

Nataraju A B (Gmail)

unread,
Dec 3, 2019, 5:41:22 AM12/3/19
to ns-3-...@googlegroups.com
this send() function shall be mapped on to send() system call provided by the operating system

--
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/d2e92b93-7d55-4bce-9790-1d073b3a8d05%40googlegroups.com.

Jie Chen

unread,
Dec 3, 2019, 6:58:13 AM12/3/19
to ns-3-users
This function matches closely in semantics to the send() function call in the standard C library (libc): ssize_t send (int s, const void *msg, size_t len, int flags); except that the send I/O is asynchronous. This is the primary Send method at this low-level API and must be implemented by subclasses.

Thanks Nataraju. I am a bit lost. Supposedly the send() function will call the other node's recv function based on the routing table. It can not just use the operating system's send() function though they are semantically close. As noted in the NSNAM source, the send function must be implemented by subclasses. Henceforth I will stick to my previous understanding that there might be somewhere in the source codes that actually implement the send(p,0).

If you think it calls the send() system call, may I get to know the details of this send() system call function as I am trying to figure out how a packet is being transmitted along the node path?

Thanks a million in advance,

Best,

Jie
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.

Nataraju A B (Gmail)

unread,
Dec 3, 2019, 10:11:54 AM12/3/19
to ns-3-...@googlegroups.com
Some pointers, but not exact answer....

to support nonblocking I/O, the send() / recv() operations are being supported with the help of Callback functions.
You may have to look at the following functions....
SetSendCallback()
SetRecvCallback() 
m_sendCb
m_receivedData


Jie Chen

unread,
Dec 3, 2019, 12:30:46 PM12/3/19
to ns-3-users
Hi Nataraju,

Thanks very much for getting back to me.

May I kindly get to know who/which component is going to receive the packet in the send()? I think it will be the next hop node on the routing table to receive the packet. But not sure how exactly it is being implemented in NS3.

Best,

Jie
Reply all
Reply to author
Forward
0 new messages