From e6bd2a7a6aa36f0ae90a16208b588427dc4e0058 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 20 May 2008 11:52:25 -0700 Subject: [PATCH 1/6] change TcpSocket to TcpSocketImpl --- src/internet-node/tcp-header.cc | 2 +- src/internet-node/tcp-impl.h | 2 +- src/internet-node/tcp-l4-protocol.cc | 4 +- src/internet-node/tcp-l4-protocol.h | 6 +- .../{tcp-socket.cc => tcp-socket-impl.cc} | 244 +++++++++--------- .../{tcp-socket.h => tcp-socket-impl.h} | 16 +- src/internet-node/wscript | 2 +- 7 files changed, 138 insertions(+), 138 deletions(-) rename src/internet-node/{tcp-socket.cc => tcp-socket-impl.cc} (83%) rename src/internet-node/{tcp-socket.h => tcp-socket-impl.h} (96%) diff --git a/src/internet-node/tcp-header.cc b/src/internet-node/tcp-header.cc index f5c485999..c0f476220 100644 --- a/src/internet-node/tcp-header.cc +++ b/src/internet-node/tcp-header.cc @@ -20,7 +20,7 @@ #include #include -#include "tcp-socket.h" +#include "tcp-socket-impl.h" #include "tcp-header.h" #include "ns3/buffer.h" diff --git a/src/internet-node/tcp-impl.h b/src/internet-node/tcp-impl.h index 9990c7721..1b69a1d13 100644 --- a/src/internet-node/tcp-impl.h +++ b/src/internet-node/tcp-impl.h @@ -37,7 +37,7 @@ class TcpL4Protocol; * * Georgia Tech Network Simulator (GTNetS). * - * Most of the logic is in class ns3::TcpSocket. + * Most of the logic is in class ns3::TcpSocketImpl. */ class TcpImpl : public Tcp { diff --git a/src/internet-node/tcp-l4-protocol.cc b/src/internet-node/tcp-l4-protocol.cc index 653575db0..2898b09f4 100644 --- a/src/internet-node/tcp-l4-protocol.cc +++ b/src/internet-node/tcp-l4-protocol.cc @@ -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 rtt = m_rttFactory.Create (); - Ptr socket = CreateObject (); + Ptr socket = CreateObject (); socket->SetNode (m_node); socket->SetTcp (this); socket->SetRtt (rtt); diff --git a/src/internet-node/tcp-l4-protocol.h b/src/internet-node/tcp-l4-protocol.h index e832a69a2..b08eabeba 100644 --- a/src/internet-node/tcp-l4-protocol.h +++ b/src/internet-node/tcp-l4-protocol.h @@ -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 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, TcpHeader, Ipv4Address, Ipv4Address); static ObjectFactory GetDefaultRttEstimatorFactory (void); diff --git a/src/internet-node/tcp-socket.cc b/src/internet-node/tcp-socket-impl.cc similarity index 83% rename from src/internet-node/tcp-socket.cc rename to src/internet-node/tcp-socket-impl.cc index 3e2a7bc2a..12686e376 100644 --- a/src/internet-node/tcp-socket.cc +++ b/src/internet-node/tcp-socket-impl.cc @@ -23,7 +23,7 @@ #include "ns3/inet-socket-address.h" #include "ns3/log.h" #include "ns3/ipv4.h" -#include "tcp-socket.h" +#include "tcp-socket-impl.h" #include "tcp-l4-protocol.h" #include "ipv4-end-point.h" #include "ipv4-l4-demux.h" @@ -36,27 +36,27 @@ #include -NS_LOG_COMPONENT_DEFINE ("TcpSocket"); +NS_LOG_COMPONENT_DEFINE ("TcpSocketImpl"); using namespace std; namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED (TcpSocket); +NS_OBJECT_ENSURE_REGISTERED (TcpSocketImpl); TypeId -TcpSocket::GetTypeId () +TcpSocketImpl::GetTypeId () { - static TypeId tid = TypeId("ns3::TcpSocket") + static TypeId tid = TypeId("ns3::TcpSocketImpl") .SetParent () .AddTraceSource ("CongestionWindow", "The TCP connection's congestion window", - MakeTraceSourceAccessor (&TcpSocket::m_cWnd)) + MakeTraceSourceAccessor (&TcpSocketImpl::m_cWnd)) ; return tid; } - TcpSocket::TcpSocket () + TcpSocketImpl::TcpSocketImpl () : m_skipRetxResched (false), m_dupAckCount (0), m_delAckCount (0), @@ -89,7 +89,7 @@ TcpSocket::GetTypeId () } -TcpSocket::TcpSocket(const TcpSocket& sock) +TcpSocketImpl::TcpSocketImpl(const TcpSocketImpl& sock) : Socket(sock), //copy the base class callbacks m_skipRetxResched (sock.m_skipRetxResched), m_dupAckCount (sock.m_dupAckCount), @@ -148,7 +148,7 @@ TcpSocket::TcpSocket(const TcpSocket& sock) //too; this is in SYN_ACK_TX } -TcpSocket::~TcpSocket () +TcpSocketImpl::~TcpSocketImpl () { NS_LOG_FUNCTION(this); m_node = 0; @@ -173,7 +173,7 @@ TcpSocket::~TcpSocket () } void -TcpSocket::SetNode (Ptr node) +TcpSocketImpl::SetNode (Ptr node) { m_node = node; Ptr t = node->GetObject (); @@ -190,33 +190,33 @@ TcpSocket::SetNode (Ptr node) } void -TcpSocket::SetTcp (Ptr tcp) +TcpSocketImpl::SetTcp (Ptr tcp) { m_tcp = tcp; } void -TcpSocket::SetRtt (Ptr rtt) +TcpSocketImpl::SetRtt (Ptr rtt) { m_rtt = rtt; } enum Socket::SocketErrno -TcpSocket::GetErrno (void) const +TcpSocketImpl::GetErrno (void) const { NS_LOG_FUNCTION_NOARGS (); return m_errno; } Ptr -TcpSocket::GetNode (void) const +TcpSocketImpl::GetNode (void) const { NS_LOG_FUNCTION_NOARGS (); return m_node; } void -TcpSocket::Destroy (void) +TcpSocketImpl::Destroy (void) { NS_LOG_FUNCTION_NOARGS (); m_node = 0; @@ -225,29 +225,29 @@ TcpSocket::Destroy (void) m_retxEvent.Cancel (); } int -TcpSocket::FinishBind (void) +TcpSocketImpl::FinishBind (void) { NS_LOG_FUNCTION_NOARGS (); if (m_endPoint == 0) { return -1; } - m_endPoint->SetRxCallback (MakeCallback (&TcpSocket::ForwardUp, Ptr(this))); - m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocket::Destroy, Ptr(this))); + m_endPoint->SetRxCallback (MakeCallback (&TcpSocketImpl::ForwardUp, Ptr(this))); + m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketImpl::Destroy, Ptr(this))); m_localAddress = m_endPoint->GetLocalAddress (); m_localPort = m_endPoint->GetLocalPort (); return 0; } int -TcpSocket::Bind (void) +TcpSocketImpl::Bind (void) { NS_LOG_FUNCTION_NOARGS (); m_endPoint = m_tcp->Allocate (); return FinishBind (); } int -TcpSocket::Bind (const Address &address) +TcpSocketImpl::Bind (const Address &address) { NS_LOG_FUNCTION (this<Allocate (); - NS_LOG_LOGIC ("TcpSocket "<Allocate (port); - NS_LOG_LOGIC ("TcpSocket "<Allocate (ipv4); - NS_LOG_LOGIC ("TcpSocket "<Allocate (ipv4, port); - NS_LOG_LOGIC ("TcpSocket "< p) //p here is just data, no headers +TcpSocketImpl::Send (const Ptr p) //p here is just data, no headers { // TCP Does not deal with packets from app, just data return Send(p->PeekData(), p->GetSize()); } -int TcpSocket::Send (const uint8_t* buf, uint32_t size) +int TcpSocketImpl::Send (const uint8_t* buf, uint32_t size) { NS_LOG_FUNCTION (this << buf << size); if (m_state == ESTABLISHED || m_state == SYN_SENT || m_state == CLOSE_WAIT) @@ -397,7 +397,7 @@ int TcpSocket::Send (const uint8_t* buf, uint32_t size) } } -int TcpSocket::DoSendTo (Ptr p, const Address &address) +int TcpSocketImpl::DoSendTo (Ptr p, const Address &address) { NS_LOG_FUNCTION (this << p << address); InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); @@ -406,7 +406,7 @@ int TcpSocket::DoSendTo (Ptr p, const Address &address) return DoSendTo (p, ipv4, port); } -int TcpSocket::DoSendTo (Ptr p, Ipv4Address ipv4, uint16_t port) +int TcpSocketImpl::DoSendTo (Ptr p, Ipv4Address ipv4, uint16_t port) { NS_LOG_FUNCTION (this << p << ipv4 << port); if (m_endPoint == 0) @@ -430,7 +430,7 @@ int TcpSocket::DoSendTo (Ptr p, Ipv4Address ipv4, uint16_t port) } int -TcpSocket::SendTo (Ptr p, const Address &address) +TcpSocketImpl::SendTo (Ptr p, const Address &address) { NS_LOG_FUNCTION (this << address << p); if (!m_connected) @@ -445,7 +445,7 @@ TcpSocket::SendTo (Ptr p, const Address &address) } uint32_t -TcpSocket::GetTxAvailable (void) const +TcpSocketImpl::GetTxAvailable (void) const { NS_LOG_FUNCTION_NOARGS (); if (m_pendingData != 0) @@ -462,7 +462,7 @@ TcpSocket::GetTxAvailable (void) const } int -TcpSocket::Listen (uint32_t q) +TcpSocketImpl::Listen (uint32_t q) { NS_LOG_FUNCTION (this << q); Actions_t action = ProcessEvent (APP_LISTEN); @@ -471,7 +471,7 @@ TcpSocket::Listen (uint32_t q) } Ptr -TcpSocket::Recv (uint32_t maxSize, uint32_t flags) +TcpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { NS_LOG_FUNCTION_NOARGS (); if (m_deliveryQueue.empty() ) @@ -492,7 +492,7 @@ TcpSocket::Recv (uint32_t maxSize, uint32_t flags) } uint32_t -TcpSocket::GetRxAvailable (void) const +TcpSocketImpl::GetRxAvailable (void) const { NS_LOG_FUNCTION_NOARGS (); // We separately maintain this state to avoid walking the queue @@ -501,35 +501,35 @@ TcpSocket::GetRxAvailable (void) const } void -TcpSocket::SetSndBuf (uint32_t size) +TcpSocketImpl::SetSndBuf (uint32_t size) { NS_LOG_FUNCTION_NOARGS (); m_sndBufLimit = size; } uint32_t -TcpSocket::GetSndBuf (void) const +TcpSocketImpl::GetSndBuf (void) const { NS_LOG_FUNCTION_NOARGS (); return m_sndBufLimit; } void -TcpSocket::SetRcvBuf (uint32_t size) +TcpSocketImpl::SetRcvBuf (uint32_t size) { NS_LOG_FUNCTION_NOARGS (); m_rcvBufLimit = size; } uint32_t -TcpSocket::GetRcvBuf (void) const +TcpSocketImpl::GetRcvBuf (void) const { NS_LOG_FUNCTION_NOARGS (); return m_rcvBufLimit; } void -TcpSocket::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) +TcpSocketImpl::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) { NS_LOG_DEBUG("Socket " << this << " got forward up" << " dport " << m_endPoint->GetLocalPort() << @@ -563,26 +563,26 @@ TcpSocket::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) ProcessPacketAction (action, packet, tcpHeader, address); } -Actions_t TcpSocket::ProcessEvent (Events_t e) +Actions_t TcpSocketImpl::ProcessEvent (Events_t e) { NS_LOG_FUNCTION (this << e); States_t saveState = m_state; - NS_LOG_LOGIC ("TcpSocket " << this << " processing event " << e); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " processing event " << e); // simulation singleton is a way to get a single global static instance of a // class intended to be a singleton; see simulation-singleton.h SA stateAction = SimulationSingleton::Get ()->Lookup (m_state,e); // debug if (stateAction.action == RST_TX) { - NS_LOG_LOGIC ("TcpSocket " << this << " sending RST from state " + NS_LOG_LOGIC ("TcpSocketImpl " << this << " sending RST from state " << saveState << " event " << e); } bool needCloseNotify = (stateAction.state == CLOSED && m_state != CLOSED && e != TIMEOUT); m_state = stateAction.state; - NS_LOG_LOGIC ("TcpSocket " << this << " moved from state " << saveState + NS_LOG_LOGIC ("TcpSocketImpl " << this << " moved from state " << saveState << " to state " <SetPeer (m_remoteAddress, m_remotePort); - NS_LOG_LOGIC ("TcpSocket " << this << " Connected!"); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " Connected!"); } if (needCloseNotify && !m_closeNotified) { - NS_LOG_LOGIC ("TcpSocket " << this << " transition to CLOSED from " + NS_LOG_LOGIC ("TcpSocketImpl " << this << " transition to CLOSED from " << m_state << " event " << e << " closeNot " << m_closeNotified << " action " << stateAction.action); NotifyCloseCompleted (); m_closeNotified = true; - NS_LOG_LOGIC ("TcpSocket " << this << " calling Closed from PE" + NS_LOG_LOGIC ("TcpSocketImpl " << this << " calling Closed from PE" << " origState " << saveState << " event " << e); - NS_LOG_LOGIC ("TcpSocket " << this << " transition to CLOSED from " + NS_LOG_LOGIC ("TcpSocketImpl " << this << " transition to CLOSED from " << m_state << " event " << e << " set CloseNotif "); } return stateAction.action; } -void TcpSocket::SendEmptyPacket (uint8_t flags) +void TcpSocketImpl::SendEmptyPacket (uint8_t flags) { NS_LOG_FUNCTION (this << flags); Ptr p = Create (); @@ -640,17 +640,17 @@ void TcpSocket::SendEmptyPacket (uint8_t flags) NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " << (Simulator::Now () + rto).GetSeconds ()); - m_retxEvent = Simulator::Schedule (rto, &TcpSocket::ReTxTimeout, this); + m_retxEvent = Simulator::Schedule (rto, &TcpSocketImpl::ReTxTimeout, this); } } -bool TcpSocket::ProcessAction (Actions_t a) +bool TcpSocketImpl::ProcessAction (Actions_t a) { // These actions do not require a packet or any TCP Headers NS_LOG_FUNCTION (this << a); switch (a) { case NO_ACT: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action: NO_ACT"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action: NO_ACT"); break; case ACK_TX: SendEmptyPacket (TcpHeader::ACK); @@ -659,11 +659,11 @@ bool TcpSocket::ProcessAction (Actions_t a) NS_ASSERT (false); // This should be processed in ProcessPacketAction break; case RST_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action RST_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action RST_TX"); SendEmptyPacket (TcpHeader::RST); break; case SYN_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action SYN_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_TX"); // TCP SYN Flag consumes one byte // is the above correct? we're SENDING a syn, not acking back -- Raj // commented out for now @@ -671,17 +671,17 @@ bool TcpSocket::ProcessAction (Actions_t a) SendEmptyPacket (TcpHeader::SYN); break; case SYN_ACK_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action SYN_ACK_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); // TCP SYN Flag consumes one byte ++m_nextRxSequence; SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); break; case FIN_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action FIN_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action FIN_TX"); SendEmptyPacket (TcpHeader::FIN); break; case FIN_ACK_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action FIN_ACK_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action FIN_ACK_TX"); SendEmptyPacket (TcpHeader::FIN | TcpHeader::ACK); break; case NEW_ACK: @@ -691,36 +691,36 @@ bool TcpSocket::ProcessAction (Actions_t a) NS_ASSERT (false); // This should be processed in ProcessPacketAction break; case RETX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action RETX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action RETX"); break; case TX_DATA: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action TX_DATA"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action TX_DATA"); SendPendingData (); break; case PEER_CLOSE: NS_ASSERT (false); // This should be processed in ProcessPacketAction - NS_LOG_LOGIC ("TcpSocket " << this <<" Action PEER_CLOSE"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action PEER_CLOSE"); break; case APP_CLOSED: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action APP_CLOSED"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action APP_CLOSED"); break; case CANCEL_TM: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action CANCEL_TM"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action CANCEL_TM"); break; case APP_NOTIFY: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action APP_NOTIFY"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action APP_NOTIFY"); break; case SERV_NOTIFY: NS_ASSERT (false); // This should be processed in ProcessPacketAction break; case LAST_ACTION: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action LAST_ACTION"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action LAST_ACTION"); break; } return true; } -bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, +bool TcpSocketImpl::ProcessPacketAction (Actions_t a, Ptr p, const TcpHeader& tcpHeader, const Address& fromAddress) { @@ -730,24 +730,24 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, switch (a) { case SYN_ACK_TX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action SYN_ACK_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SYN_ACK_TX"); // m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); // m_remoteAddress = InetSocketAddress::ConvertFrom (fromAddress).GetIpv4 (); // if (ipv4->GetIfIndexForDestination (m_remoteAddress, localIfIndex)) // { // m_localAddress = ipv4->GetAddress (localIfIndex); // } - if (m_state == LISTEN) //this means we should fork a new TcpSocket + if (m_state == LISTEN) //this means we should fork a new TcpSocketImpl { NS_LOG_DEBUG("In SYN_ACK_TX, m_state is LISTEN, this " << this); //notify the server that we got a SYN // If server refuses connection do nothing if (!NotifyConnectionRequest(fromAddress)) return true; // Clone the socket - Ptr newSock = Copy (); - NS_LOG_LOGIC ("Cloned a TcpSocket " << newSock); + Ptr newSock = Copy (); + NS_LOG_LOGIC ("Cloned a TcpSocketImpl " << newSock); //this listening socket should do nothing more - Simulator::ScheduleNow (&TcpSocket::CompleteFork, newSock, + Simulator::ScheduleNow (&TcpSocketImpl::CompleteFork, newSock, p, tcpHeader,fromAddress); return true; } @@ -766,12 +766,12 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, SendEmptyPacket (TcpHeader::SYN | TcpHeader::ACK); break; case ACK_TX_1: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action ACK_TX_1"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action ACK_TX_1"); // TCP SYN consumes one byte m_nextRxSequence = tcpHeader.GetSequenceNumber() + SequenceNumber(1); m_nextTxSequence = tcpHeader.GetAckNumber (); m_firstPendingSequence = m_nextTxSequence; //bug 166 - NS_LOG_DEBUG ("TcpSocket " << this << " ACK_TX_1" << + NS_LOG_DEBUG ("TcpSocketImpl " << this << " ACK_TX_1" << " nextRxSeq " << m_nextRxSequence); SendEmptyPacket (TcpHeader::ACK); m_rxWindowSize = tcpHeader.GetWindowSize (); @@ -788,7 +788,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, SendPendingData (); break; case NEW_ACK: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action NEW_ACK_TX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action NEW_ACK_TX"); if (tcpHeader.GetAckNumber () < m_highestRxAck) //old ack, do nothing { break; @@ -806,7 +806,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, NewAck (tcpHeader.GetAckNumber ()); break; case NEW_SEQ_RX: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action NEW_SEQ_RX"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action NEW_SEQ_RX"); NewRx (p, tcpHeader, fromAddress); // Process new data received break; case PEER_CLOSE: @@ -817,7 +817,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, if (tcpHeader.GetSequenceNumber () != m_nextRxSequence) { // process close later m_pendingClose = true; - NS_LOG_LOGIC ("TcpSocket " << this << " setting pendingClose" + NS_LOG_LOGIC ("TcpSocketImpl " << this << " setting pendingClose" << " rxseq " << tcpHeader.GetSequenceNumber () << " nextRxSeq " << m_nextRxSequence); NewRx (p, tcpHeader, fromAddress); @@ -830,7 +830,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, NewRx (p, tcpHeader, fromAddress); } States_t saveState = m_state; // Used to see if app responds - NS_LOG_LOGIC ("TcpSocket " << this + NS_LOG_LOGIC ("TcpSocketImpl " << this << " peer close, state " << m_state); if (!m_closeRequestNotified) { @@ -839,7 +839,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, NotifyCloseRequested(); m_closeRequestNotified = true; } - NS_LOG_LOGIC ("TcpSocket " << this + NS_LOG_LOGIC ("TcpSocketImpl " << this << " peer close, state after " << m_state); if (m_state == saveState) { // Need to ack, the application will close later @@ -848,15 +848,15 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, } if (m_state == LAST_ACK) { - NS_LOG_LOGIC ("TcpSocket " << this << " scheduling LATO1"); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " scheduling LATO1"); m_lastAckEvent = Simulator::Schedule (m_rtt->RetransmitTimeout (), - &TcpSocket::LastAckTimeout,this); + &TcpSocketImpl::LastAckTimeout,this); } break; } case SERV_NOTIFY: - NS_LOG_LOGIC ("TcpSocket " << this <<" Action SERV_NOTIFY"); - NS_LOG_LOGIC ("TcpSocket " << this << " Connected!"); + NS_LOG_LOGIC ("TcpSocketImpl " << this <<" Action SERV_NOTIFY"); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " Connected!"); NotifyNewConnectionCreated (this, fromAddress); m_connected = true; // ! This is bogus; fix when we clone the tcp m_endPoint->SetPeer (m_remoteAddress, m_remotePort); @@ -869,7 +869,7 @@ bool TcpSocket::ProcessPacketAction (Actions_t a, Ptr p, return true; } -void TcpSocket::CompleteFork(Ptr p, const TcpHeader& h, const Address& fromAddress) +void TcpSocketImpl::CompleteFork(Ptr p, const TcpHeader& h, const Address& fromAddress) { // Get port and address from peer (connecting host) m_remotePort = InetSocketAddress::ConvertFrom (fromAddress).GetPort (); @@ -881,19 +881,19 @@ void TcpSocket::CompleteFork(Ptr p, const TcpHeader& h, const Address& f //the cloned socket with be in listen state, so manually change state m_state = SYN_RCVD; //equivalent to FinishBind - m_endPoint->SetRxCallback (MakeCallback (&TcpSocket::ForwardUp, Ptr(this))); - m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocket::Destroy, Ptr(this))); + m_endPoint->SetRxCallback (MakeCallback (&TcpSocketImpl::ForwardUp, Ptr(this))); + m_endPoint->SetDestroyCallback (MakeCallback (&TcpSocketImpl::Destroy, Ptr(this))); ProcessPacketAction(SYN_ACK_TX, p, h, fromAddress); } -void TcpSocket::ConnectionSucceeded() +void TcpSocketImpl::ConnectionSucceeded() { // We would preferred to have scheduled an event directly to // NotifyConnectionSucceeded, but (sigh) these are protected // and we can get the address of it :( NotifyConnectionSucceeded(); } -bool TcpSocket::SendPendingData (bool withAck) +bool TcpSocketImpl::SendPendingData (bool withAck) { NS_LOG_FUNCTION (this << withAck); NS_LOG_LOGIC ("ENTERING SendPendingData"); @@ -905,7 +905,7 @@ bool TcpSocket::SendPendingData (bool withAck) while (m_pendingData->SizeFromSeq (m_firstPendingSequence, m_nextTxSequence)) { uint32_t w = AvailableWindow ();// Get available window size - NS_LOG_LOGIC ("TcpSocket " << this << " SendPendingData" + NS_LOG_LOGIC ("TcpSocketImpl " << this << " SendPendingData" << " w " << w << " rxwin " << m_rxWindowSize << " cWnd " << m_cWnd @@ -922,7 +922,7 @@ bool TcpSocket::SendPendingData (bool withAck) uint32_t s = std::min (w, m_segmentSize); // Send no more than window Ptr p = m_pendingData->CopyFromSeq (s, m_firstPendingSequence, m_nextTxSequence); - NS_LOG_LOGIC("TcpSocket " << this << " sendPendingData" + NS_LOG_LOGIC("TcpSocketImpl " << this << " sendPendingData" << " txseq " << m_nextTxSequence << " s " << s << " datasize " << p->GetSize() ); @@ -960,7 +960,7 @@ bool TcpSocket::SendPendingData (bool withAck) NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " << (Simulator::Now () + rto).GetSeconds () ); - m_retxEvent = Simulator::Schedule (rto,&TcpSocket::ReTxTimeout,this); + m_retxEvent = Simulator::Schedule (rto,&TcpSocketImpl::ReTxTimeout,this); } NS_LOG_LOGIC ("About to send a packet with flags: " << flags); m_tcp->SendPacket (p, header, @@ -968,7 +968,7 @@ bool TcpSocket::SendPendingData (bool withAck) m_remoteAddress); m_rtt->SentSeq(m_nextTxSequence, sz); // notify the RTT // Notify the application - Simulator::ScheduleNow(&TcpSocket::NotifyDataSent, this, p->GetSize ()); + Simulator::ScheduleNow(&TcpSocketImpl::NotifyDataSent, this, p->GetSize ()); nPacketsSent++; // Count sent this loop m_nextTxSequence += sz; // Advance next tx sequence // Note the high water mark @@ -979,26 +979,26 @@ bool TcpSocket::SendPendingData (bool withAck) return (nPacketsSent>0); } -uint32_t TcpSocket::UnAckDataCount () +uint32_t TcpSocketImpl::UnAckDataCount () { NS_LOG_FUNCTION_NOARGS (); return m_nextTxSequence - m_highestRxAck; } -uint32_t TcpSocket::BytesInFlight () +uint32_t TcpSocketImpl::BytesInFlight () { NS_LOG_FUNCTION_NOARGS (); return m_highTxMark - m_highestRxAck; } -uint32_t TcpSocket::Window () +uint32_t TcpSocketImpl::Window () { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC ("TcpSocket::Window() "< p, +void TcpSocketImpl::NewRx (Ptr p, const TcpHeader& tcpHeader, const Address& fromAddress) { NS_LOG_FUNCTION (this << p << "tcpHeader " << fromAddress); - NS_LOG_LOGIC ("TcpSocket " << this << " NewRx," + NS_LOG_LOGIC ("TcpSocketImpl " << this << " NewRx," << " seq " << tcpHeader.GetSequenceNumber() << " ack " << tcpHeader.GetAckNumber() << " p.size is " << p->GetSize () ); - NS_LOG_DEBUG ("TcpSocket " << this << + NS_LOG_DEBUG ("TcpSocketImpl " << this << " NewRx," << " seq " << tcpHeader.GetSequenceNumber() << " ack " << tcpHeader.GetAckNumber() << @@ -1055,7 +1055,7 @@ void TcpSocket::NewRx (Ptr p, { NS_LOG_LOGIC ("Tcp " << this << " HuH? Got data after closeNotif"); } - NS_LOG_LOGIC ("TcpSocket " << this << " adv rxseq by " << s); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " adv rxseq by " << s); // Look for buffered data UnAckData_t::iterator i; // Note that the bufferedData list DOES contain the tcp header @@ -1109,11 +1109,11 @@ void TcpSocket::NewRx (Ptr p, m_rxAvailable += p->GetSize (); NotifyDataRecv (); - NS_LOG_LOGIC ("TcpSocket " << this << " adv rxseq1 by " << s1 ); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " adv rxseq1 by " << s1 ); m_nextRxSequence += s1; // Note data received m_bufferedData.erase (i); // Remove from list if (flags & TcpHeader::FIN) - NS_LOG_LOGIC("TcpSocket " << this + NS_LOG_LOGIC("TcpSocketImpl " << this << " found FIN in buffered"); } @@ -1153,17 +1153,17 @@ void TcpSocket::NewRx (Ptr p, } else { - m_delAckEvent = Simulator::Schedule (m_delAckTimout, &TcpSocket::DelAckTimeout, this); + m_delAckEvent = Simulator::Schedule (m_delAckTimout, &TcpSocketImpl::DelAckTimeout, this); } } -void TcpSocket::DelAckTimeout () +void TcpSocketImpl::DelAckTimeout () { m_delAckCount = 0; SendEmptyPacket (TcpHeader::ACK); } -void TcpSocket::CommonNewAck (SequenceNumber ack, bool skipTimer) +void TcpSocketImpl::CommonNewAck (SequenceNumber ack, bool skipTimer) { // CommonNewAck is called only for "New" (non-duplicate) acks // and MUST be called by any subclass, from the NewAck function // Always cancel any pending re-tx timer on new acknowledgement @@ -1177,7 +1177,7 @@ void TcpSocket::CommonNewAck (SequenceNumber ack, bool skipTimer) NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " << (Simulator::Now () + rto).GetSeconds ()); - m_retxEvent = Simulator::Schedule (rto, &TcpSocket::ReTxTimeout, this); + m_retxEvent = Simulator::Schedule (rto, &TcpSocketImpl::ReTxTimeout, this); } NS_LOG_LOGIC ("TCP " << this << " NewAck " << ack << " numberAck " << (ack - m_highestRxAck)); // Number bytes ack'ed @@ -1209,23 +1209,23 @@ void TcpSocket::CommonNewAck (SequenceNumber ack, bool skipTimer) SendPendingData(); } -Ptr TcpSocket::Copy () +Ptr TcpSocketImpl::Copy () { - return CopyObject (this); + return CopyObject (this); } -void TcpSocket::NewAck (SequenceNumber seq) +void TcpSocketImpl::NewAck (SequenceNumber seq) { // New acknowledgement up to sequence number "seq" // Adjust congestion window in response to new ack's received NS_LOG_FUNCTION (this << seq); - NS_LOG_LOGIC ("TcpSocket " << this << " NewAck " + NS_LOG_LOGIC ("TcpSocketImpl " << this << " NewAck " << " seq " << seq << " cWnd " << m_cWnd << " ssThresh " << m_ssThresh); if (m_cWnd < m_ssThresh) { // Slow start mode, add one segSize to cWnd m_cWnd += m_segmentSize; - NS_LOG_LOGIC ("TcpSocket " << this << " NewCWnd SlowStart, cWnd " << m_cWnd + NS_LOG_LOGIC ("TcpSocketImpl " << this << " NewCWnd SlowStart, cWnd " << m_cWnd << " sst " << m_ssThresh); } else @@ -1242,17 +1242,17 @@ void TcpSocket::NewAck (SequenceNumber seq) CommonNewAck (seq, false); // Complete newAck processing } -void TcpSocket::DupAck (const TcpHeader& t, uint32_t count) +void TcpSocketImpl::DupAck (const TcpHeader& t, uint32_t count) { NS_LOG_FUNCTION (this << "t " << count); - NS_LOG_LOGIC ("TcpSocket " << this << " DupAck " << t.GetAckNumber () + NS_LOG_LOGIC ("TcpSocketImpl " << this << " DupAck " << t.GetAckNumber () << ", count " << count << ", time " << Simulator::Now ()); if (count == 3) { // Count of three indicates triple duplicate ack m_ssThresh = Window () / 2; // Per RFC2581 m_ssThresh = std::max (m_ssThresh, 2 * m_segmentSize); - NS_LOG_LOGIC("TcpSocket " << this << "Tahoe TDA, time " << Simulator::Now () + NS_LOG_LOGIC("TcpSocketImpl " << this << "Tahoe TDA, time " << Simulator::Now () << " seq " << t.GetAckNumber () << " in flight " << BytesInFlight () << " new ssthresh " << m_ssThresh); @@ -1264,7 +1264,7 @@ void TcpSocket::DupAck (const TcpHeader& t, uint32_t count) } } -void TcpSocket::ReTxTimeout () +void TcpSocketImpl::ReTxTimeout () { // Retransmit timeout NS_LOG_FUNCTION (this); m_ssThresh = Window () / 2; // Per RFC2581 @@ -1277,7 +1277,7 @@ void TcpSocket::ReTxTimeout () Retransmit (); // Retransmit the packet } -void TcpSocket::LastAckTimeout () +void TcpSocketImpl::LastAckTimeout () { m_lastAckEvent.Cancel (); if (m_state == LAST_ACK) @@ -1291,7 +1291,7 @@ void TcpSocket::LastAckTimeout () } } -void TcpSocket::Retransmit () +void TcpSocketImpl::Retransmit () { NS_LOG_FUNCTION (this); uint8_t flags = TcpHeader::NONE; @@ -1328,14 +1328,14 @@ void TcpSocket::Retransmit () flags = flags | TcpHeader::FIN; } - NS_LOG_LOGIC ("TcpSocket " << this << " retxing seq " << m_highestRxAck); + NS_LOG_LOGIC ("TcpSocketImpl " << this << " retxing seq " << m_highestRxAck); if (m_retxEvent.IsExpired () ) { Time rto = m_rtt->RetransmitTimeout (); NS_LOG_LOGIC ("Schedule retransmission timeout at time " << Simulator::Now ().GetSeconds () << " to expire at time " << (Simulator::Now () + rto).GetSeconds ()); - m_retxEvent = Simulator::Schedule (rto,&TcpSocket::ReTxTimeout,this); + m_retxEvent = Simulator::Schedule (rto,&TcpSocketImpl::ReTxTimeout,this); } m_rtt->SentSeq (m_highestRxAck,p->GetSize ()); // And send the packet diff --git a/src/internet-node/tcp-socket.h b/src/internet-node/tcp-socket-impl.h similarity index 96% rename from src/internet-node/tcp-socket.h rename to src/internet-node/tcp-socket-impl.h index 023d3029d..e2f9d75f6 100644 --- a/src/internet-node/tcp-socket.h +++ b/src/internet-node/tcp-socket-impl.h @@ -17,8 +17,8 @@ * * Author: Raj Bhattacharjea */ -#ifndef TCP_SOCKET_H -#define TCP_SOCKET_H +#ifndef TCP_SOCKET_IMPL_H +#define TCP_SOCKET_IMPL_H #include #include @@ -42,16 +42,16 @@ class Packet; class TcpL4Protocol; class TcpHeader; -class TcpSocket : public Socket +class TcpSocketImpl : public Socket { 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); void SetTcp (Ptr tcp); @@ -110,7 +110,7 @@ private: // Manage data tx/rx void NewRx (Ptr, const TcpHeader&, const Address&); // XXX This should be virtual and overridden - Ptr Copy (); + Ptr Copy (); void NewAck (SequenceNumber seq); // XXX This should be virtual and overridden void DupAck (const TcpHeader& t, uint32_t count); @@ -194,4 +194,4 @@ private: }//namespace ns3 -#endif /* TCP_SOCKET_H */ +#endif /* TCP_SOCKET_IMPL_H */ diff --git a/src/internet-node/wscript b/src/internet-node/wscript index 7b05bdaf0..26c5d6a64 100644 --- a/src/internet-node/wscript +++ b/src/internet-node/wscript @@ -23,7 +23,7 @@ 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', From 8dc24604163de88a1e671cf31be73677402de14b Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 20 May 2008 12:16:55 -0700 Subject: [PATCH 2/6] move Tcp to TcpSocketFactory --- examples/tcp-large-transfer.cc | 6 +-- src/helper/packet-sink-helper.cc | 2 +- src/internet-node/tcp-header.h | 2 +- src/internet-node/tcp-impl.cc | 2 +- src/internet-node/tcp-impl.h | 4 +- src/internet-node/tcp-socket-impl.cc | 2 +- src/node/{tcp.cc => tcp-socket-factory.cc} | 48 +++++++++++----------- src/node/{tcp.h => tcp-socket-factory.h} | 13 +++--- src/node/wscript | 4 +- utils/print-introspected-doxygen.cc | 2 +- 10 files changed, 43 insertions(+), 42 deletions(-) rename src/node/{tcp.cc => tcp-socket-factory.cc} (70%) rename src/node/{tcp.h => tcp-socket-factory.h} (89%) diff --git a/examples/tcp-large-transfer.cc b/examples/tcp-large-transfer.cc index ee7d831b0..610ad0714 100644 --- a/examples/tcp-large-transfer.cc +++ b/examples/tcp-large-transfer.cc @@ -169,15 +169,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 localSocket = Socket::CreateSocket (c0.Get (0), Tcp::GetTypeId ()); + //TypeId tid = TypeId::LookupByName ("ns3::TcpSocketFactory"); + Ptr localSocket = Socket::CreateSocket (c0.Get (0), TcpSocketFactory::GetTypeId ()); localSocket->Bind (); Simulator::ScheduleNow (&StartFlow, localSocket, nBytes, ipInterfs.GetAddress (1), servPort); diff --git a/src/helper/packet-sink-helper.cc b/src/helper/packet-sink-helper.cc index e7cc76f72..ef2704114 100644 --- a/src/helper/packet-sink-helper.cc +++ b/src/helper/packet-sink-helper.cc @@ -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 diff --git a/src/internet-node/tcp-header.h b/src/internet-node/tcp-header.h index 3181b03be..e676287f6 100644 --- a/src/internet-node/tcp-header.h +++ b/src/internet-node/tcp-header.h @@ -24,7 +24,7 @@ #include #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" diff --git a/src/internet-node/tcp-impl.cc b/src/internet-node/tcp-impl.cc index 5a1ad3954..dc6d69f17 100644 --- a/src/internet-node/tcp-impl.cc +++ b/src/internet-node/tcp-impl.cc @@ -48,7 +48,7 @@ void TcpImpl::DoDispose (void) { m_tcp = 0; - Tcp::DoDispose (); + TcpSocketFactory::DoDispose (); } } // namespace ns3 diff --git a/src/internet-node/tcp-impl.h b/src/internet-node/tcp-impl.h index 1b69a1d13..647dd6372 100644 --- a/src/internet-node/tcp-impl.h +++ b/src/internet-node/tcp-impl.h @@ -20,7 +20,7 @@ #ifndef TCP_IMPL_H #define TCP_IMPL_H -#include "ns3/tcp.h" +#include "ns3/tcp-socket-factory.h" #include "ns3/ptr.h" namespace ns3 { @@ -39,7 +39,7 @@ class TcpL4Protocol; * * Most of the logic is in class ns3::TcpSocketImpl. */ -class TcpImpl : public Tcp +class TcpImpl : public TcpSocketFactory { public: TcpImpl (); diff --git a/src/internet-node/tcp-socket-impl.cc b/src/internet-node/tcp-socket-impl.cc index 12686e376..5edc19109 100644 --- a/src/internet-node/tcp-socket-impl.cc +++ b/src/internet-node/tcp-socket-impl.cc @@ -176,7 +176,7 @@ void TcpSocketImpl::SetNode (Ptr node) { m_node = node; - Ptr t = node->GetObject (); + Ptr t = node->GetObject (); m_segmentSize = t->GetDefaultSegSize (); m_rxWindowSize = t->GetDefaultAdvWin (); m_advertisedWindowSize = t->GetDefaultAdvWin (); diff --git a/src/node/tcp.cc b/src/node/tcp-socket-factory.cc similarity index 70% rename from src/node/tcp.cc rename to src/node/tcp-socket-factory.cc index 77e02362f..40d1caa66 100644 --- a/src/node/tcp.cc +++ b/src/node/tcp-socket-factory.cc @@ -17,122 +17,122 @@ * * Author: Raj Bhattacharjea */ -#include "tcp.h" +#include "tcp-socket-factory.h" #include "ns3/uinteger.h" #include "ns3/double.h" namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED (Tcp); +NS_OBJECT_ENSURE_REGISTERED (TcpSocketFactory); TypeId -Tcp::GetTypeId (void) +TcpSocketFactory::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::Tcp") + static TypeId tid = TypeId ("ns3::TcpSocketFactory") .SetParent () .AddAttribute ("DefaultSegmentSize", "Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)", UintegerValue (536), - MakeUintegerAccessor (&Tcp::m_defaultSegSize), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultSegSize), MakeUintegerChecker ()) .AddAttribute ("DefaultAdvertisedWindowSize", "Default TCP advertised window size (bytes)", UintegerValue (0xffff), - MakeUintegerAccessor (&Tcp::m_defaultAdvWin), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultAdvWin), MakeUintegerChecker ()) .AddAttribute ("DefaultSlowStartThreshold", "Default TCP slow start threshold (bytes)", UintegerValue (0xffff), - MakeUintegerAccessor (&Tcp::m_defaultSsThresh), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultSsThresh), MakeUintegerChecker ()) .AddAttribute ("DefaultTxBufferSize", "Default TCP maximum transmit buffer size (bytes)", UintegerValue (0xffffffffl), - MakeUintegerAccessor (&Tcp::m_defaultTxBuffer), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultTxBuffer), MakeUintegerChecker ()) .AddAttribute ("DefaultRxBufferSize", "Default TCP maximum receive buffer size (bytes)", UintegerValue (0xffffffffl), - MakeUintegerAccessor (&Tcp::m_defaultRxBuffer), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultRxBuffer), MakeUintegerChecker ()) .AddAttribute ("DefaultInitialCongestionWindowSize", "Default TCP initial congestion window size (segments)", UintegerValue (1), - MakeUintegerAccessor (&Tcp::m_defaultInitialCwnd), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultInitialCwnd), MakeUintegerChecker ()) .AddAttribute ("DefaultConnTimeout", "Default TCP retransmission timeout when opening connection (seconds)", UintegerValue (3), - MakeUintegerAccessor (&Tcp::m_defaultConnTimeout), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnTimeout), MakeUintegerChecker ()) .AddAttribute ("DefaultConnCount", "Default number of connection attempts (SYN retransmissions) before returning failure", UintegerValue (6), - MakeUintegerAccessor (&Tcp::m_defaultConnCount), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnCount), MakeUintegerChecker ()) .AddAttribute ("DefaultDelAckTimeout", "Default timeout value for TCP delayed acks, in seconds", DoubleValue (0.2), - MakeDoubleAccessor (&Tcp::m_defaultDelAckTimeout), + MakeDoubleAccessor (&TcpSocketFactory::m_defaultDelAckTimeout), MakeDoubleChecker ()) .AddAttribute ("DefaultDelAckCount", "Default number of packets to wait before sending a TCP ack", UintegerValue (2), - MakeUintegerAccessor (&Tcp::m_defaultDelAckCount), + MakeUintegerAccessor (&TcpSocketFactory::m_defaultDelAckCount), MakeUintegerChecker ()) ; return tid; } uint32_t -Tcp::GetDefaultSegSize (void) const +TcpSocketFactory::GetDefaultSegSize (void) const { return m_defaultSegSize; } uint32_t -Tcp::GetDefaultAdvWin (void) const +TcpSocketFactory::GetDefaultAdvWin (void) const { return m_defaultAdvWin; } uint32_t -Tcp::GetDefaultSsThresh (void) const +TcpSocketFactory::GetDefaultSsThresh (void) const { return m_defaultSsThresh; } uint32_t -Tcp::GetDefaultTxBuffer (void) const +TcpSocketFactory::GetDefaultTxBuffer (void) const { return m_defaultTxBuffer; } uint32_t -Tcp::GetDefaultRxBuffer (void) const +TcpSocketFactory::GetDefaultRxBuffer (void) const { return m_defaultRxBuffer; } uint32_t -Tcp::GetDefaultInitialCwnd (void) const +TcpSocketFactory::GetDefaultInitialCwnd (void) const { return m_defaultInitialCwnd; } uint32_t -Tcp::GetDefaultConnTimeout (void) const +TcpSocketFactory::GetDefaultConnTimeout (void) const { return m_defaultConnTimeout; } uint32_t -Tcp::GetDefaultConnCount (void) const +TcpSocketFactory::GetDefaultConnCount (void) const { return m_defaultConnCount; } double -Tcp::GetDefaultDelAckTimeout (void) const +TcpSocketFactory::GetDefaultDelAckTimeout (void) const { return m_defaultDelAckTimeout; } uint32_t -Tcp::GetDefaultDelAckCount (void) const +TcpSocketFactory::GetDefaultDelAckCount (void) const { return m_defaultDelAckCount; } diff --git a/src/node/tcp.h b/src/node/tcp-socket-factory.h similarity index 89% rename from src/node/tcp.h rename to src/node/tcp-socket-factory.h index 91923cb62..9d98eafff 100644 --- a/src/node/tcp.h +++ b/src/node/tcp-socket-factory.h @@ -17,8 +17,8 @@ * * Author: Raj Bhattacharjea */ -#ifndef TCP_H -#define TCP_H +#ifndef TCP_SOCKET_FACTORY_H +#define TCP_SOCKET_FACTORY_H #include "socket-factory.h" @@ -34,13 +34,14 @@ 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); @@ -74,4 +75,4 @@ private: } // namespace ns3 -#endif /* TCP_H */ +#endif /* TCP_SOCKET_FACTORY_H */ diff --git a/src/node/wscript b/src/node/wscript index 3f35ca216..6d0974263 100644 --- a/src/node/wscript +++ b/src/node/wscript @@ -27,7 +27,7 @@ def build(bld): 'packet-socket.cc', 'udp-socket.cc', 'udp-socket-factory.cc', - 'tcp.cc', + 'tcp-socket-factory.cc', 'ipv4.cc', 'application.cc', 'simple-channel.cc', @@ -60,7 +60,7 @@ def build(bld): 'packet-socket-factory.h', 'udp-socket.h', 'udp-socket-factory.h', - 'tcp.h', + 'tcp-socket-factory.h', 'ipv4.h', 'application.h', 'simple-channel.h', diff --git a/utils/print-introspected-doxygen.cc b/utils/print-introspected-doxygen.cc index c714d5ee7..24f8b944f 100644 --- a/utils/print-introspected-doxygen.cc +++ b/utils/print-introspected-doxygen.cc @@ -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"); From c21d79a87b6fab8ef438973d3b03e30ac95a794f Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 20 May 2008 12:27:30 -0700 Subject: [PATCH 3/6] change TcpImpl to TcpSocketFactoryImpl --- src/internet-node/internet-stack.cc | 8 ++++---- .../{tcp-impl.cc => tcp-socket-factory-impl.cc} | 12 ++++++------ .../{tcp-impl.h => tcp-socket-factory-impl.h} | 12 ++++++------ src/internet-node/wscript | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) rename src/internet-node/{tcp-impl.cc => tcp-socket-factory-impl.cc} (80%) rename src/internet-node/{tcp-impl.h => tcp-socket-factory-impl.h} (86%) diff --git a/src/internet-node/internet-stack.cc b/src/internet-node/internet-stack.cc index 8aaab0509..5b8f3bfd1 100644 --- a/src/internet-node/internet-stack.cc +++ b/src/internet-node/internet-stack.cc @@ -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) ipv4L4Demux->Insert (tcp); Ptr udpFactory = CreateObject (); - Ptr tcpImpl = CreateObject (); + Ptr tcpFactory = CreateObject (); Ptr ipv4Impl = CreateObject (); 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); } diff --git a/src/internet-node/tcp-impl.cc b/src/internet-node/tcp-socket-factory-impl.cc similarity index 80% rename from src/internet-node/tcp-impl.cc rename to src/internet-node/tcp-socket-factory-impl.cc index dc6d69f17..ef806adf4 100644 --- a/src/internet-node/tcp-impl.cc +++ b/src/internet-node/tcp-socket-factory-impl.cc @@ -17,35 +17,35 @@ * * Author: Raj Bhattacharjea */ -#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 tcp) +TcpSocketFactoryImpl::SetTcp (Ptr tcp) { m_tcp = tcp; } Ptr -TcpImpl::CreateSocket (void) +TcpSocketFactoryImpl::CreateSocket (void) { return m_tcp->CreateSocket (); } void -TcpImpl::DoDispose (void) +TcpSocketFactoryImpl::DoDispose (void) { m_tcp = 0; TcpSocketFactory::DoDispose (); diff --git a/src/internet-node/tcp-impl.h b/src/internet-node/tcp-socket-factory-impl.h similarity index 86% rename from src/internet-node/tcp-impl.h rename to src/internet-node/tcp-socket-factory-impl.h index 647dd6372..38bf123a2 100644 --- a/src/internet-node/tcp-impl.h +++ b/src/internet-node/tcp-socket-factory-impl.h @@ -17,8 +17,8 @@ * * Author: Raj Bhattacharjea */ -#ifndef TCP_IMPL_H -#define TCP_IMPL_H +#ifndef TCP_SOCKET_FACTORY_IMPL_H +#define TCP_SOCKET_FACTORY_IMPL_H #include "ns3/tcp-socket-factory.h" #include "ns3/ptr.h" @@ -39,11 +39,11 @@ class TcpL4Protocol; * * Most of the logic is in class ns3::TcpSocketImpl. */ -class TcpImpl : public TcpSocketFactory +class TcpSocketFactoryImpl : public TcpSocketFactory { public: - TcpImpl (); - virtual ~TcpImpl (); + TcpSocketFactoryImpl (); + virtual ~TcpSocketFactoryImpl (); void SetTcp (Ptr tcp); @@ -57,4 +57,4 @@ private: } // namespace ns3 -#endif /* TCP_IMPL_H */ +#endif /* TCP_SOCKET_FACTORY_IMPL_H */ diff --git a/src/internet-node/wscript b/src/internet-node/wscript index 26c5d6a64..20f69c7b2 100644 --- a/src/internet-node/wscript +++ b/src/internet-node/wscript @@ -29,7 +29,7 @@ def build(bld): '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', From 49d5404bfcc494140e29380a689a23e2008d36ed Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 20 May 2008 12:36:05 -0700 Subject: [PATCH 4/6] Add abstract base class TcpSocket --- src/internet-node/tcp-socket-impl.cc | 2 +- src/internet-node/tcp-socket-impl.h | 4 ++-- src/node/wscript | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/internet-node/tcp-socket-impl.cc b/src/internet-node/tcp-socket-impl.cc index 5edc19109..26ad2dc0a 100644 --- a/src/internet-node/tcp-socket-impl.cc +++ b/src/internet-node/tcp-socket-impl.cc @@ -90,7 +90,7 @@ TcpSocketImpl::GetTypeId () } TcpSocketImpl::TcpSocketImpl(const TcpSocketImpl& sock) - : Socket(sock), //copy the base class callbacks + : TcpSocket(sock), //copy the base class callbacks m_skipRetxResched (sock.m_skipRetxResched), m_dupAckCount (sock.m_dupAckCount), m_delAckCount (0), diff --git a/src/internet-node/tcp-socket-impl.h b/src/internet-node/tcp-socket-impl.h index e2f9d75f6..0171f2e6d 100644 --- a/src/internet-node/tcp-socket-impl.h +++ b/src/internet-node/tcp-socket-impl.h @@ -24,7 +24,7 @@ #include #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,7 +42,7 @@ class Packet; class TcpL4Protocol; class TcpHeader; -class TcpSocketImpl : public Socket +class TcpSocketImpl : public TcpSocket { public: static TypeId GetTypeId (void); diff --git a/src/node/wscript b/src/node/wscript index 6d0974263..2f91f1e2a 100644 --- a/src/node/wscript +++ b/src/node/wscript @@ -27,6 +27,7 @@ def build(bld): 'packet-socket.cc', 'udp-socket.cc', 'udp-socket-factory.cc', + 'tcp-socket.cc', 'tcp-socket-factory.cc', 'ipv4.cc', 'application.cc', @@ -60,6 +61,7 @@ def build(bld): 'packet-socket-factory.h', 'udp-socket.h', 'udp-socket-factory.h', + 'tcp-socket.h', 'tcp-socket-factory.h', 'ipv4.h', 'application.h', From ef99300effe286f17f82d781cd5b19187b60f6e2 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Tue, 20 May 2008 12:55:23 -0700 Subject: [PATCH 5/6] Add missing files --- src/node/tcp-socket.cc | 72 +++++++++++++++++++++++++++++++++++++ src/node/tcp-socket.h | 81 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/node/tcp-socket.cc create mode 100644 src/node/tcp-socket.h diff --git a/src/node/tcp-socket.cc b/src/node/tcp-socket.cc new file mode 100644 index 000000000..3d3a83d67 --- /dev/null +++ b/src/node/tcp-socket.cc @@ -0,0 +1,72 @@ +/* -*- 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 + */ + +#include "ns3/object.h" +#include "ns3/log.h" +#include "ns3/uinteger.h" +#include "ns3/trace-source-accessor.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 () +#if 0 + .AddAttribute ("RcvBufSize", + "TcpSocket maximum receive buffer size (bytes)", + UintegerValue (0xffffffffl), + MakeUintegerAccessor (&TcpSocket::GetRcvBufSize, + &TcpSocket::SetRcvBufSize), + MakeUintegerChecker ()) + .AddAttribute ("IpTtl", + "socket-specific TTL for unicast IP packets (if non-zero)", + UintegerValue (0), + MakeUintegerAccessor (&TcpSocket::GetIpTtl, + &TcpSocket::SetIpTtl), + MakeUintegerChecker ()) + .AddAttribute ("IpMulticastTtl", + "socket-specific TTL for multicast IP packets (if non-zero)", + UintegerValue (0), + MakeUintegerAccessor (&TcpSocket::GetIpMulticastTtl, + &TcpSocket::SetIpMulticastTtl), + MakeUintegerChecker ()) +#endif + ; + return tid; +} + +TcpSocket::TcpSocket () +{ + NS_LOG_FUNCTION_NOARGS (); +} + +TcpSocket::~TcpSocket () +{ + NS_LOG_FUNCTION_NOARGS (); +} + +}; // namespace ns3 diff --git a/src/node/tcp-socket.h b/src/node/tcp-socket.h new file mode 100644 index 000000000..bc48ebf93 --- /dev/null +++ b/src/node/tcp-socket.h @@ -0,0 +1,81 @@ +/* -*- 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 + * Mathieu Lacage + */ + +#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" + +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 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 p) = 0; + virtual uint32_t GetTxAvailable (void) const = 0; + virtual int SendTo (Ptr p, const Address &address) = 0; + virtual Ptr Recv (uint32_t maxSize, uint32_t flags) = 0; + virtual uint32_t GetRxAvailable (void) const = 0; + +public: +#if 0 + // Indirect the attribute setting and getting through private virtual methods + virtual void SetRcvBufSize (uint32_t size) = 0; + virtual uint32_t GetRcvBufSize (void) const = 0; + virtual void SetIpTtl (uint32_t ipTtl) = 0; + virtual uint32_t GetIpTtl (void) const = 0; + virtual void SetIpMulticastTtl (uint32_t ipTtl) = 0; + virtual uint32_t GetIpMulticastTtl (void) const = 0; +#endif + +}; + +} //namespace ns3 + +#endif /* TCP_SOCKET_H */ + + From 72d054a8675305dd5106ec0bfc15b60e8747d2d0 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 21 May 2008 00:38:49 -0700 Subject: [PATCH 6/6] Move Tcp attributes from factory to TcpSocket --- src/internet-node/tcp-socket-impl.cc | 181 +++++++++++++++++++-------- src/internet-node/tcp-socket-impl.h | 36 ++++-- src/internet-node/udp-socket-impl.h | 2 +- src/node/tcp-socket-factory.cc | 105 +--------------- src/node/tcp-socket-factory.h | 23 ---- src/node/tcp-socket.cc | 66 ++++++++-- src/node/tcp-socket.h | 27 ++-- src/node/udp-socket.h | 2 +- 8 files changed, 234 insertions(+), 208 deletions(-) diff --git a/src/internet-node/tcp-socket-impl.cc b/src/internet-node/tcp-socket-impl.cc index 26ad2dc0a..57c0e0d09 100644 --- a/src/internet-node/tcp-socket-impl.cc +++ b/src/internet-node/tcp-socket-impl.cc @@ -48,7 +48,7 @@ TypeId TcpSocketImpl::GetTypeId () { static TypeId tid = TypeId("ns3::TcpSocketImpl") - .SetParent () + .SetParent () .AddTraceSource ("CongestionWindow", "The TCP connection's congestion window", MakeTraceSourceAccessor (&TcpSocketImpl::m_cWnd)) @@ -81,12 +81,9 @@ TcpSocketImpl::GetTypeId () m_rtt (0), m_lastMeasuredRtt (Seconds(0.0)), m_rxAvailable (0), - m_sndBufLimit (0xffffffff), - m_rcvBufLimit (0xffffffff), m_wouldBlock (false) { NS_LOG_FUNCTION (this); - } TcpSocketImpl::TcpSocketImpl(const TcpSocketImpl& sock) @@ -95,7 +92,7 @@ TcpSocketImpl::TcpSocketImpl(const TcpSocketImpl& sock) m_dupAckCount (sock.m_dupAckCount), m_delAckCount (0), m_delAckMaxCount (sock.m_delAckMaxCount), - m_delAckTimout (sock.m_delAckTimout), + m_delAckTimeout (sock.m_delAckTimeout), m_endPoint (0), m_node (sock.m_node), m_tcp (sock.m_tcp), @@ -128,9 +125,7 @@ TcpSocketImpl::TcpSocketImpl(const TcpSocketImpl& sock) m_lastMeasuredRtt (Seconds(0.0)), m_cnTimeout (sock.m_cnTimeout), m_cnCount (sock.m_cnCount), - m_rxAvailable (0), - m_sndBufLimit (0xffffffff), - m_rcvBufLimit (0xffffffff) + m_rxAvailable (0) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC("Invoked the copy constructor"); @@ -176,17 +171,9 @@ void TcpSocketImpl::SetNode (Ptr node) { m_node = node; - Ptr t = node->GetObject (); - m_segmentSize = t->GetDefaultSegSize (); - m_rxWindowSize = t->GetDefaultAdvWin (); - m_advertisedWindowSize = t->GetDefaultAdvWin (); - m_cWnd = t->GetDefaultInitialCwnd () * m_segmentSize; - m_ssThresh = t->GetDefaultSsThresh (); - m_initialCWnd = t->GetDefaultInitialCwnd (); - m_cnTimeout = Seconds (t->GetDefaultConnTimeout ()); - m_cnCount = t->GetDefaultConnCount (); - m_delAckTimout = Seconds(t->GetDefaultDelAckTimeout ()); - m_delAckMaxCount = t->GetDefaultDelAckCount (); + // Initialize some variables + m_cWnd = m_initialCWnd * m_segmentSize; + m_rxWindowSize = m_advertisedWindowSize; } void @@ -452,12 +439,12 @@ TcpSocketImpl::GetTxAvailable (void) const { uint32_t unAckedDataSize = m_pendingData->SizeFromSeq (m_firstPendingSequence, m_highestRxAck); - NS_ASSERT (m_sndBufLimit >= unAckedDataSize); //else a logical error - return m_sndBufLimit-unAckedDataSize; + NS_ASSERT (m_sndBufSize >= unAckedDataSize); //else a logical error + return m_sndBufSize-unAckedDataSize; } else { - return m_sndBufLimit; + return m_sndBufSize; } } @@ -500,34 +487,6 @@ TcpSocketImpl::GetRxAvailable (void) const return m_rxAvailable; } -void -TcpSocketImpl::SetSndBuf (uint32_t size) -{ - NS_LOG_FUNCTION_NOARGS (); - m_sndBufLimit = size; -} - -uint32_t -TcpSocketImpl::GetSndBuf (void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_sndBufLimit; -} - -void -TcpSocketImpl::SetRcvBuf (uint32_t size) -{ - NS_LOG_FUNCTION_NOARGS (); - m_rcvBufLimit = size; -} - -uint32_t -TcpSocketImpl::GetRcvBuf (void) const -{ - NS_LOG_FUNCTION_NOARGS (); - return m_rcvBufLimit; -} - void TcpSocketImpl::ForwardUp (Ptr packet, Ipv4Address ipv4, uint16_t port) { @@ -1153,7 +1112,7 @@ void TcpSocketImpl::NewRx (Ptr p, } else { - m_delAckEvent = Simulator::Schedule (m_delAckTimout, &TcpSocketImpl::DelAckTimeout, this); + m_delAckEvent = Simulator::Schedule (m_delAckTimeout, &TcpSocketImpl::DelAckTimeout, this); } } @@ -1351,4 +1310,124 @@ void TcpSocketImpl::Retransmit () m_remoteAddress); } +void +TcpSocketImpl::SetSndBufSize (uint32_t size) +{ + m_sndBufSize = size; +} + +uint32_t +TcpSocketImpl::GetSndBufSize (void) const +{ + return m_sndBufSize; +} + +void +TcpSocketImpl::SetRcvBufSize (uint32_t size) +{ + m_rcvBufSize = size; +} + +uint32_t +TcpSocketImpl::GetRcvBufSize (void) const +{ + return m_rcvBufSize; +} + +void +TcpSocketImpl::SetSegSize (uint32_t size) +{ + m_segmentSize = size; +} + +uint32_t +TcpSocketImpl::GetSegSize (void) const +{ + return m_segmentSize; +} + +void +TcpSocketImpl::SetAdvWin (uint32_t window) +{ + m_advertisedWindowSize = window; +} + +uint32_t +TcpSocketImpl::GetAdvWin (void) const +{ + return m_advertisedWindowSize; +} + +void +TcpSocketImpl::SetSSThresh (uint32_t threshold) +{ + m_ssThresh = threshold; +} + +uint32_t +TcpSocketImpl::GetSSThresh (void) const +{ + return m_ssThresh; +} + +void +TcpSocketImpl::SetInitialCwnd (uint32_t cwnd) +{ + m_initialCWnd = cwnd; +} + +uint32_t +TcpSocketImpl::GetInitialCwnd (void) const +{ + return m_initialCWnd; +} + +void +TcpSocketImpl::SetConnTimeout (Time timeout) +{ + m_cnTimeout = timeout; +} + +Time +TcpSocketImpl::GetConnTimeout (void) const +{ + return m_cnTimeout; +} + +void +TcpSocketImpl::SetConnCount (uint32_t count) +{ + m_cnCount = count; +} + +uint32_t +TcpSocketImpl::GetConnCount (void) const +{ + return m_cnCount; +} + +void +TcpSocketImpl::SetDelAckTimeout (Time timeout) +{ + m_delAckTimeout = timeout; +} + +Time +TcpSocketImpl::GetDelAckTimeout (void) const +{ + return m_delAckTimeout; +} + +void +TcpSocketImpl::SetDelAckMaxCount (uint32_t count) +{ + m_delAckMaxCount = count; +} + +uint32_t +TcpSocketImpl::GetDelAckMaxCount (void) const +{ + return m_delAckMaxCount; +} + }//namespace ns3 diff --git a/src/internet-node/tcp-socket-impl.h b/src/internet-node/tcp-socket-impl.h index 0171f2e6d..7adc8669e 100644 --- a/src/internet-node/tcp-socket-impl.h +++ b/src/internet-node/tcp-socket-impl.h @@ -74,12 +74,6 @@ public: virtual Ptr 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 @@ -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 m_node; @@ -187,9 +203,11 @@ private: std::queue > 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 diff --git a/src/internet-node/udp-socket-impl.h b/src/internet-node/udp-socket-impl.h index 71bded586..42047a5d0 100644 --- a/src/internet-node/udp-socket-impl.h +++ b/src/internet-node/udp-socket-impl.h @@ -64,6 +64,7 @@ public: virtual Ptr 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); diff --git a/src/node/tcp-socket-factory.cc b/src/node/tcp-socket-factory.cc index 40d1caa66..ca1ae25b8 100644 --- a/src/node/tcp-socket-factory.cc +++ b/src/node/tcp-socket-factory.cc @@ -30,111 +30,8 @@ TcpSocketFactory::GetTypeId (void) { static TypeId tid = TypeId ("ns3::TcpSocketFactory") .SetParent () - .AddAttribute ("DefaultSegmentSize", - "Default TCP maximum segment size in bytes (may be adjusted based on MTU discovery)", - UintegerValue (536), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultSegSize), - MakeUintegerChecker ()) - .AddAttribute ("DefaultAdvertisedWindowSize", - "Default TCP advertised window size (bytes)", - UintegerValue (0xffff), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultAdvWin), - MakeUintegerChecker ()) - .AddAttribute ("DefaultSlowStartThreshold", - "Default TCP slow start threshold (bytes)", - UintegerValue (0xffff), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultSsThresh), - MakeUintegerChecker ()) - .AddAttribute ("DefaultTxBufferSize", - "Default TCP maximum transmit buffer size (bytes)", - UintegerValue (0xffffffffl), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultTxBuffer), - MakeUintegerChecker ()) - .AddAttribute ("DefaultRxBufferSize", - "Default TCP maximum receive buffer size (bytes)", - UintegerValue (0xffffffffl), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultRxBuffer), - MakeUintegerChecker ()) - .AddAttribute ("DefaultInitialCongestionWindowSize", - "Default TCP initial congestion window size (segments)", - UintegerValue (1), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultInitialCwnd), - MakeUintegerChecker ()) - .AddAttribute ("DefaultConnTimeout", - "Default TCP retransmission timeout when opening connection (seconds)", - UintegerValue (3), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnTimeout), - MakeUintegerChecker ()) - .AddAttribute ("DefaultConnCount", - "Default number of connection attempts (SYN retransmissions) before returning failure", - UintegerValue (6), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultConnCount), - MakeUintegerChecker ()) - .AddAttribute ("DefaultDelAckTimeout", - "Default timeout value for TCP delayed acks, in seconds", - DoubleValue (0.2), - MakeDoubleAccessor (&TcpSocketFactory::m_defaultDelAckTimeout), - MakeDoubleChecker ()) - .AddAttribute ("DefaultDelAckCount", - "Default number of packets to wait before sending a TCP ack", - UintegerValue (2), - MakeUintegerAccessor (&TcpSocketFactory::m_defaultDelAckCount), - MakeUintegerChecker ()) - ; + ; return tid; } -uint32_t -TcpSocketFactory::GetDefaultSegSize (void) const -{ - return m_defaultSegSize; -} -uint32_t -TcpSocketFactory::GetDefaultAdvWin (void) const -{ - return m_defaultAdvWin; -} -uint32_t -TcpSocketFactory::GetDefaultSsThresh (void) const -{ - return m_defaultSsThresh; -} -uint32_t -TcpSocketFactory::GetDefaultTxBuffer (void) const -{ - return m_defaultTxBuffer; -} -uint32_t -TcpSocketFactory::GetDefaultRxBuffer (void) const -{ - return m_defaultRxBuffer; -} -uint32_t -TcpSocketFactory::GetDefaultInitialCwnd (void) const -{ - return m_defaultInitialCwnd; -} -uint32_t -TcpSocketFactory::GetDefaultConnTimeout (void) const -{ - return m_defaultConnTimeout; -} -uint32_t -TcpSocketFactory::GetDefaultConnCount (void) const -{ - return m_defaultConnCount; -} - -double -TcpSocketFactory::GetDefaultDelAckTimeout (void) const -{ - return m_defaultDelAckTimeout; -} - -uint32_t -TcpSocketFactory::GetDefaultDelAckCount (void) const -{ - return m_defaultDelAckCount; -} - } // namespace ns3 diff --git a/src/node/tcp-socket-factory.h b/src/node/tcp-socket-factory.h index 9d98eafff..35909cb54 100644 --- a/src/node/tcp-socket-factory.h +++ b/src/node/tcp-socket-factory.h @@ -48,29 +48,6 @@ public: virtual Ptr 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 diff --git a/src/node/tcp-socket.cc b/src/node/tcp-socket.cc index 3d3a83d67..1dd3d4057 100644 --- a/src/node/tcp-socket.cc +++ b/src/node/tcp-socket.cc @@ -21,7 +21,9 @@ #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"); @@ -35,26 +37,66 @@ TcpSocket::GetTypeId (void) { static TypeId tid = TypeId ("ns3::TcpSocket") .SetParent () -#if 0 + .AddAttribute ("SndBufSize", + "TcpSocket maximum transmit buffer size (bytes)", + UintegerValue (0xffffffffl), + MakeUintegerAccessor (&TcpSocket::GetSndBufSize, + &TcpSocket::SetSndBufSize), + MakeUintegerChecker ()) .AddAttribute ("RcvBufSize", "TcpSocket maximum receive buffer size (bytes)", UintegerValue (0xffffffffl), MakeUintegerAccessor (&TcpSocket::GetRcvBufSize, &TcpSocket::SetRcvBufSize), MakeUintegerChecker ()) - .AddAttribute ("IpTtl", - "socket-specific TTL for unicast IP packets (if non-zero)", - UintegerValue (0), - MakeUintegerAccessor (&TcpSocket::GetIpTtl, - &TcpSocket::SetIpTtl), + .AddAttribute ("SegmentSize", + "TCP maximum segment size in bytes (may be adjusted based on MTU discovery)", + UintegerValue (536), + MakeUintegerAccessor (&TcpSocket::GetSegSize, + &TcpSocket::SetSegSize), MakeUintegerChecker ()) - .AddAttribute ("IpMulticastTtl", - "socket-specific TTL for multicast IP packets (if non-zero)", - UintegerValue (0), - MakeUintegerAccessor (&TcpSocket::GetIpMulticastTtl, - &TcpSocket::SetIpMulticastTtl), + .AddAttribute ("AdvertisedWindowSize", + "TCP advertised window size (bytes)", + UintegerValue (0xffff), + MakeUintegerAccessor (&TcpSocket::GetAdvWin, + &TcpSocket::SetAdvWin), + MakeUintegerChecker ()) + .AddAttribute ("SlowStartThreshold", + "TCP slow start threshold (bytes)", + UintegerValue (0xffff), + MakeUintegerAccessor (&TcpSocket::GetSSThresh, + &TcpSocket::SetSSThresh), + MakeUintegerChecker ()) + .AddAttribute ("InitialCwnd", + "TCP initial congestion window size (segments)", + UintegerValue (1), + MakeUintegerAccessor (&TcpSocket::GetInitialCwnd, + &TcpSocket::SetInitialCwnd), + MakeUintegerChecker ()) + .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 ()) + .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 ()) -#endif ; return tid; } diff --git a/src/node/tcp-socket.h b/src/node/tcp-socket.h index bc48ebf93..9092474f4 100644 --- a/src/node/tcp-socket.h +++ b/src/node/tcp-socket.h @@ -28,6 +28,7 @@ #include "ns3/callback.h" #include "ns3/ptr.h" #include "ns3/object.h" +#include "ns3/nstime.h" namespace ns3 { @@ -61,16 +62,28 @@ public: virtual Ptr Recv (uint32_t maxSize, uint32_t flags) = 0; virtual uint32_t GetRxAvailable (void) const = 0; -public: -#if 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 SetIpTtl (uint32_t ipTtl) = 0; - virtual uint32_t GetIpTtl (void) const = 0; - virtual void SetIpMulticastTtl (uint32_t ipTtl) = 0; - virtual uint32_t GetIpMulticastTtl (void) const = 0; -#endif + 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; }; diff --git a/src/node/udp-socket.h b/src/node/udp-socket.h index 5f20fd7c0..1c81916c2 100644 --- a/src/node/udp-socket.h +++ b/src/node/udp-socket.h @@ -61,7 +61,7 @@ public: virtual Ptr 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;