1.1 --- a/src/internet-stack/arp-l3-protocol.h Tue Aug 25 08:41:04 2009 +0200
1.2 +++ b/src/internet-stack/arp-l3-protocol.h Tue Aug 25 08:52:57 2009 +0200
1.3 @@ -26,14 +26,13 @@
1.4 #include "ns3/ptr.h"
1.5 #include "ns3/traced-callback.h"
1.6
1.7 -#include "ipv4-interface.h"
1.8 -
1.9 namespace ns3 {
1.10
1.11 class ArpCache;
1.12 class NetDevice;
1.13 class Node;
1.14 class Packet;
1.15 +class Ipv4Interface;
1.16
1.17 /**
1.18 * \ingroup internetStack
2.1 --- a/src/internet-stack/nsc-tcp-l4-protocol.cc Tue Aug 25 08:41:04 2009 +0200
2.2 +++ b/src/internet-stack/nsc-tcp-l4-protocol.cc Tue Aug 25 08:52:57 2009 +0200
2.3 @@ -32,8 +32,10 @@
2.4 #include "ipv4-end-point.h"
2.5 #include "ipv4-l3-protocol.h"
2.6 #include "nsc-tcp-l4-protocol.h"
2.7 +#include "nsc-tcp-socket-impl.h"
2.8 #include "nsc-sysctl.h"
2.9 #include "nsc-tcp-socket-factory-impl.h"
2.10 +#include "sim_interface.h"
2.11
2.12 #include "tcp-typedefs.h"
2.13
2.14 @@ -54,13 +56,39 @@
2.15 /* see http://www.iana.org/assignments/protocol-numbers */
2.16 const uint8_t NscTcpL4Protocol::PROT_NUMBER = 6;
2.17
2.18 -ObjectFactory
2.19 -NscTcpL4Protocol::GetDefaultRttEstimatorFactory (void)
2.20 +class NscInterfaceImpl : public ISendCallback, public IInterruptCallback
2.21 {
2.22 - ObjectFactory factory;
2.23 - factory.SetTypeId (RttMeanDeviation::GetTypeId ());
2.24 - return factory;
2.25 +public:
2.26 + NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot);
2.27 +private:
2.28 + virtual void send_callback(const void *data, int datalen);
2.29 + virtual void wakeup();
2.30 + virtual void gettime(unsigned int *, unsigned int *);
2.31 +private:
2.32 + Ptr<NscTcpL4Protocol> m_prot;
2.33 +};
2.34 +
2.35 +NscInterfaceImpl::NscInterfaceImpl (Ptr<NscTcpL4Protocol> prot)
2.36 + : m_prot (prot)
2.37 +{}
2.38 +
2.39 +void
2.40 +NscInterfaceImpl::send_callback(const void *data, int datalen)
2.41 +{
2.42 + m_prot->send_callback (data, datalen);
2.43 }
2.44 +void
2.45 +NscInterfaceImpl::wakeup()
2.46 +{
2.47 + m_prot->wakeup ();
2.48 +}
2.49 +void
2.50 +NscInterfaceImpl::gettime(unsigned int *sec, unsigned int *usec)
2.51 +{
2.52 + m_prot->gettime (sec,usec);
2.53 +}
2.54 +
2.55 +
2.56
2.57 TypeId
2.58 NscTcpL4Protocol::GetTypeId (void)
2.59 @@ -68,11 +96,6 @@
2.60 static TypeId tid = TypeId ("ns3::NscTcpL4Protocol")
2.61 .SetParent<Ipv4L4Protocol> ()
2.62 .AddConstructor<NscTcpL4Protocol>()
2.63 - .AddAttribute ("RttEstimatorFactory",
2.64 - "How RttEstimator objects are created.",
2.65 - ObjectFactoryValue (GetDefaultRttEstimatorFactory ()),
2.66 - MakeObjectFactoryAccessor (&NscTcpL4Protocol::m_rttFactory),
2.67 - MakeObjectFactoryChecker ())
2.68 .AddAttribute ("SocketList", "The list of sockets associated to this protocol.",
2.69 ObjectVectorValue (),
2.70 MakeObjectVectorAccessor (&NscTcpL4Protocol::m_sockets),
2.71 @@ -95,6 +118,7 @@
2.72 NscTcpL4Protocol::NscTcpL4Protocol ()
2.73 : m_endPoints (new Ipv4EndPointDemux ()),
2.74 m_nscStack (0),
2.75 + m_nscInterface (new NscInterfaceImpl (this)),
2.76 m_softTimer (Timer::CANCEL_ON_DESTROY)
2.77 {
2.78 m_dlopenHandle = NULL;
2.79 @@ -139,7 +163,7 @@
2.80
2.81 FCreateStack create = (FCreateStack)dlsym(m_dlopenHandle, "nsc_create_stack");
2.82 NS_ASSERT(create);
2.83 - m_nscStack = create(this, this, external_rand);
2.84 + m_nscStack = create(m_nscInterface, m_nscInterface, external_rand);
2.85 int hzval = m_nscStack->get_hz();
2.86
2.87 NS_ASSERT(hzval > 0);
2.88 @@ -212,6 +236,8 @@
2.89 m_endPoints = 0;
2.90 }
2.91 m_node = 0;
2.92 + delete m_nscInterface;
2.93 + m_nscInterface = 0;
2.94 Ipv4L4Protocol::DoDispose ();
2.95 }
2.96
2.97 @@ -220,11 +246,9 @@
2.98 {
2.99 NS_LOG_FUNCTION (this);
2.100
2.101 - Ptr<RttEstimator> rtt = m_rttFactory.Create<RttEstimator> ();
2.102 Ptr<NscTcpSocketImpl> socket = CreateObject<NscTcpSocketImpl> ();
2.103 socket->SetNode (m_node);
2.104 socket->SetTcp (this);
2.105 - socket->SetRtt (rtt);
2.106 m_sockets.push_back (socket);
2.107 return socket;
2.108 }
3.1 --- a/src/internet-stack/nsc-tcp-l4-protocol.h Tue Aug 25 08:41:04 2009 +0200
3.2 +++ b/src/internet-stack/nsc-tcp-l4-protocol.h Tue Aug 25 08:52:57 2009 +0200
3.3 @@ -23,27 +23,27 @@
3.4 #include "ns3/ipv4-address.h"
3.5 #include "ns3/ptr.h"
3.6 #include "ns3/object-factory.h"
3.7 -#include "ipv4-end-point-demux.h"
3.8 +#include "ns3/timer.h"
3.9 #include "ipv4-l4-protocol.h"
3.10 -#include "ipv4-interface.h"
3.11
3.12 -#include "tcp-header.h"
3.13 -
3.14 -#include "ns3/timer.h"
3.15 -#include "sim_interface.h"
3.16 -#include "nsc-tcp-socket-impl.h"
3.17 +struct INetStack;
3.18
3.19 namespace ns3 {
3.20
3.21 class Node;
3.22 class Socket;
3.23 -class TcpHeader;
3.24 +class Ipv4EndPointDemux;
3.25 +class Ipv4Interface;
3.26 +class NscTcpSocketImpl;
3.27 +class Ipv4EndPoint;
3.28 +class NscInterfaceImpl;
3.29 +
3.30 /**
3.31 * \ingroup nsctcp
3.32 *
3.33 * \brief Nsc wrapper glue, to interface with the Ipv4 protocol underneath.
3.34 */
3.35 -class NscTcpL4Protocol : public Ipv4L4Protocol, ISendCallback, IInterruptCallback {
3.36 +class NscTcpL4Protocol : public Ipv4L4Protocol {
3.37 public:
3.38 static const uint8_t PROT_NUMBER;
3.39 static TypeId GetTypeId (void);
3.40 @@ -86,6 +86,10 @@
3.41 Ipv4Address const &destination,
3.42 Ptr<Ipv4Interface> incomingInterface);
3.43
3.44 +protected:
3.45 + virtual void DoDispose (void);
3.46 + virtual void NotifyNewAggregate ();
3.47 +private:
3.48 // NSC callbacks.
3.49 // NSC invokes these hooks to interact with the simulator.
3.50 // In any case, these methods are only to be called by NSC.
3.51 @@ -93,29 +97,23 @@
3.52 // send_callback is invoked by NSCs 'ethernet driver' to re-inject
3.53 // a packet (i.e. an octet soup consisting of an IP Header, TCP Header
3.54 // and user payload, if any), into ns-3.
3.55 - virtual void send_callback(const void *data, int datalen);
3.56 + void send_callback(const void *data, int datalen);
3.57 // This is called by the NSC stack whenever something of interest
3.58 // has happened, e.g. when data arrives on a socket, a listen socket
3.59 // has a new connection pending, etc.
3.60 - virtual void wakeup();
3.61 + void wakeup();
3.62 // This is called by the Linux stack RNG initialization.
3.63 // Its also used by the cradle code to add a timestamp to
3.64 // printk/printf/debug output.
3.65 - virtual void gettime(unsigned int *, unsigned int *);
3.66 -
3.67 -protected:
3.68 - virtual void DoDispose (void);
3.69 - virtual void NotifyNewAggregate ();
3.70 -private:
3.71 + void gettime(unsigned int *sec, unsigned int *usec);
3.72 + void AddInterface (void);
3.73 + void SoftInterrupt (void);
3.74 + friend class NscInterfaceImpl;
3.75 + friend class NscTcpSocketImpl;
3.76 Ptr<Node> m_node;
3.77 Ipv4EndPointDemux *m_endPoints;
3.78 - ObjectFactory m_rttFactory;
3.79 -private:
3.80 - void AddInterface (void);
3.81 - void SoftInterrupt (void);
3.82 - static ObjectFactory GetDefaultRttEstimatorFactory (void);
3.83 - friend class NscTcpSocketImpl;
3.84 INetStack* m_nscStack;
3.85 + NscInterfaceImpl *m_nscInterface;
3.86 void *m_dlopenHandle;
3.87 std::string m_nscLibrary;
3.88 Timer m_softTimer;
4.1 --- a/src/internet-stack/nsc-tcp-socket-impl.cc Tue Aug 25 08:41:04 2009 +0200
4.2 +++ b/src/internet-stack/nsc-tcp-socket-impl.cc Tue Aug 25 08:52:57 2009 +0200
4.3 @@ -74,7 +74,6 @@
4.4 m_state (CLOSED),
4.5 m_closeOnEmpty (false),
4.6 m_txBufferSize (0),
4.7 - m_rtt (0),
4.8 m_lastMeasuredRtt (Seconds(0.0))
4.9 {
4.10 NS_LOG_FUNCTION (this);
4.11 @@ -104,7 +103,6 @@
4.12 m_cWnd (sock.m_cWnd),
4.13 m_ssThresh (sock.m_ssThresh),
4.14 m_initialCWnd (sock.m_initialCWnd),
4.15 - m_rtt (0),
4.16 m_lastMeasuredRtt (Seconds(0.0)),
4.17 m_cnTimeout (sock.m_cnTimeout),
4.18 m_cnCount (sock.m_cnCount),
4.19 @@ -119,11 +117,6 @@
4.20 {
4.21 m_txBuffer = sock.m_txBuffer;
4.22 }
4.23 - //copy the rtt if necessary
4.24 - if (sock.m_rtt)
4.25 - {
4.26 - m_rtt = sock.m_rtt->Copy();
4.27 - }
4.28 //can't "copy" the endpoint just yes, must do this when we know the peer info
4.29 //too; this is in SYN_ACK_TX
4.30 }
4.31 @@ -165,11 +158,6 @@
4.32 m_nscTcpSocket = tcp->m_nscStack->new_tcp_socket();
4.33 m_tcp = tcp;
4.34 }
4.35 -void
4.36 -NscTcpSocketImpl::SetRtt (Ptr<RttEstimator> rtt)
4.37 -{
4.38 - m_rtt = rtt;
4.39 -}
4.40
4.41
4.42 enum Socket::SocketErrno
5.1 --- a/src/internet-stack/nsc-tcp-socket-impl.h Tue Aug 25 08:41:04 2009 +0200
5.2 +++ b/src/internet-stack/nsc-tcp-socket-impl.h Tue Aug 25 08:52:57 2009 +0200
5.3 @@ -30,7 +30,8 @@
5.4 #include "tcp-typedefs.h"
5.5 #include "pending-data.h"
5.6 #include "sequence-number.h"
5.7 -#include "rtt-estimator.h"
5.8 +
5.9 +struct INetStreamSocket;
5.10
5.11 namespace ns3 {
5.12
5.13 @@ -63,7 +64,6 @@
5.14
5.15 void SetNode (Ptr<Node> node);
5.16 void SetTcp (Ptr<NscTcpL4Protocol> tcp);
5.17 - void SetRtt (Ptr<RttEstimator> rtt);
5.18
5.19 virtual enum SocketErrno GetErrno (void) const;
5.20 virtual Ptr<Node> GetNode (void) const;
5.21 @@ -158,7 +158,6 @@
5.22 uint32_t m_initialCWnd; //Initial cWnd value
5.23
5.24 // Round trip time estimation
5.25 - Ptr<RttEstimator> m_rtt;
5.26 Time m_lastMeasuredRtt;
5.27
5.28 // Timer-related members
6.1 --- a/src/internet-stack/tcp-l4-protocol.cc Tue Aug 25 08:41:04 2009 +0200
6.2 +++ b/src/internet-stack/tcp-l4-protocol.cc Tue Aug 25 08:52:57 2009 +0200
6.3 @@ -34,7 +34,8 @@
6.4 #include "ipv4-end-point.h"
6.5 #include "ipv4-l3-protocol.h"
6.6 #include "tcp-socket-factory-impl.h"
6.7 -
6.8 +#include "tcp-socket-impl.h"
6.9 +#include "rtt-estimator.h"
6.10 #include "tcp-typedefs.h"
6.11
6.12 #include <vector>
6.13 @@ -558,17 +559,18 @@
6.14 }
6.15
6.16 void
6.17 -TcpL4Protocol::SendPacket (Ptr<Packet> packet, TcpHeader outgoingHeader,
6.18 +TcpL4Protocol::SendPacket (Ptr<Packet> packet, const TcpHeader &outgoing,
6.19 Ipv4Address saddr, Ipv4Address daddr)
6.20 {
6.21 NS_LOG_LOGIC("TcpL4Protocol " << this
6.22 - << " sending seq " << outgoingHeader.GetSequenceNumber()
6.23 - << " ack " << outgoingHeader.GetAckNumber()
6.24 - << " flags " << std::hex << (int)outgoingHeader.GetFlags() << std::dec
6.25 + << " sending seq " << outgoing.GetSequenceNumber()
6.26 + << " ack " << outgoing.GetAckNumber()
6.27 + << " flags " << std::hex << (int)outgoing.GetFlags() << std::dec
6.28 << " data size " << packet->GetSize());
6.29 NS_LOG_FUNCTION (this << packet << saddr << daddr);
6.30 // XXX outgoingHeader cannot be logged
6.31
6.32 + TcpHeader outgoingHeader = outgoing;
6.33 outgoingHeader.SetLength (5); //header length in units of 32bit words
6.34 /* outgoingHeader.SetUrgentPointer (0); //XXX */
6.35 if(Node::ChecksumEnabled ())
7.1 --- a/src/internet-stack/tcp-l4-protocol.h Tue Aug 25 08:41:04 2009 +0200
7.2 +++ b/src/internet-stack/tcp-l4-protocol.h Tue Aug 25 08:52:57 2009 +0200
7.3 @@ -27,19 +27,17 @@
7.4 #include "ns3/ipv4-address.h"
7.5 #include "ns3/ptr.h"
7.6 #include "ns3/object-factory.h"
7.7 -#include "ipv4-end-point-demux.h"
7.8 #include "ipv4-l4-protocol.h"
7.9 -#include "ipv4-interface.h"
7.10 -
7.11 -#include "tcp-socket-impl.h"
7.12 -#include "tcp-header.h"
7.13 -#include "tcp-typedefs.h"
7.14
7.15 namespace ns3 {
7.16
7.17 class Node;
7.18 class Socket;
7.19 class TcpHeader;
7.20 +class Ipv4EndPointDemux;
7.21 +class Ipv4Interface;
7.22 +class TcpSocketImpl;
7.23 +class Ipv4EndPoint;
7.24
7.25 /**
7.26 * \ingroup tcp
7.27 @@ -120,7 +118,7 @@
7.28 ObjectFactory m_rttFactory;
7.29 private:
7.30 friend class TcpSocketImpl;
7.31 - void SendPacket (Ptr<Packet>, TcpHeader,
7.32 + void SendPacket (Ptr<Packet>, const TcpHeader &,
7.33 Ipv4Address, Ipv4Address);
7.34 static ObjectFactory GetDefaultRttEstimatorFactory (void);
7.35
8.1 --- a/src/internet-stack/tcp-socket-impl.cc Tue Aug 25 08:41:04 2009 +0200
8.2 +++ b/src/internet-stack/tcp-socket-impl.cc Tue Aug 25 08:52:57 2009 +0200
8.3 @@ -36,6 +36,8 @@
8.4 #include "tcp-socket-impl.h"
8.5 #include "tcp-l4-protocol.h"
8.6 #include "ipv4-end-point.h"
8.7 +#include "tcp-header.h"
8.8 +#include "rtt-estimator.h"
8.9
8.10 #include <algorithm>
8.11
9.1 --- a/src/internet-stack/tcp-test.cc Tue Aug 25 08:41:04 2009 +0200
9.2 +++ b/src/internet-stack/tcp-test.cc Tue Aug 25 08:52:57 2009 +0200
9.3 @@ -31,17 +31,18 @@
9.4 #include "ns3/simple-net-device.h"
9.5 #include "ns3/drop-tail-queue.h"
9.6 #include "ns3/config.h"
9.7 +#include "ns3/ipv4-static-routing.h"
9.8 +#include "ns3/ipv4-list-routing.h"
9.9 +#include "ns3/node.h"
9.10 +#include "ns3/inet-socket-address.h"
9.11 +#include "ns3/uinteger.h"
9.12 +
9.13 #include "ipv4-end-point.h"
9.14 #include "arp-l3-protocol.h"
9.15 #include "ipv4-l3-protocol.h"
9.16 #include "icmpv4-l4-protocol.h"
9.17 #include "udp-l4-protocol.h"
9.18 #include "tcp-l4-protocol.h"
9.19 -#include "ns3/ipv4-static-routing.h"
9.20 -#include "ns3/ipv4-list-routing.h"
9.21 -
9.22 -#include "ns3/node.h"
9.23 -#include "ns3/inet-socket-address.h"
9.24
9.25 #include <string>
9.26
10.1 --- a/src/internet-stack/udp-l4-protocol.h Tue Aug 25 08:41:04 2009 +0200
10.2 +++ b/src/internet-stack/udp-l4-protocol.h Tue Aug 25 08:52:57 2009 +0200
10.3 @@ -26,7 +26,6 @@
10.4 #include "ns3/packet.h"
10.5 #include "ns3/ipv4-address.h"
10.6 #include "ns3/ptr.h"
10.7 -#include "ipv4-end-point-demux.h"
10.8 #include "ipv4-l4-protocol.h"
10.9
10.10 namespace ns3 {
10.11 @@ -34,6 +33,8 @@
10.12 class Node;
10.13 class Socket;
10.14 class Ipv4Route;
10.15 +class Ipv4EndPointDemux;
10.16 +class Ipv4EndPoint;
10.17 /**
10.18 * \ingroup udp
10.19 * \brief Implementation of the UDP protocol
11.1 --- a/src/internet-stack/wscript Tue Aug 25 08:41:04 2009 +0200
11.2 +++ b/src/internet-stack/wscript Tue Aug 25 08:52:57 2009 +0200
11.3 @@ -121,11 +121,19 @@
11.4 'sequence-number.h',
11.5 'icmpv4.h',
11.6 'icmpv6-header.h',
11.7 - ]
11.8 + 'ipv4-l3-protocol.h',
11.9 + 'arp-l3-protocol.h',
11.10 + 'udp-l4-protocol.h',
11.11 + 'tcp-l4-protocol.h',
11.12 + 'icmpv4-l4-protocol.h',
11.13 + 'ipv4-l4-protocol.h',
11.14 + 'arp-cache.h',
11.15 + ]
11.16
11.17 if bld.env['NSC_ENABLED']:
11.18 obj.source.append ('nsc-tcp-socket-impl.cc')
11.19 obj.source.append ('nsc-tcp-l4-protocol.cc')
11.20 obj.source.append ('nsc-tcp-socket-factory-impl.cc')
11.21 obj.source.append ('nsc-sysctl.cc')
11.22 + headers.source.append('nsc-tcp-l4-protocol.h')
11.23 obj.uselib = 'DL'