Merge with tomh/ns-3-dev-socket

This commit is contained in:
Raj Bhattacharjea
2008-05-21 12:01:24 -04:00
21 changed files with 578 additions and 412 deletions

View 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

View File

@@ -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
View 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
View 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 */

View File

@@ -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

View File

@@ -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;

View File

@@ -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',