[Ns-developers] ns3 - removal of Socket::HalfClose callbacks

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Thu Mar 20 20:26:27 PDT 2008


hi raj,

As a user, here is my understanding of what was expected to happen. 

If I am A and I am connected to B, I can get two types of closure
events:

  - I request a half-close with B so, I send a FIN with a shutdown
(WRITE). I want to be notified when I receive the ACK for this FIN. The
reception of this ACK is one type of closure event.

  - B requests a half-close with me so, B sends a FIN and I have to
reply with an ACK. The reception of this FIN is one other type of
closure event.

So, to comment about the two types of callbacks you mention below, it is
my understanding that they are used to identify the two different kinds
of closure events I identified above. I personally don't care much
whether you really want to tell the difference between the two kinds of
closures but I guess that this is the rationale for the current API.
However, as you point out, this is not very well documented (and,
although I did not come up with this part of the API myself, I am to
blame for the documentation I think :).

So, to summarize, is your proposed fix ok ? I don't know. It depends on
what the use-cases are for the various closure events. For example, one
question is: is the synchronous shutdown (WRITE) specified in the BSD
socket API blocking until we get the ACK for the FIN we send ? If this
is so, then, we need the callback for that FIN to be able to unblock the
caller of a synchronous API built on top of this async API. As for the
other kind of closure event (the FIN sent by the remote side), I have to
confess that I have a hard time figuring out what I would use it for.

Mathieu

On Thu, 2008-03-20 at 18:06 -0400, Raj Bhattacharjea wrote:
> The callback API for Socket objects is kind of strange.  In
> particular, there is a "halfClose" callback and a "closeRequested"
> callback.  Its clear from the Doxygen that it wasn't very well
> understood when to invoke these callbacks...that is because only one
> of them is required, the closeRequested callback, and it is invoked
> precisely when in a connection, your peer requests a close (i.e. for
> TCP when a FIN arrives on either end of the connection).
> 
> I propose the following patch as a fix:
> http://code.nsnam.org/raj/ns-3-dev/rev/ee0139477951
> 
> It removes the notion of the halfClose and replaces it entirely with
> closeRequested.  It also separates the setter for this callback into a
> method Socket::SetCloseRequestCallback, instead of lumping it with the
> Socket::SetAcceptCallback.  It also makes the appropriate changes to
> code which uses the Socket callback APIs, namely the PacketSink
> application and TCP example scripts.
> 



More information about the Ns-developers mailing list