[Ns-developers] [ns3] socket API

Tom Henderson tomh at tomh.org
Wed May 21 07:19:19 PDT 2008


Mathieu Lacage wrote:

> There are two remaining issues which need to be dealt with (decided
> upon) before merging:
>   - removal of overloaded Socket::Send
>   - how do we deal with socket options
> 
> None of the two need to be necessarily fully implemented, but deciding
> what we are going to do seems like a reasonable requirement before
> merging.
> 

I pushed some updates to deal with the second issue above, which was the 
remaining open issue.

http://code.nsnam.org/tomh/ns-3-dev-socket

Following Mathieu's suggestion, socket options are now attributes of the 
  socket classes.  The main issue that needed to be resolved was 
"attributes of which class?".  There were a few choices (put them all in 
the socket base class, put them all in the derived classes, or introduce 
a couple of new abstract base classes).  I elected to do the latter, for 
the following reasons:

i) putting them in the socket base class results in base class options 
that have no meaning for certain types of sockets in our system
ii) putting them all in the derived classes results in a situation where 
they cannot be easily reused across implementations.  For instance, 
Florian and Sam are working on a TCP cradle implementation that could 
reuse the same default values stored in the attributes.

So, I added two new abstract base classes in src/node (class TcpSocket 
and class UdpSocket) that host the attributes, and moved the existing 
implementation classes to TcpSocketImpl and UdpSocketImpl, respectively. 
  This meant that the factory classes (Tcp and Udp) are just factories 
now, so I renamed them to TcpSocketFactory and UdpSocketFactory.  This 
renaming has the benefit of being aligned with the naming convention for 
PacketSocket.

 From an application API perspective, not much has changed, except that 
sockets are created by specifying the type id of the factory class 
"ns3::TcpSocketFactory" instead of "ns3::Tcp".  And (previously 
mentioned) a new helper method Socket::CreateSocket().

I added a couple of UDP socket options (regarding the setting of TTL on 
a per-socket basis).  We can promote options/attributes to the base 
class ns3::Socket if we find that they have applicability to all sockets.

Because this is a blocker for our beta release, I'd like to merge this 
and TCP tag code on Friday if there are no objections raised, and then 
freeze that and clean up for the release next week.

- Tom


More information about the Ns-developers mailing list