--- a/examples/tcp-large-transfer.cc Thu Mar 19 11:33:19 2009 -0700
+++ b/examples/tcp-large-transfer.cc Mon Mar 23 11:26:39 2009 -0700
@@ -57,9 +57,14 @@
void StartFlow(Ptr<Socket>, Ipv4Address, uint16_t);
void WriteUntilBufferFull (Ptr<Socket>, 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 @@
// 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 @@
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
+++ b/examples/tcp-nsc-lfn.cc Mon Mar 23 11:26:39 2009 -0700
@@ -43,6 +43,11 @@
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 @@
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/devices/point-to-point/point-to-point-net-device.cc Thu Mar 19 11:33:19 2009 -0700
+++ b/src/devices/point-to-point/point-to-point-net-device.cc Mon Mar 23 11:26:39 2009 -0700
@@ -167,6 +167,7 @@
PointToPointNetDevice::~PointToPointNetDevice ()
{
+ NS_LOG_FUNCTION_NOARGS ();
}
void
@@ -226,8 +227,8 @@
//
NS_ASSERT_MSG(m_txMachineState == READY, "Must be READY to transmit");
m_txMachineState = BUSY;
+ m_currentPkt = p;
m_phyTxBeginTrace (m_currentPkt);
- m_currentPkt = p;
Time txTime = Seconds (m_bps.CalculateTxTime(p->GetSize()));
Time txCompleteTime = txTime + m_tInterframeGap;
--- a/src/internet-stack/internet-stack.cc Thu Mar 19 11:33:19 2009 -0700
+++ b/src/internet-stack/internet-stack.cc Mon Mar 23 11:26:39 2009 -0700
@@ -54,6 +54,8 @@
Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();
udp->SetNode (node);
ipv4->Insert (udp);
+ node->AggregateObject (udp);
+
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
udpFactory->SetUdp (udp);
node->AggregateObject (udpFactory);
@@ -66,6 +68,8 @@
Ptr<Icmpv4L4Protocol> icmp = CreateObject<Icmpv4L4Protocol> ();
icmp->SetNode (node);
ipv4->Insert (icmp);
+ node->AggregateObject (icmp);
+
Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
node->AggregateObject (rawFactory);
}
@@ -76,8 +80,8 @@
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> ();
tcp->SetNode (node);
-
ipv4->Insert (tcp);
+ node->AggregateObject (tcp);
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
tcpFactory->SetTcp (tcp);
@@ -114,6 +118,8 @@
tcp->SetNscLibrary(soname);
tcp->SetNode (node);
ipv4->Insert (tcp);
+ node->AggregateObject (tcp);
+
Ptr<NscTcpSocketFactoryImpl> tcpFactory = CreateObject<NscTcpSocketFactoryImpl> ();
tcpFactory->SetTcp (tcp);
node->AggregateObject (tcpFactory);
--- a/src/internet-stack/ipv4-l3-protocol.cc Thu Mar 19 11:33:19 2009 -0700
+++ b/src/internet-stack/ipv4-l3-protocol.cc Mon Mar 23 11:26:39 2009 -0700
@@ -152,15 +152,13 @@
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<Ipv4Interface> 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
+++ b/src/internet-stack/nsc-tcp-l4-protocol.cc Mon Mar 23 11:26:39 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 @@
ObjectFactoryValue (GetDefaultRttEstimatorFactory ()),
MakeObjectFactoryAccessor (&NscTcpL4Protocol::m_rttFactory),
MakeObjectFactoryChecker ())
+ .AddAttribute ("SocketList", "The list of sockets associated to this protocol.",
+ ObjectVectorValue (),
+ MakeObjectVectorAccessor (&NscTcpL4Protocol::m_sockets),
+ MakeObjectVectorChecker<NscTcpSocketImpl> ())
;
return tid;
}
@@ -154,6 +159,14 @@
NscTcpL4Protocol::DoDispose (void)
{
NS_LOG_FUNCTION (this);
+
+ for (std::vector<Ptr<NscTcpSocketImpl> >::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 @@
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
+++ b/src/internet-stack/nsc-tcp-l4-protocol.h Mon Mar 23 11:26:39 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 @@
INetStack* m_nscStack;
void *m_dlopenHandle;
Timer m_softTimer;
+ std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
};
}; // namespace ns3
--- a/src/internet-stack/nsc-tcp-socket-factory-impl.cc Thu Mar 19 11:33:19 2009 -0700
+++ b/src/internet-stack/nsc-tcp-socket-factory-impl.cc Mon Mar 23 11:26:39 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
+++ b/src/internet-stack/tcp-l4-protocol.cc Mon Mar 23 11:26:39 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 @@
BooleanValue (false),
MakeBooleanAccessor (&TcpL4Protocol::m_calcChecksum),
MakeBooleanChecker ())
+ .AddAttribute ("SocketList", "The list of sockets associated to this protocol.",
+ ObjectVectorValue (),
+ MakeObjectVectorAccessor (&TcpL4Protocol::m_sockets),
+ MakeObjectVectorChecker<TcpSocketImpl> ())
;
return tid;
}
@@ -366,11 +370,18 @@
TcpL4Protocol::DoDispose (void)
{
NS_LOG_FUNCTION_NOARGS ();
+ for (std::vector<Ptr<TcpSocketImpl> >::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 @@
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
+++ b/src/internet-stack/tcp-l4-protocol.h Mon Mar 23 11:26:39 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 @@
bool m_goodChecksum;
bool m_calcChecksum;
+ std::vector<Ptr<TcpSocketImpl> > m_sockets;
};
}; // namespace ns3