A Discrete-Event Network Simulator
API
tcp-l4-protocol.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007 Georgia Tech Research Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Raj Bhattacharjea <raj.b@gatech.edu>
19 */
20
21#ifndef TCP_L4_PROTOCOL_H
22#define TCP_L4_PROTOCOL_H
23
24#include <stdint.h>
25
26#include "ns3/ipv4-address.h"
27#include "ns3/ipv6-address.h"
28#include "ns3/sequence-number.h"
29#include "ip-l4-protocol.h"
30
31
32namespace ns3 {
33
34class Node;
35class Socket;
36class TcpHeader;
37class Ipv4EndPointDemux;
38class Ipv6EndPointDemux;
39class Ipv4Interface;
40class TcpSocketBase;
41class Ipv4EndPoint;
42class Ipv6EndPoint;
43class NetDevice;
44
45
81public:
86 static TypeId GetTypeId (void);
87 static const uint8_t PROT_NUMBER;
88
90 virtual ~TcpL4Protocol ();
91
92 // Delete copy constructor and assignment operator to avoid misuse
93 TcpL4Protocol (const TcpL4Protocol &) = delete;
95
100 void SetNode (Ptr<Node> node);
101
102 // NOTE: API from here should not be removed, only added. Be backward-compatible!
103
111
123 Ptr<Socket> CreateSocket (TypeId congestionTypeId, TypeId recoveryTypeId);
124
133 Ptr<Socket> CreateSocket (TypeId congestionTypeId);
134
139 Ipv4EndPoint *Allocate (void);
152 Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice, uint16_t port);
160 Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice, Ipv4Address address, uint16_t port);
170 Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice,
171 Ipv4Address localAddress, uint16_t localPort,
172 Ipv4Address peerAddress, uint16_t peerPort);
177 Ipv6EndPoint *Allocate6 (void);
190 Ipv6EndPoint *Allocate6 (Ptr<NetDevice> boundNetDevice, uint16_t port);
198 Ipv6EndPoint *Allocate6 (Ptr<NetDevice> boundNetDevice, Ipv6Address address, uint16_t port);
208 Ipv6EndPoint *Allocate6 (Ptr<NetDevice> boundNetDevice,
209 Ipv6Address localAddress, uint16_t localPort,
210 Ipv6Address peerAddress, uint16_t peerPort);
211
221 void SendPacket (Ptr<Packet> pkt, const TcpHeader &outgoing,
222 const Address &saddr, const Address &daddr,
223 Ptr<NetDevice> oif = 0) const;
224
232 void AddSocket (Ptr<TcpSocketBase> socket);
233
240 bool RemoveSocket (Ptr<TcpSocketBase> socket);
241
246 void DeAllocate (Ipv4EndPoint *endPoint);
251 void DeAllocate (Ipv6EndPoint *endPoint);
252
253 // From IpL4Protocol
255 Ipv4Header const &incomingIpHeader,
256 Ptr<Ipv4Interface> incomingInterface);
258 Ipv6Header const &incomingIpHeader,
259 Ptr<Ipv6Interface> incomingInterface);
260
261 virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
262 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
263 Ipv4Address payloadSource,Ipv4Address payloadDestination,
264 const uint8_t payload[8]);
265 virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
266 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
267 Ipv6Address payloadSource,Ipv6Address payloadDestination,
268 const uint8_t payload[8]);
269
272 virtual int GetProtocolNumber (void) const;
275
276protected:
277 virtual void DoDispose (void);
278
288 virtual void NotifyNewAggregate ();
289
301 PacketReceived (Ptr<Packet> packet, TcpHeader &incomingTcpHeader,
302 const Address &source, const Address &destination);
303
317 void NoEndPointsFound (const TcpHeader &incomingHeader, const Address &incomingSAddr,
318 const Address &incomingDAddr);
319
320private:
327 std::vector<Ptr<TcpSocketBase> > m_sockets;
330
340 void SendPacketV4 (Ptr<Packet> pkt, const TcpHeader &outgoing,
341 const Ipv4Address &saddr, const Ipv4Address &daddr,
342 Ptr<NetDevice> oif = 0) const;
343
353 void SendPacketV6 (Ptr<Packet> pkt, const TcpHeader &outgoing,
354 const Ipv6Address &saddr, const Ipv6Address &daddr,
355 Ptr<NetDevice> oif = 0) const;
356};
357
358} // namespace ns3
359
360#endif /* TCP_L4_PROTOCOL_H */
a polymophic address class
Definition: address.h:91
L4 Protocol abstract base class.
RxStatus
Rx status codes.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Demultiplexes packets to various transport layer endpoints.
A representation of an internet endpoint/connection.
Packet header for IPv4.
Definition: ipv4-header.h:34
Describes an IPv6 address.
Definition: ipv6-address.h:50
Demultiplexer for end points.
A representation of an IPv6 endpoint/connection.
Packet header for IPv6.
Definition: ipv6-header.h:36
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
TCP socket creation and multiplexing/demultiplexing.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
TcpL4Protocol(const TcpL4Protocol &)=delete
void NoEndPointsFound(const TcpHeader &incomingHeader, const Address &incomingSAddr, const Address &incomingDAddr)
Check if RST packet should be sent, and in case, send it.
bool RemoveSocket(Ptr< TcpSocketBase > socket)
Remove a socket from the internal list.
TypeId m_congestionTypeId
The socket TypeId.
virtual int GetProtocolNumber(void) const
Returns the protocol number of this protocol.
enum IpL4Protocol::RxStatus PacketReceived(Ptr< Packet > packet, TcpHeader &incomingTcpHeader, const Address &source, const Address &destination)
Get the tcp header of the incoming packet and checks its checksum if needed.
void SendPacketV6(Ptr< Packet > pkt, const TcpHeader &outgoing, const Ipv6Address &saddr, const Ipv6Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IPv6)
TypeId m_recoveryTypeId
The recovery TypeId.
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &incomingIpHeader, Ptr< Ipv4Interface > incomingInterface)
Called from lower-level layers to send the packet up in the stack.
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points.
std::vector< Ptr< TcpSocketBase > > m_sockets
list of sockets
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv4 ca...
Ipv6EndPointDemux * m_endPoints6
A list of IPv6 end points.
Ptr< Socket > CreateSocket(void)
Create a TCP socket using the TypeId set by SocketType attribute.
Ptr< Node > m_node
the node this stack is associated with
virtual void DoDispose(void)
Destructor implementation.
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint.
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
virtual void ReceiveIcmp(Ipv4Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, Ipv4Address payloadSource, Ipv4Address payloadDestination, const uint8_t payload[8])
Called from lower-level layers to send the ICMP packet up in the stack.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint.
void SendPacketV4(Ptr< Packet > pkt, const TcpHeader &outgoing, const Ipv4Address &saddr, const Ipv4Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IPv4)
static const uint8_t PROT_NUMBER
protocol number (0x6)
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
This method allows a caller to get the current down target callback set for this L4 protocol (IPv6 ca...
void SendPacket(Ptr< Packet > pkt, const TcpHeader &outgoing, const Address &saddr, const Address &daddr, Ptr< NetDevice > oif=0) const
Send a packet via TCP (IP-agnostic)
virtual void NotifyNewAggregate()
Setup socket factory and callbacks when aggregated to a node.
TcpL4Protocol & operator=(const TcpL4Protocol &)=delete
static TypeId GetTypeId(void)
Get the type ID.
Ipv6EndPoint * Allocate6(void)
Allocate an IPv6 Endpoint.
void AddSocket(Ptr< TcpSocketBase > socket)
Make a socket fully operational.
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv6 ca...
IpL4Protocol::DownTargetCallback6 m_downTarget6
Callback to send packets over IPv6.
TypeId m_rttTypeId
The RTT Estimator TypeId.
a unique identifier for an interface.
Definition: type-id.h:59
uint16_t port
Definition: dsdv-manet.cc:45
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.