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/packet.h"
27 #include "ns3/ipv4-address.h"
28 #include "ns3/ipv6-address.h"
29 #include "ns3/ptr.h"
30 #include "ns3/object-factory.h"
31 #include "ip-l4-protocol.h"
32 #include "ns3/net-device.h"
33 
34 namespace ns3 {
35 
36 class Node;
37 class Socket;
38 class TcpHeader;
39 class Ipv4EndPointDemux;
40 class Ipv6EndPointDemux;
41 class Ipv4Interface;
42 class TcpSocketBase;
43 class Ipv4EndPoint;
44 class Ipv6EndPoint;
45 
56 class TcpL4Protocol : public IpL4Protocol {
57 public:
62  static TypeId GetTypeId (void);
63  static const uint8_t PROT_NUMBER;
64 
65  TcpL4Protocol ();
66  virtual ~TcpL4Protocol ();
67 
72  void SetNode (Ptr<Node> node);
73 
74  virtual int GetProtocolNumber (void) const;
75 
91  Ptr<Socket> CreateSocket (TypeId socketTypeId);
92 
97  Ipv4EndPoint *Allocate (void);
109  Ipv4EndPoint *Allocate (uint16_t port);
125  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
126  Ipv4Address peerAddress, uint16_t peerPort);
131  Ipv6EndPoint *Allocate6 (void);
143  Ipv6EndPoint *Allocate6 (uint16_t port);
159  Ipv6EndPoint *Allocate6 (Ipv6Address localAddress, uint16_t localPort,
160  Ipv6Address peerAddress, uint16_t peerPort);
161 
166  void DeAllocate (Ipv4EndPoint *endPoint);
171  void DeAllocate (Ipv6EndPoint *endPoint);
172 
182  void Send (Ptr<Packet> packet,
183  Ipv4Address saddr, Ipv4Address daddr,
184  uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
194  void Send (Ptr<Packet> packet,
195  Ipv6Address saddr, Ipv6Address daddr,
196  uint16_t sport, uint16_t dport, Ptr<NetDevice> oif = 0);
197 
198 
200  Ipv4Header const &header,
201  Ptr<Ipv4Interface> incomingInterface);
203  Ipv6Header const &header,
204  Ptr<Ipv6Interface> incomingInterface);
205 
206  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
207  uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
208  Ipv4Address payloadSource,Ipv4Address payloadDestination,
209  const uint8_t payload[8]);
210  virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
211  uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
212  Ipv6Address payloadSource,Ipv6Address payloadDestination,
213  const uint8_t payload[8]);
214 
215  // From IpL4Protocol
218  // From IpL4Protocol
219  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
221 
222 protected:
223  virtual void DoDispose (void);
224  /*
225  * This function will notify other components connected to the node that a new stack member is now connected
226  * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
227  */
228  virtual void NotifyNewAggregate ();
229 private:
235 private:
236  friend class TcpSocketBase;
237  void SendPacket (Ptr<Packet>, const TcpHeader &,
239  void SendPacket (Ptr<Packet>, const TcpHeader &,
241 
247  TcpL4Protocol (const TcpL4Protocol &);
255 
256  std::vector<Ptr<TcpSocketBase> > m_sockets;
259 };
260 
261 } // namespace ns3
262 
263 #endif /* TCP_L4_PROTOCOL_H */
Ptr< Socket > CreateSocket(void)
Create a TCP socket.
TypeId m_socketTypeId
The socket TypeId.
Introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
Ptr< Node > m_node
the node this stack is associated with
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...
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...
virtual void DoDispose(void)
Destructor implementation.
Ipv6EndPoint * Allocate6(void)
Allocate an IPv6 Endpoint.
void Send(Ptr< Packet > packet, Ipv4Address saddr, Ipv4Address daddr, uint16_t sport, uint16_t dport, Ptr< NetDevice > oif=0)
Send a packet via TCP (IPv4)
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.
uint16_t port
Definition: dsdv-manet.cc:44
A layer between the sockets interface and IP.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Demultiplexes packets to various transport layer endpoints.
Packet header for IPv4.
Definition: ipv4-header.h:31
TcpL4Protocol & operator=(const TcpL4Protocol &)
Copy constructor.
virtual enum IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Called from lower-level layers to send the packet up in the stack.
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...
A base class for implementation of a stream socket using TCP.
std::vector< Ptr< TcpSocketBase > > m_sockets
list of sockets
static const uint8_t PROT_NUMBER
protocol number (0x6)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv6EndPointDemux * m_endPoints6
A list of IPv6 end points.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:44
virtual int GetProtocolNumber(void) const
void SendPacket(Ptr< Packet >, const TcpHeader &, Ipv4Address, Ipv4Address, Ptr< NetDevice > oif=0)
L4 Protocol abstract base class.
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint.
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points.
void SetNode(Ptr< Node > node)
Set node associated with this stack.
Describes an IPv6 address.
Definition: ipv6-address.h:47
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
static TypeId GetTypeId(void)
Get the type ID.
Demultiplexor for end points.
A representation of an internet IPv6 endpoint/connection.
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...
TypeId m_rttTypeId
The RTT Estimator TypeId.
RxStatus
Rx status codes.
tuple address
Definition: first.py:37
a unique identifier for an interface.
Definition: type-id.h:57
IpL4Protocol::DownTargetCallback6 m_downTarget6
Callback to send packets over IPv6.
A representation of an internet endpoint/connection.
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4.