[Ns-bugs] [Bug 426] TCP: close does not send RST
code@nsnam.ece.gatech.edu
code at nsnam.ece.gatech.edu
Mon Mar 30 07:06:43 PDT 2009
http://www.nsnam.org/bugzilla/show_bug.cgi?id=426
--- Comment #6 from Tom Henderson <tomh at tomh.org> 2009-03-30 10:06:43 EDT ---
(From update of attachment 407)
>diff -r 80601ddf444a examples/tcp-large-transfer.cc
>--- a/examples/tcp-large-transfer.cc Mon Mar 23 00:06:28 2009 -0400
>+++ b/examples/tcp-large-transfer.cc Mon Mar 30 01:49:51 2009 -0400
>@@ -212,5 +212,5 @@
> return;
> }
> }
>- localSocket->Close ();
>+ localSocket->ShutdownSend ();
> }
I would not necessarily change the above; Close() is still valid here. The
program otherwise doesn't call Close() or ShutdownRecv() so it seems
insufficient to just make the above change.
>diff -r 80601ddf444a src/internet-stack/tcp-socket-impl.cc
>--- a/src/internet-stack/tcp-socket-impl.cc Mon Mar 23 00:06:28 2009 -0400
>+++ b/src/internet-stack/tcp-socket-impl.cc Mon Mar 30 01:49:51 2009 -0400
>@@ -73,6 +73,7 @@
> m_closeRequestNotified (false),
> m_closeOnEmpty (false),
> m_pendingClose (false),
>+ m_closeCalled (false),
> m_nextTxSequence (0),
> m_highTxMark (0),
> m_highestRxAck (0),
>@@ -112,6 +113,7 @@
> m_closeRequestNotified (sock.m_closeRequestNotified),
> m_closeOnEmpty (sock.m_closeOnEmpty),
> m_pendingClose (sock.m_pendingClose),
>+ m_closeCalled (sock.m_closeCalled),
> m_nextTxSequence (sock.m_nextTxSequence),
> m_highTxMark (sock.m_highTxMark),
> m_highestRxAck (sock.m_highestRxAck),
>@@ -294,6 +296,16 @@
> TcpSocketImpl::ShutdownSend (void)
> {
> NS_LOG_FUNCTION_NOARGS ();
>+ if (m_pendingData && m_pendingData->Size() != 0)
>+ { // App close with pending data must wait until all data transmitted
>+ m_closeOnEmpty = true;
>+ NS_LOG_LOGIC("Socket " << this <<
>+ " deferring close, state " << m_state);
>+ return 0;
>+ }
>+
>+ Actions_t action = ProcessEvent (APP_CLOSE);
>+ ProcessAction (action);
> m_shutdownSend = true;
> return 0;
> }
>@@ -308,18 +320,15 @@
> int
> TcpSocketImpl::Close (void)
> {
>- NS_LOG_FUNCTION_NOARGS ();
do not delete the log statement
>- if (m_pendingData && m_pendingData->Size() != 0)
>- { // App close with pending data must wait until all data transmitted
>- m_closeOnEmpty = true;
>- NS_LOG_LOGIC("Socket " << this <<
>- " deferring close, state " << m_state);
>- return 0;
>- }
>-
>- Actions_t action = ProcessEvent (APP_CLOSE);
>- ProcessAction (action);
>- ShutdownSend ();
>+ if (GetRxAvailable () > 0)
>+ {
>+ ProcessAction (RST_TX);
>+ }
>+ else
>+ {
>+ ShutdownSend();
>+ }
>+ m_closeCalled = true;
doesn't ShutdownRecv() need to be called also? (and fix ShutdownRecv() as you
previously mentioned)
I am not sure the code will honor shutdownRecv; it seems that RecvFrom ignores
this. After close(), you should not be able to read from the socket.
> return 0;
> }
>
>@@ -1125,6 +1134,11 @@
> " seq " << tcpHeader.GetSequenceNumber() <<
> " ack " << tcpHeader.GetAckNumber() <<
> " p.size is " << p->GetSize());
>+ if(m_closeCalled) //send RST accordingly
>+ {
>+ ProcessAction(RST_TX);
>+ return;
>+ }
Do you send RST for each NewRx? I don't know if these are rate limited in any
way.
> States_t origState = m_state;
> if (RxBufferFreeSpace() < p->GetSize())
> { //if not enough room, fragment
>diff -r 80601ddf444a src/internet-stack/tcp-socket-impl.h
>--- a/src/internet-stack/tcp-socket-impl.h Mon Mar 23 00:06:28 2009 -0400
>+++ b/src/internet-stack/tcp-socket-impl.h Mon Mar 30 01:49:51 2009 -0400
>@@ -191,6 +191,7 @@
> bool m_closeRequestNotified;
> bool m_closeOnEmpty;
> bool m_pendingClose;
>+ bool m_closeCalled;
>
>
> //sequence info, sender side
--
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the Ns-bugs
mailing list