nsc: move nsc glue code from nsc-tcp-l4-protocol to node/nsc-glue.cc.
known problems:
- sim_interface.h is duplicated
- nsc-glue.cc adds hooks in node.cc, "hijacks" incoming packets
- nsc-glue exports NSCs INetStack (instead of wrapping it completely)
- nsc-tcp-l4-protocol and nsc-tcp-socket-impl make calls into nsc-glue
- nsc-tcp-socket-impl should really be "nsc-socket-core" (or something
like that)
needs fixing on nsc side:
- no support for multiple interfaces yet (also not yet supported
on nsc side)
- nsc initialisation still tied to IP (Adding an Interface and assigning the
IP address is a single step; it should be separate)
maybe there is more.
There is a NSC_NEXT define in nsc-glue.h, its main purpose is to flag
the places where the NSC API needs to be adapted to support multiple
interfaces in nsc.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation;
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #ifndef NSC_TCP_SOCKET_IMPL_H
17 #define NSC_TCP_SOCKET_IMPL_H
23 #include "ns3/callback.h"
24 #include "ns3/traced-value.h"
25 #include "ns3/tcp-socket.h"
27 #include "ns3/ipv4-address.h"
28 #include "ns3/inet-socket-address.h"
29 #include "ns3/event-id.h"
30 #include "tcp-typedefs.h"
31 #include "pending-data.h"
32 #include "sequence-number.h"
33 #include "rtt-estimator.h"
35 class INetStreamSocket;
41 class NscTcpL4Protocol;
48 * \brief Socket logic for the NSC TCP sockets.
50 * Most of the TCP internal
51 * logic is handled by the NSC tcp library itself; this class maps ns3::Socket
52 * calls to the NSC TCP library.
54 class NscTcpSocketImpl : public TcpSocket
57 static TypeId GetTypeId (void);
59 * Create an unbound tcp socket.
62 NscTcpSocketImpl (const NscTcpSocketImpl& sock);
63 virtual ~NscTcpSocketImpl ();
65 void SetNode (Ptr<Node> node);
66 void SetTcp (Ptr<NscTcpL4Protocol> tcp);
67 void SetRtt (Ptr<RttEstimator> rtt);
69 virtual enum SocketErrno GetErrno (void) const;
70 virtual Ptr<Node> GetNode (void) const;
71 virtual int Bind (void);
72 virtual int Bind (const Address &address);
73 virtual int Close (void);
74 virtual int ShutdownSend (void);
75 virtual int ShutdownRecv (void);
76 virtual int Connect(const Address &address);
77 virtual int Listen(void);
78 virtual uint32_t GetTxAvailable (void) const;
79 virtual int Send (Ptr<Packet> p, uint32_t flags);
80 virtual int SendTo(Ptr<Packet> p, uint32_t flags, const Address &toAddress);
81 virtual uint32_t GetRxAvailable (void) const;
82 virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
83 virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
84 Address &fromAddress);
85 virtual int GetSockName (Address &address) const;
90 // invoked by Tcp class
91 int FinishBind (void);
92 void ForwardUp (Ptr<Packet> p, Ipv4Address ipv4, uint16_t port);
95 bool SendPendingData(void);
96 bool ReadPendingData(void);
98 void CompleteFork(void);
99 void ConnectionSucceeded();
102 // XXX This should be virtual and overridden
103 Ptr<NscTcpSocketImpl> Copy ();
106 virtual void SetSndBufSize (uint32_t size);
107 virtual uint32_t GetSndBufSize (void) const;
108 virtual void SetRcvBufSize (uint32_t size);
109 virtual uint32_t GetRcvBufSize (void) const;
110 virtual void SetSegSize (uint32_t size);
111 virtual uint32_t GetSegSize (void) const;
112 virtual void SetAdvWin (uint32_t window);
113 virtual uint32_t GetAdvWin (void) const;
114 virtual void SetSSThresh (uint32_t threshold);
115 virtual uint32_t GetSSThresh (void) const;
116 virtual void SetInitialCwnd (uint32_t cwnd);
117 virtual uint32_t GetInitialCwnd (void) const;
118 virtual void SetConnTimeout (Time timeout);
119 virtual Time GetConnTimeout (void) const;
120 virtual void SetConnCount (uint32_t count);
121 virtual uint32_t GetConnCount (void) const;
122 virtual void SetDelAckTimeout (Time timeout);
123 virtual Time GetDelAckTimeout (void) const;
124 virtual void SetDelAckMaxCount (uint32_t count);
125 virtual uint32_t GetDelAckMaxCount (void) const;
127 enum Socket::SocketErrno GetNativeNs3Errno(int err) const;
128 uint32_t m_delAckMaxCount;
129 Time m_delAckTimeout;
131 Ipv4EndPoint *m_endPoint;
133 Ptr<NscTcpL4Protocol> m_tcp;
134 Ipv4Address m_remoteAddress;
135 uint16_t m_remotePort;
136 //these two are so that the socket/endpoint cloning works
137 Ipv4Address m_localAddress;
138 uint16_t m_localPort;
139 InetSocketAddress m_peerAddress;
140 enum SocketErrno m_errno;
145 //manage the state infomation
149 //needed to queue data when in SYN_SENT state
150 std::queue<Ptr<Packet> > m_txBuffer;
151 uint32_t m_txBufferSize;
154 uint32_t m_segmentSize; //SegmentSize
155 uint32_t m_rxWindowSize;
156 uint32_t m_advertisedWindowSize; //Window to advertise
157 TracedValue<uint32_t> m_cWnd; //Congestion window
158 uint32_t m_ssThresh; //Slow Start Threshold
159 uint32_t m_initialCWnd; //Initial cWnd value
161 // Round trip time estimation
162 Ptr<RttEstimator> m_rtt;
163 Time m_lastMeasuredRtt;
165 // Timer-related members
169 // Temporary queue for delivering data to application
170 std::queue<Ptr<Packet> > m_deliveryQueue;
171 uint32_t m_rxAvailable;
172 INetStreamSocket* m_nscTcpSocket;
175 uint32_t m_sndBufSize; // buffer limit for the outgoing queue
176 uint32_t m_rcvBufSize; // maximum receive socket buffer size
181 #endif /* NSC_TCP_SOCKET_IMPL_H */