Merge with tomh/ns-3-dev-socket
This commit is contained in:
@@ -143,15 +143,15 @@ int main (int argc, char *argv[])
|
||||
uint16_t servPort = 50000;
|
||||
|
||||
// Create a packet sink to receive these packets
|
||||
PacketSinkHelper sink ("ns3::Tcp",
|
||||
PacketSinkHelper sink ("ns3::TcpSocketFactory",
|
||||
InetSocketAddress (Ipv4Address::GetAny (), servPort));
|
||||
|
||||
ApplicationContainer apps = sink.Install (c1.Get (1));
|
||||
apps.Start (Seconds (0.0));
|
||||
|
||||
// and generate traffic to remote sink.
|
||||
//TypeId tid = TypeId::LookupByName ("ns3::Tcp");
|
||||
Ptr<Socket> localSocket = Socket::CreateSocket (c0.Get (0), Tcp::GetTypeId ());
|
||||
//TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory");
|
||||
Ptr<Socket> localSocket = Socket::CreateSocket (c0.Get (0), TcpSocketFactory::GetTypeId ());
|
||||
localSocket->Bind ();
|
||||
Simulator::ScheduleNow (&StartFlow, localSocket, nBytes,
|
||||
ipInterfs.GetAddress (1), servPort);
|
||||
|
||||
@@ -47,7 +47,7 @@ PacketSinkHelper::SetUdpLocal (Ipv4Address ip, uint16_t port)
|
||||
void
|
||||
PacketSinkHelper::SetTcpLocal (Ipv4Address ip, uint16_t port)
|
||||
{
|
||||
m_factory.Set ("Protocol", String ("ns3::Tcp"));
|
||||
m_factory.Set ("Protocol", String ("ns3::TcpSocketFactory"));
|
||||
m_factory.Set ("Local", Address (InetSocketAddress (ip, port)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "ipv4-l3-protocol.h"
|
||||
#include "arp-l3-protocol.h"
|
||||
#include "udp-socket-factory-impl.h"
|
||||
#include "tcp-impl.h"
|
||||
#include "tcp-socket-factory-impl.h"
|
||||
#include "ipv4-impl.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -59,18 +59,18 @@ AddInternetStack (Ptr<Node> node)
|
||||
ipv4L4Demux->Insert (tcp);
|
||||
|
||||
Ptr<UdpSocketFactoryImpl> udpFactory = CreateObject<UdpSocketFactoryImpl> ();
|
||||
Ptr<TcpImpl> tcpImpl = CreateObject<TcpImpl> ();
|
||||
Ptr<TcpSocketFactoryImpl> tcpFactory = CreateObject<TcpSocketFactoryImpl> ();
|
||||
Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> ();
|
||||
|
||||
udpFactory->SetUdp (udp);
|
||||
tcpImpl->SetTcp (tcp);
|
||||
tcpFactory->SetTcp (tcp);
|
||||
ipv4Impl->SetIpv4 (ipv4);
|
||||
|
||||
node->AggregateObject (ipv4);
|
||||
node->AggregateObject (arp);
|
||||
node->AggregateObject (ipv4Impl);
|
||||
node->AggregateObject (udpFactory);
|
||||
node->AggregateObject (tcpImpl);
|
||||
node->AggregateObject (tcpFactory);
|
||||
node->AggregateObject (ipv4L4Demux);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include "tcp-socket.h"
|
||||
#include "tcp-socket-impl.h"
|
||||
#include "tcp-header.h"
|
||||
#include "ns3/buffer.h"
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include <stdint.h>
|
||||
#include "ns3/header.h"
|
||||
#include "ns3/buffer.h"
|
||||
#include "ns3/tcp.h"
|
||||
#include "ns3/tcp-socket-factory.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/sequence-number.h"
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "ipv4-end-point-demux.h"
|
||||
#include "ipv4-end-point.h"
|
||||
#include "ipv4-l3-protocol.h"
|
||||
#include "tcp-socket.h"
|
||||
#include "tcp-socket-impl.h"
|
||||
|
||||
#include "tcp-typedefs.h"
|
||||
|
||||
@@ -379,7 +379,7 @@ TcpL4Protocol::CreateSocket (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<RttEstimator> rtt = m_rttFactory.Create<RttEstimator> ();
|
||||
Ptr<TcpSocket> socket = CreateObject<TcpSocket> ();
|
||||
Ptr<TcpSocketImpl> socket = CreateObject<TcpSocketImpl> ();
|
||||
socket->SetNode (m_node);
|
||||
socket->SetTcp (this);
|
||||
socket->SetRtt (rtt);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
virtual int GetVersion (void) const;
|
||||
|
||||
/**
|
||||
* \return A smart Socket pointer to a TcpSocket, allocated by this instance
|
||||
* \return A smart Socket pointer to a TcpSocketImpl, allocated by this instance
|
||||
* of the TCP protocol
|
||||
*/
|
||||
Ptr<Socket> CreateSocket (void);
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
void DeAllocate (Ipv4EndPoint *endPoint);
|
||||
|
||||
// // called by TcpSocket.
|
||||
// // called by TcpSocketImpl.
|
||||
// bool Connect (const Ipv4Address& saddr, const Ipv4Address& daddr,
|
||||
// uint16_t sport, uint16_t dport);
|
||||
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
Ipv4EndPointDemux *m_endPoints;
|
||||
ObjectFactory m_rttFactory;
|
||||
private:
|
||||
friend class TcpSocket;
|
||||
friend class TcpSocketImpl;
|
||||
void SendPacket (Ptr<Packet>, TcpHeader,
|
||||
Ipv4Address, Ipv4Address);
|
||||
static ObjectFactory GetDefaultRttEstimatorFactory (void);
|
||||
|
||||
@@ -17,38 +17,38 @@
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#include "tcp-impl.h"
|
||||
#include "tcp-socket-factory-impl.h"
|
||||
#include "tcp-l4-protocol.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
TcpImpl::TcpImpl ()
|
||||
TcpSocketFactoryImpl::TcpSocketFactoryImpl ()
|
||||
: m_tcp (0)
|
||||
{}
|
||||
TcpImpl::~TcpImpl ()
|
||||
TcpSocketFactoryImpl::~TcpSocketFactoryImpl ()
|
||||
{
|
||||
NS_ASSERT (m_tcp == 0);
|
||||
}
|
||||
|
||||
void
|
||||
TcpImpl::SetTcp (Ptr<TcpL4Protocol> tcp)
|
||||
TcpSocketFactoryImpl::SetTcp (Ptr<TcpL4Protocol> tcp)
|
||||
{
|
||||
m_tcp = tcp;
|
||||
}
|
||||
|
||||
Ptr<Socket>
|
||||
TcpImpl::CreateSocket (void)
|
||||
TcpSocketFactoryImpl::CreateSocket (void)
|
||||
{
|
||||
return m_tcp->CreateSocket ();
|
||||
}
|
||||
|
||||
void
|
||||
TcpImpl::DoDispose (void)
|
||||
TcpSocketFactoryImpl::DoDispose (void)
|
||||
{
|
||||
m_tcp = 0;
|
||||
Tcp::DoDispose ();
|
||||
TcpSocketFactory::DoDispose ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -17,10 +17,10 @@
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#ifndef TCP_IMPL_H
|
||||
#define TCP_IMPL_H
|
||||
#ifndef TCP_SOCKET_FACTORY_IMPL_H
|
||||
#define TCP_SOCKET_FACTORY_IMPL_H
|
||||
|
||||
#include "ns3/tcp.h"
|
||||
#include "ns3/tcp-socket-factory.h"
|
||||
#include "ns3/ptr.h"
|
||||
|
||||
namespace ns3 {
|
||||
@@ -37,13 +37,13 @@ class TcpL4Protocol;
|
||||
* <a href="http://www.ece.gatech.edu/research/labs/MANIACS/GTNetS/">
|
||||
* Georgia Tech Network Simulator (GTNetS)</a>.
|
||||
*
|
||||
* Most of the logic is in class ns3::TcpSocket.
|
||||
* Most of the logic is in class ns3::TcpSocketImpl.
|
||||
*/
|
||||
class TcpImpl : public Tcp
|
||||
class TcpSocketFactoryImpl : public TcpSocketFactory
|
||||
{
|
||||
public:
|
||||
TcpImpl ();
|
||||
virtual ~TcpImpl ();
|
||||
TcpSocketFactoryImpl ();
|
||||
virtual ~TcpSocketFactoryImpl ();
|
||||
|
||||
void SetTcp (Ptr<TcpL4Protocol> tcp);
|
||||
|
||||
@@ -57,4 +57,4 @@ private:
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* TCP_IMPL_H */
|
||||
#endif /* TCP_SOCKET_FACTORY_IMPL_H */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,14 +17,14 @@
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#ifndef TCP_SOCKET_H
|
||||
#define TCP_SOCKET_H
|
||||
#ifndef TCP_SOCKET_IMPL_H
|
||||
#define TCP_SOCKET_IMPL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <queue>
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/traced-value.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/tcp-socket.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/event-id.h"
|
||||
@@ -42,16 +42,16 @@ class Packet;
|
||||
class TcpL4Protocol;
|
||||
class TcpHeader;
|
||||
|
||||
class TcpSocket : public Socket
|
||||
class TcpSocketImpl : public TcpSocket
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
/**
|
||||
* Create an unbound tcp socket.
|
||||
*/
|
||||
TcpSocket ();
|
||||
TcpSocket (const TcpSocket& sock);
|
||||
virtual ~TcpSocket ();
|
||||
TcpSocketImpl ();
|
||||
TcpSocketImpl (const TcpSocketImpl& sock);
|
||||
virtual ~TcpSocketImpl ();
|
||||
|
||||
void SetNode (Ptr<Node> node);
|
||||
void SetTcp (Ptr<TcpL4Protocol> tcp);
|
||||
@@ -74,12 +74,6 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual uint32_t GetRxAvailable (void) const;
|
||||
|
||||
protected:
|
||||
virtual void SetSndBuf (uint32_t size);
|
||||
virtual uint32_t GetSndBuf (void) const;
|
||||
virtual void SetRcvBuf (uint32_t size);
|
||||
virtual uint32_t GetRcvBuf (void) const;
|
||||
|
||||
private:
|
||||
friend class Tcp;
|
||||
// invoked by Tcp class
|
||||
@@ -110,7 +104,7 @@ private:
|
||||
// Manage data tx/rx
|
||||
void NewRx (Ptr<Packet>, const TcpHeader&, const Address&);
|
||||
// XXX This should be virtual and overridden
|
||||
Ptr<TcpSocket> Copy ();
|
||||
Ptr<TcpSocketImpl> Copy ();
|
||||
void NewAck (SequenceNumber seq);
|
||||
// XXX This should be virtual and overridden
|
||||
void DupAck (const TcpHeader& t, uint32_t count);
|
||||
@@ -120,6 +114,28 @@ private:
|
||||
void Retransmit ();
|
||||
void CommonNewAck (SequenceNumber seq, bool skipTimer = false);
|
||||
|
||||
// attribute related
|
||||
virtual void SetSndBufSize (uint32_t size);
|
||||
virtual uint32_t GetSndBufSize (void) const;
|
||||
virtual void SetRcvBufSize (uint32_t size);
|
||||
virtual uint32_t GetRcvBufSize (void) const;
|
||||
virtual void SetSegSize (uint32_t size);
|
||||
virtual uint32_t GetSegSize (void) const;
|
||||
virtual void SetAdvWin (uint32_t window);
|
||||
virtual uint32_t GetAdvWin (void) const;
|
||||
virtual void SetSSThresh (uint32_t threshold);
|
||||
virtual uint32_t GetSSThresh (void) const;
|
||||
virtual void SetInitialCwnd (uint32_t cwnd);
|
||||
virtual uint32_t GetInitialCwnd (void) const;
|
||||
virtual void SetConnTimeout (Time timeout);
|
||||
virtual Time GetConnTimeout (void) const;
|
||||
virtual void SetConnCount (uint32_t count);
|
||||
virtual uint32_t GetConnCount (void) const;
|
||||
virtual void SetDelAckTimeout (Time timeout);
|
||||
virtual Time GetDelAckTimeout (void) const;
|
||||
virtual void SetDelAckMaxCount (uint32_t count);
|
||||
virtual uint32_t GetDelAckMaxCount (void) const;
|
||||
|
||||
bool m_skipRetxResched;
|
||||
uint32_t m_dupAckCount;
|
||||
EventId m_retxEvent;
|
||||
@@ -128,7 +144,7 @@ private:
|
||||
EventId m_delAckEvent;
|
||||
uint32_t m_delAckCount;
|
||||
uint32_t m_delAckMaxCount;
|
||||
Time m_delAckTimout;
|
||||
Time m_delAckTimeout;
|
||||
|
||||
Ipv4EndPoint *m_endPoint;
|
||||
Ptr<Node> m_node;
|
||||
@@ -187,11 +203,13 @@ private:
|
||||
std::queue<Ptr<Packet> > m_deliveryQueue;
|
||||
uint32_t m_rxAvailable;
|
||||
|
||||
uint32_t m_sndBufLimit; // buffer limit for the outgoing queue
|
||||
uint32_t m_rcvBufLimit; // maximum receive socket buffer size
|
||||
bool m_wouldBlock; // set to true whenever socket would block on send()
|
||||
|
||||
// Attributes
|
||||
uint32_t m_rcvBufSize; // maximum receive socket buffer size
|
||||
uint32_t m_sndBufSize; // buffer limit for the outgoing queue
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
#endif /* TCP_SOCKET_H */
|
||||
#endif /* TCP_SOCKET_IMPL_H */
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
|
||||
virtual uint32_t GetRxAvailable (void) const;
|
||||
|
||||
private:
|
||||
// Attributes set through UdpSocket base class
|
||||
virtual void SetRcvBufSize (uint32_t size);
|
||||
virtual uint32_t GetRcvBufSize (void) const;
|
||||
@@ -72,7 +73,6 @@ public:
|
||||
virtual void SetIpMulticastTtl (uint32_t ipTtl);
|
||||
virtual uint32_t GetIpMulticastTtl (void) const;
|
||||
|
||||
private:
|
||||
friend class UdpSocketFactory;
|
||||
// invoked by Udp class
|
||||
int FinishBind (void);
|
||||
|
||||
@@ -23,13 +23,13 @@ def build(bld):
|
||||
'arp-l3-protocol.cc',
|
||||
'ipv4-loopback-interface.cc',
|
||||
'udp-socket-impl.cc',
|
||||
'tcp-socket.cc',
|
||||
'tcp-socket-impl.cc',
|
||||
'ipv4-end-point-demux.cc',
|
||||
'ipv4-impl.cc',
|
||||
'ascii-trace.cc',
|
||||
'pcap-trace.cc',
|
||||
'udp-socket-factory-impl.cc',
|
||||
'tcp-impl.cc',
|
||||
'tcp-socket-factory-impl.cc',
|
||||
'pending-data.cc',
|
||||
'sequence-number.cc',
|
||||
'rtt-estimator.cc',
|
||||
|
||||
37
src/node/tcp-socket-factory.cc
Normal file
37
src/node/tcp-socket-factory.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 Georgia Tech Research Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#include "tcp-socket-factory.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TcpSocketFactory);
|
||||
|
||||
TypeId
|
||||
TcpSocketFactory::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::TcpSocketFactory")
|
||||
.SetParent<SocketFactory> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -17,8 +17,8 @@
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#ifndef TCP_H
|
||||
#define TCP_H
|
||||
#ifndef TCP_SOCKET_FACTORY_H
|
||||
#define TCP_SOCKET_FACTORY_H
|
||||
|
||||
#include "socket-factory.h"
|
||||
|
||||
@@ -34,44 +34,22 @@ class Socket;
|
||||
* initialize newly created sockets, such as values that are
|
||||
* set through the sysctl or proc interfaces in Linux.
|
||||
|
||||
* All TCP implementations must provide an implementation of CreateSocket
|
||||
* All TCP socket factory implementations must provide an implementation
|
||||
* of CreateSocket
|
||||
* below, and should make use of the default values configured below.
|
||||
*
|
||||
* \see TcpImpl
|
||||
* \see TcpSocketFactoryImpl
|
||||
*
|
||||
*/
|
||||
class Tcp : public SocketFactory
|
||||
class TcpSocketFactory : public SocketFactory
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
virtual Ptr<Socket> CreateSocket (void) = 0;
|
||||
|
||||
uint32_t GetDefaultSegSize (void) const;
|
||||
uint32_t GetDefaultAdvWin (void) const;
|
||||
uint32_t GetDefaultSsThresh (void) const;
|
||||
uint32_t GetDefaultTxBuffer (void) const;
|
||||
uint32_t GetDefaultRxBuffer (void) const;
|
||||
uint32_t GetDefaultInitialCwnd (void) const;
|
||||
uint32_t GetDefaultConnTimeout (void) const;
|
||||
uint32_t GetDefaultConnCount (void) const;
|
||||
double GetDefaultDelAckTimeout (void) const;
|
||||
uint32_t GetDefaultDelAckCount (void) const;
|
||||
|
||||
private:
|
||||
uint32_t m_defaultSegSize;
|
||||
uint32_t m_defaultAdvWin;
|
||||
uint32_t m_defaultSsThresh;
|
||||
uint32_t m_defaultTxBuffer;
|
||||
uint32_t m_defaultRxBuffer;
|
||||
uint32_t m_defaultInitialCwnd;
|
||||
uint32_t m_defaultConnTimeout;
|
||||
uint32_t m_defaultConnCount;
|
||||
double m_defaultDelAckTimeout;
|
||||
uint32_t m_defaultDelAckCount;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* TCP_H */
|
||||
#endif /* TCP_SOCKET_FACTORY_H */
|
||||
114
src/node/tcp-socket.cc
Normal file
114
src/node/tcp-socket.cc
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/double.h"
|
||||
#include "ns3/trace-source-accessor.h"
|
||||
#include "ns3/nstime.h"
|
||||
#include "tcp-socket.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("TcpSocket");
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (TcpSocket);
|
||||
|
||||
TypeId
|
||||
TcpSocket::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::TcpSocket")
|
||||
.SetParent<Socket> ()
|
||||
.AddAttribute ("SndBufSize",
|
||||
"TcpSocket maximum transmit buffer size (bytes)",
|
||||
UintegerValue (0xffffffffl),
|
||||
MakeUintegerAccessor (&TcpSocket::GetSndBufSize,
|
||||
&TcpSocket::SetSndBufSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("RcvBufSize",
|
||||
"TcpSocket maximum receive buffer size (bytes)",
|
||||
UintegerValue (0xffffffffl),
|
||||
MakeUintegerAccessor (&TcpSocket::GetRcvBufSize,
|
||||
&TcpSocket::SetRcvBufSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("SegmentSize",
|
||||
"TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
|
||||
UintegerValue (536),
|
||||
MakeUintegerAccessor (&TcpSocket::GetSegSize,
|
||||
&TcpSocket::SetSegSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("AdvertisedWindowSize",
|
||||
"TCP advertised window size (bytes)",
|
||||
UintegerValue (0xffff),
|
||||
MakeUintegerAccessor (&TcpSocket::GetAdvWin,
|
||||
&TcpSocket::SetAdvWin),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("SlowStartThreshold",
|
||||
"TCP slow start threshold (bytes)",
|
||||
UintegerValue (0xffff),
|
||||
MakeUintegerAccessor (&TcpSocket::GetSSThresh,
|
||||
&TcpSocket::SetSSThresh),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("InitialCwnd",
|
||||
"TCP initial congestion window size (segments)",
|
||||
UintegerValue (1),
|
||||
MakeUintegerAccessor (&TcpSocket::GetInitialCwnd,
|
||||
&TcpSocket::SetInitialCwnd),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("ConnTimeout",
|
||||
"TCP retransmission timeout when opening connection (seconds)",
|
||||
TimeValue (Seconds (3)),
|
||||
MakeTimeAccessor (&TcpSocket::GetConnTimeout,
|
||||
&TcpSocket::SetConnTimeout),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("ConnCount",
|
||||
"Number of connection attempts (SYN retransmissions) before returning failure",
|
||||
UintegerValue (6),
|
||||
MakeUintegerAccessor (&TcpSocket::GetConnCount,
|
||||
&TcpSocket::SetConnCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DelAckTimeout",
|
||||
"Timeout value for TCP delayed acks, in seconds",
|
||||
TimeValue (Seconds (0.2)),
|
||||
MakeTimeAccessor (&TcpSocket::GetDelAckTimeout,
|
||||
&TcpSocket::SetDelAckTimeout),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("DelAckCount",
|
||||
"Number of packets to wait before sending a TCP ack",
|
||||
UintegerValue (2),
|
||||
MakeUintegerAccessor (&TcpSocket::GetDelAckMaxCount,
|
||||
&TcpSocket::SetDelAckMaxCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
TcpSocket::TcpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
TcpSocket::~TcpSocket ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
94
src/node/tcp-socket.h
Normal file
94
src/node/tcp-socket.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 Georgia Tech Research Corporation
|
||||
* 2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Authors: George F. Riley<riley@ece.gatech.edu>
|
||||
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef __TCP_SOCKET_H__
|
||||
#define __TCP_SOCKET_H__
|
||||
|
||||
#include "socket.h"
|
||||
#include "ns3/traced-callback.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/nstime.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Node;
|
||||
class Packet;
|
||||
|
||||
/**
|
||||
* \brief (abstract) base class of all TcpSockets
|
||||
*
|
||||
* This class exists solely for hosting TcpSocket attributes that can
|
||||
* be reused across different implementations.
|
||||
*/
|
||||
class TcpSocket : public Socket
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
TcpSocket (void);
|
||||
virtual ~TcpSocket (void);
|
||||
|
||||
virtual enum Socket::SocketErrno GetErrno (void) const = 0;
|
||||
virtual Ptr<Node> GetNode (void) const = 0;
|
||||
virtual int Bind () = 0;
|
||||
virtual int Close (void) = 0;
|
||||
virtual int ShutdownSend (void) = 0;
|
||||
virtual int ShutdownRecv (void) = 0;
|
||||
virtual int Connect (const Address &address) = 0;
|
||||
virtual int Send (Ptr<Packet> p) = 0;
|
||||
virtual uint32_t GetTxAvailable (void) const = 0;
|
||||
virtual int SendTo (Ptr<Packet> p, const Address &address) = 0;
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
|
||||
virtual uint32_t GetRxAvailable (void) const = 0;
|
||||
|
||||
private:
|
||||
// Indirect the attribute setting and getting through private virtual methods
|
||||
virtual void SetSndBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetSndBufSize (void) const = 0;
|
||||
virtual void SetRcvBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetRcvBufSize (void) const = 0;
|
||||
virtual void SetSegSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetSegSize (void) const = 0;
|
||||
virtual void SetAdvWin (uint32_t window) = 0;
|
||||
virtual uint32_t GetAdvWin (void) const = 0;
|
||||
virtual void SetSSThresh (uint32_t threshold) = 0;
|
||||
virtual uint32_t GetSSThresh (void) const = 0;
|
||||
virtual void SetInitialCwnd (uint32_t count) = 0;
|
||||
virtual uint32_t GetInitialCwnd (void) const = 0;
|
||||
virtual void SetConnTimeout (Time timeout) = 0;
|
||||
virtual Time GetConnTimeout (void) const = 0;
|
||||
virtual void SetConnCount (uint32_t count) = 0;
|
||||
virtual uint32_t GetConnCount (void) const = 0;
|
||||
virtual void SetDelAckTimeout (Time timeout) = 0;
|
||||
virtual Time GetDelAckTimeout (void) const = 0;
|
||||
virtual void SetDelAckMaxCount (uint32_t count) = 0;
|
||||
virtual uint32_t GetDelAckMaxCount (void) const = 0;
|
||||
|
||||
};
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
#endif /* TCP_SOCKET_H */
|
||||
|
||||
|
||||
140
src/node/tcp.cc
140
src/node/tcp.cc
@@ -1,140 +0,0 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 Georgia Tech Research Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Raj Bhattacharjea <raj.b@gatech.edu>
|
||||
*/
|
||||
#include "tcp.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Tcp);
|
||||
|
||||
TypeId
|
||||
Tcp::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Tcp")
|
||||
.SetParent<SocketFactory> ()
|
||||
.AddAttribute ("DefaultSegmentSize",
|
||||
"Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)",
|
||||
UintegerValue (536),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultSegSize),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultAdvertisedWindowSize",
|
||||
"Default TCP advertised window size (bytes)",
|
||||
UintegerValue (0xffff),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultAdvWin),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultSlowStartThreshold",
|
||||
"Default TCP slow start threshold (bytes)",
|
||||
UintegerValue (0xffff),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultSsThresh),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultTxBufferSize",
|
||||
"Default TCP maximum transmit buffer size (bytes)",
|
||||
UintegerValue (0xffffffffl),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultTxBuffer),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultRxBufferSize",
|
||||
"Default TCP maximum receive buffer size (bytes)",
|
||||
UintegerValue (0xffffffffl),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultRxBuffer),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultInitialCongestionWindowSize",
|
||||
"Default TCP initial congestion window size (segments)",
|
||||
UintegerValue (1),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultInitialCwnd),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultConnTimeout",
|
||||
"Default TCP retransmission timeout when opening connection (seconds)",
|
||||
UintegerValue (3),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultConnTimeout),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultConnCount",
|
||||
"Default number of connection attempts (SYN retransmissions) before returning failure",
|
||||
UintegerValue (6),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultConnCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("DefaultDelAckTimeout",
|
||||
"Default timeout value for TCP delayed acks, in seconds",
|
||||
DoubleValue (0.2),
|
||||
MakeDoubleAccessor (&Tcp::m_defaultDelAckTimeout),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("DefaultDelAckCount",
|
||||
"Default number of packets to wait before sending a TCP ack",
|
||||
UintegerValue (2),
|
||||
MakeUintegerAccessor (&Tcp::m_defaultDelAckCount),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Tcp::GetDefaultSegSize (void) const
|
||||
{
|
||||
return m_defaultSegSize;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultAdvWin (void) const
|
||||
{
|
||||
return m_defaultAdvWin;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultSsThresh (void) const
|
||||
{
|
||||
return m_defaultSsThresh;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultTxBuffer (void) const
|
||||
{
|
||||
return m_defaultTxBuffer;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultRxBuffer (void) const
|
||||
{
|
||||
return m_defaultRxBuffer;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultInitialCwnd (void) const
|
||||
{
|
||||
return m_defaultInitialCwnd;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultConnTimeout (void) const
|
||||
{
|
||||
return m_defaultConnTimeout;
|
||||
}
|
||||
uint32_t
|
||||
Tcp::GetDefaultConnCount (void) const
|
||||
{
|
||||
return m_defaultConnCount;
|
||||
}
|
||||
|
||||
double
|
||||
Tcp::GetDefaultDelAckTimeout (void) const
|
||||
{
|
||||
return m_defaultDelAckTimeout;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Tcp::GetDefaultDelAckCount (void) const
|
||||
{
|
||||
return m_defaultDelAckCount;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
|
||||
virtual uint32_t GetRxAvailable (void) const = 0;
|
||||
|
||||
public:
|
||||
private:
|
||||
// Indirect the attribute setting and getting through private virtual methods
|
||||
virtual void SetRcvBufSize (uint32_t size) = 0;
|
||||
virtual uint32_t GetRcvBufSize (void) const = 0;
|
||||
|
||||
@@ -27,7 +27,8 @@ def build(bld):
|
||||
'packet-socket.cc',
|
||||
'udp-socket.cc',
|
||||
'udp-socket-factory.cc',
|
||||
'tcp.cc',
|
||||
'tcp-socket.cc',
|
||||
'tcp-socket-factory.cc',
|
||||
'ipv4.cc',
|
||||
'application.cc',
|
||||
'simple-channel.cc',
|
||||
@@ -60,7 +61,8 @@ def build(bld):
|
||||
'packet-socket-factory.h',
|
||||
'udp-socket.h',
|
||||
'udp-socket-factory.h',
|
||||
'tcp.h',
|
||||
'tcp-socket.h',
|
||||
'tcp-socket-factory.h',
|
||||
'ipv4.h',
|
||||
'application.h',
|
||||
'simple-channel.h',
|
||||
|
||||
@@ -236,7 +236,7 @@ int main (int argc, char *argv[])
|
||||
NodeContainer c; c.Create (1);
|
||||
|
||||
StaticInformation info;
|
||||
info.RecordAggregationInfo ("ns3::Node", "ns3::Tcp");
|
||||
info.RecordAggregationInfo ("ns3::Node", "ns3::TcpSocketFactory");
|
||||
info.RecordAggregationInfo ("ns3::Node", "ns3::UdpSocketFactory");
|
||||
info.RecordAggregationInfo ("ns3::Node", "ns3::PacketSocketFactory");
|
||||
info.RecordAggregationInfo ("ns3::Node", "ns3::olsr::Agent");
|
||||
|
||||
Reference in New Issue
Block a user