Next: 4. Core Modules
Up: 3.4 Sockets and Applications
Previous: 3.4 Sockets and Applications
Contents
Index
The sockets API exported to ns-3 attempts to mimic the standard BSD
sockets API. The major difference in the implementation is that while BSD
socket calls are synchronous (that is, they do not return control to their
caller until they complete), the ns-3 socket API calls return immediately.
This is
due to the fact that in a simulation environment where one machine is
simulating possibly thousands of socket calls across different simulated
machines simultaneously, the simulator simply cannot afford to wait for the
socket function call to return. The way the software handles the situation
instead is by returning immediately, then using callbacks when other portions
of the code need to be notified of a socket event. For example, when in the
course of the simulation a socket is directed to listen() on a specific port,
the caller also provides a callback to handle when the socket receives a
connection request. The listen() method returns immediately, and then whenever
the socket receives the connection, it invokes the callback to handle the
connection. Similar things happen for the other common socket APIs, like
send(), connect(), and bind().
Next: 4. Core Modules
Up: 3.4 Sockets and Applications
Previous: 3.4 Sockets and Applications
Contents
Index
Tom Henderson
2007-06-17