--- a/examples/tcp-large-transfer.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/examples/tcp-large-transfer.cc Thu Mar 19 18:44:43 2009 -0700 @@ -57,9 +57,14 @@ void StartFlow(Ptr, Ipv4Address, void StartFlow(Ptr, Ipv4Address, uint16_t); void WriteUntilBufferFull (Ptr, uint32_t); +static void +CwndTracer (uint32_t oldval, uint32_t newval) +{ + NS_LOG_INFO ("Moving cwnd from " << oldval << " to " << newval); +} + int main (int argc, char *argv[]) { - // Users may find it convenient to turn on explicit debugging // for selected modules; the below lines suggest how to do this // LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL); @@ -67,9 +72,6 @@ int main (int argc, char *argv[]) // LogComponentEnable("PacketSink", LOG_LEVEL_ALL); // LogComponentEnable("TcpLargeTransfer", LOG_LEVEL_ALL); - - // Allow the user to override any of the defaults and the above - // Bind()s at run-time, via command-line arguments CommandLine cmd; cmd.Parse (argc, argv); @@ -140,6 +142,9 @@ int main (int argc, char *argv[]) Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ()); localSocket->Bind (); + // Trace changes to the congestion window + Config::ConnectWithoutContext ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", MakeCallback (&CwndTracer)); + // ...and schedule the sending "Application"; This is similar to what an // ns3::Application subclass would do internally. Simulator::ScheduleNow (&StartFlow, localSocket, --- a/examples/tcp-nsc-lfn.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/examples/tcp-nsc-lfn.cc Thu Mar 19 18:44:43 2009 -0700 @@ -43,6 +43,11 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("TcpNscLfn"); +static void +CwndTracer (uint32_t oldval, uint32_t newval) +{ + NS_LOG_INFO ("Moving cwnd from " << oldval << " to " << newval); +} int main (int argc, char *argv[]) { @@ -133,6 +138,10 @@ int main (int argc, char *argv[]) clientApp.Stop (Seconds (runtime + 1.0 + i)); } + // Trace changes to the congestion window + Config::ConnectWithoutContext ("/NodeList/1/$ns3::NscTcpL4Protocol/SocketList/0/CongestionWindow", + MakeCallback (&CwndTracer)); + // This tells ns-3 to generate pcap traces. PointToPointHelper::EnablePcapAll ("tcp-nsc-lfn"); --- a/src/internet-stack/internet-stack.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/internet-stack.cc Thu Mar 19 18:44:43 2009 -0700 @@ -54,6 +54,8 @@ AddUdpStack(Ptr node) Ptr udp = CreateObject (); udp->SetNode (node); ipv4->Insert (udp); + node->AggregateObject (udp); + Ptr udpFactory = CreateObject (); udpFactory->SetUdp (udp); node->AggregateObject (udpFactory); @@ -66,6 +68,8 @@ AddIcmpStack (Ptr node) Ptr icmp = CreateObject (); icmp->SetNode (node); ipv4->Insert (icmp); + node->AggregateObject (icmp); + Ptr rawFactory = CreateObject (); node->AggregateObject (rawFactory); } @@ -76,8 +80,8 @@ AddTcpStack(Ptr node) Ptr ipv4 = node->GetObject (); Ptr tcp = CreateObject (); tcp->SetNode (node); - ipv4->Insert (tcp); + node->AggregateObject (tcp); Ptr tcpFactory = CreateObject (); tcpFactory->SetTcp (tcp); @@ -114,6 +118,8 @@ AddNscStack(Ptr node, const std::s tcp->SetNscLibrary(soname); tcp->SetNode (node); ipv4->Insert (tcp); + node->AggregateObject (tcp); + Ptr tcpFactory = CreateObject (); tcpFactory->SetTcp (tcp); node->AggregateObject (tcpFactory); --- a/src/internet-stack/ipv4-l3-protocol.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/ipv4-l3-protocol.cc Thu Mar 19 18:44:43 2009 -0700 @@ -152,15 +152,13 @@ Ipv4L3Protocol::DoDispose (void) NS_LOG_FUNCTION (this); for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) { - (*i)->Dispose (); *i = 0; } m_protocols.clear (); - for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); ++i) + for (Ipv4InterfaceList::iterator i = m_interfaces.begin (); i != m_interfaces.end (); ++i) { - Ptr interface = *i; - interface->Dispose (); + *i = 0; } m_interfaces.clear (); m_node = 0; --- a/src/internet-stack/nsc-tcp-l4-protocol.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/nsc-tcp-l4-protocol.cc Thu Mar 19 18:44:43 2009 -0700 @@ -24,12 +24,13 @@ #include "ns3/packet.h" #include "ns3/node.h" +#include "ns3/object-vector.h" + #include "tcp-header.h" #include "ipv4-end-point-demux.h" #include "ipv4-end-point.h" #include "ipv4-l3-protocol.h" #include "nsc-tcp-l4-protocol.h" -#include "nsc-tcp-socket-impl.h" #include "nsc-sysctl.h" #include "tcp-typedefs.h" @@ -70,6 +71,10 @@ NscTcpL4Protocol::GetTypeId (void) ObjectFactoryValue (GetDefaultRttEstimatorFactory ()), MakeObjectFactoryAccessor (&NscTcpL4Protocol::m_rttFactory), MakeObjectFactoryChecker ()) + .AddAttribute ("SocketList", "The list of sockets associated to this protocol.", + ObjectVectorValue (), + MakeObjectVectorAccessor (&NscTcpL4Protocol::m_sockets), + MakeObjectVectorChecker ()) ; return tid; } @@ -154,6 +159,14 @@ NscTcpL4Protocol::DoDispose (void) NscTcpL4Protocol::DoDispose (void) { NS_LOG_FUNCTION (this); + + for (std::vector >::iterator i = m_sockets.begin (); i != m_sockets.end (); i++) + { + *i = 0; + } + m_sockets.clear (); + + if (m_endPoints != 0) { delete m_endPoints; @@ -173,6 +186,7 @@ NscTcpL4Protocol::CreateSocket (void) socket->SetNode (m_node); socket->SetTcp (this); socket->SetRtt (rtt); + m_sockets.push_back (socket); return socket; } --- a/src/internet-stack/nsc-tcp-l4-protocol.h Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/nsc-tcp-l4-protocol.h Thu Mar 19 18:44:43 2009 -0700 @@ -31,6 +31,7 @@ #include "ns3/timer.h" #include "sim_interface.h" +#include "nsc-tcp-socket-impl.h" namespace ns3 { @@ -116,6 +117,7 @@ private: INetStack* m_nscStack; void *m_dlopenHandle; Timer m_softTimer; + std::vector > m_sockets; }; }; // namespace ns3 --- a/src/internet-stack/nsc-tcp-socket-factory-impl.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/nsc-tcp-socket-factory-impl.cc Thu Mar 19 18:44:43 2009 -0700 @@ -13,8 +13,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "nsc-tcp-l4-protocol.h" #include "nsc-tcp-socket-factory-impl.h" -#include "nsc-tcp-l4-protocol.h" #include "ns3/socket.h" #include "ns3/assert.h" --- a/src/internet-stack/tcp-l4-protocol.cc Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/tcp-l4-protocol.cc Thu Mar 19 18:44:43 2009 -0700 @@ -22,6 +22,7 @@ #include "ns3/log.h" #include "ns3/nstime.h" #include "ns3/boolean.h" +#include "ns3/object-vector.h" #include "ns3/packet.h" #include "ns3/node.h" @@ -31,7 +32,6 @@ #include "ipv4-end-point-demux.h" #include "ipv4-end-point.h" #include "ipv4-l3-protocol.h" -#include "tcp-socket-impl.h" #include "tcp-typedefs.h" @@ -334,6 +334,10 @@ TcpL4Protocol::GetTypeId (void) BooleanValue (false), MakeBooleanAccessor (&TcpL4Protocol::m_calcChecksum), MakeBooleanChecker ()) + .AddAttribute ("SocketList", "The list of sockets associated to this protocol.", + ObjectVectorValue (), + MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets), + MakeObjectVectorChecker ()) ; return tid; } @@ -366,11 +370,18 @@ TcpL4Protocol::DoDispose (void) TcpL4Protocol::DoDispose (void) { NS_LOG_FUNCTION_NOARGS (); + for (std::vector >::iterator i = m_sockets.begin (); i != m_sockets.end (); i++) + { + *i = 0; + } + m_sockets.clear (); + if (m_endPoints != 0) { delete m_endPoints; m_endPoints = 0; } + m_node = 0; Ipv4L4Protocol::DoDispose (); } @@ -384,6 +395,7 @@ TcpL4Protocol::CreateSocket (void) socket->SetNode (m_node); socket->SetTcp (this); socket->SetRtt (rtt); + m_sockets.push_back (socket); return socket; } --- a/src/internet-stack/tcp-l4-protocol.h Thu Mar 19 11:33:19 2009 -0700 +++ a/src/internet-stack/tcp-l4-protocol.h Thu Mar 19 18:44:43 2009 -0700 @@ -31,6 +31,7 @@ #include "ipv4-l4-protocol.h" #include "ipv4-interface.h" +#include "tcp-socket-impl.h" #include "tcp-header.h" #include "tcp-typedefs.h" @@ -120,6 +121,7 @@ private: bool m_goodChecksum; bool m_calcChecksum; + std::vector > m_sockets; }; }; // namespace ns3