[Ns-bugs] [Bug 244] PacketSink is not multitasking

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Wed Jul 2 21:13:02 PDT 2008


http://www.nsnam.org/bugzilla/show_bug.cgi?id=244





------- Comment #4 from tomh at tomh.org  2008-07-03 00:13 -------
(From update of attachment 191)
># HG changeset patch
># User Raj Bhattacharjea <raj.b at gatech.edu>
># Date 1214951154 14400
># Node ID e1313fb961eb2026771dab041cf02ee4ffe047fc
># Parent  8e6ac6061680a9454d81b65e34be0a7279690bb9
>Multitasking PacketSink
>
>diff -r 8e6ac6061680 -r e1313fb961eb examples/tcp-large-transfer.cc
>--- a/examples/tcp-large-transfer.cc	Tue Jul 01 11:00:29 2008 -0700
>+++ b/examples/tcp-large-transfer.cc	Tue Jul 01 18:25:54 2008 -0400
>@@ -132,6 +132,7 @@ int main (int argc, char *argv[])
> 
>   ApplicationContainer apps = sink.Install (n1n2.Get (1));
>   apps.Start (Seconds (0.0));
>+  apps.Stop (Seconds (60.0));

Can you please create an example where more than one flow terminates on the
same packet sink, and verify that all sockets (including the listening) are
closed?

> 
>   // Create a source to send packets from n0.  Instead of a full Application
>   // and the helper APIs you might see in other example files, this example
>diff -r 8e6ac6061680 -r e1313fb961eb src/applications/packet-sink/packet-sink.cc
>--- a/src/applications/packet-sink/packet-sink.cc	Tue Jul 01 11:00:29 2008 -0700
>+++ b/src/applications/packet-sink/packet-sink.cc	Tue Jul 01 18:25:54 2008 -0400
>@@ -88,11 +88,17 @@ void PacketSink::StartApplication()    /
>   m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this));
>   m_socket->SetAcceptCallback (
>             MakeNullCallback<bool, Ptr<Socket>, const Address &> (),
>-            MakeNullCallback<void, Ptr<Socket>, const Address&> ());
>+            MakeCallback(&PacketSink::HandleAccept, this));
> }
> 
> void PacketSink::StopApplication()     // Called at time specified by Stop
> {
>+  while(!m_socketList.empty()) //these are accepted sockets, close them
>+  {
>+    Ptr<Socket> acceptedSocket = m_socketList.front();
>+    m_socketList.pop_front();
>+    acceptedSocket->Close();
>+  }
>   if (m_socket) 
>     {

     Merge the fix for 243 here that closes m_socket

>       m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
>@@ -116,4 +122,9 @@ void PacketSink::HandleRead (Ptr<Socket>
>     }
> }
> 
>+void PacketSink::HandleAccept (Ptr<Socket> s, const Address& from)
>+{
>+  m_socketList.push_back(s);
>+}
>+
> } // Namespace ns3
>diff -r 8e6ac6061680 -r e1313fb961eb src/applications/packet-sink/packet-sink.h
>--- a/src/applications/packet-sink/packet-sink.h	Tue Jul 01 11:00:29 2008 -0700
>+++ b/src/applications/packet-sink/packet-sink.h	Tue Jul 01 18:25:54 2008 -0400
>@@ -81,8 +81,10 @@ private:
>   virtual void StopApplication (void);     // Called at time specified by Stop
> 
>   void HandleRead (Ptr<Socket> socket);
>+  void HandleAccept (Ptr<Socket>, const Address& from);
> 
>   Ptr<Socket>     m_socket;       // Associated socket

Maybe change this comment to // Listening socket

It needs to be a bit more clear that the m_socket is not stored in the
m_socketList.

>+  std::list<Ptr<Socket> > m_socketList; //the accepted sockets
>   Address         m_local;        // Local address to bind to
>   TypeId          m_tid;          // Protocol TypeId
>   TracedCallback<Ptr<const Packet>, const Address &> m_rxTrace;


-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Ns-bugs mailing list