A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
nsc-tcp-l4-protocol.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
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;
6  *
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.
11  *
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
15  */
16 
17 #ifndef NSC_TCP_L4_PROTOCOL_H
18 #define NSC_TCP_L4_PROTOCOL_H
19 
20 #include <stdint.h>
21 
22 #include "ns3/packet.h"
23 #include "ns3/ipv4-address.h"
24 #include "ns3/ptr.h"
25 #include "ns3/object-factory.h"
26 #include "ns3/timer.h"
27 #include "ip-l4-protocol.h"
28 
29 struct INetStack;
30 
31 namespace ns3 {
32 
33 class Node;
34 class Socket;
35 class Ipv4EndPointDemux;
36 class Ipv4Interface;
37 class NscTcpSocketImpl;
38 class Ipv4EndPoint;
39 class NscInterfaceImpl;
40 
47 public:
48  static const uint8_t PROT_NUMBER;
49  static TypeId GetTypeId (void);
54  virtual ~NscTcpL4Protocol ();
55 
56  void SetNode (Ptr<Node> node);
57  void SetNscLibrary (const std::string &lib);
58  std::string GetNscLibrary (void) const;
59  virtual int GetProtocolNumber (void) const;
60  virtual int GetVersion (void) const;
61 
67 
68  Ipv4EndPoint *Allocate (void);
70  Ipv4EndPoint *Allocate (uint16_t port);
71  Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port);
72  Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort,
73  Ipv4Address peerAddress, uint16_t peerPort);
74 
75  void DeAllocate (Ipv4EndPoint *endPoint);
76 
84  Ipv4Header const &header,
85  Ptr<Ipv4Interface> incomingInterface);
87  Ipv6Address &src,
88  Ipv6Address &dst,
89  Ptr<Ipv6Interface> interface);
90 
91  // From IpL4Protocol
94  // From IpL4Protocol
97 protected:
98  virtual void DoDispose (void);
99  virtual void NotifyNewAggregate ();
100 private:
103 
104  // NSC callbacks.
105  // NSC invokes these hooks to interact with the simulator.
106  // In any case, these methods are only to be called by NSC.
107  //
108  // send_callback is invoked by NSCs 'ethernet driver' to re-inject
109  // a packet (i.e. an octet soup consisting of an IP Header, TCP Header
110  // and user payload, if any), into ns-3.
111  void send_callback (const void *data, int datalen);
112  // This is called by the NSC stack whenever something of interest
113  // has happened, e.g. when data arrives on a socket, a listen socket
114  // has a new connection pending, etc.
115  void wakeup ();
116  // This is called by the Linux stack RNG initialization.
117  // Its also used by the cradle code to add a timestamp to
118  // printk/printf/debug output.
119  void gettime (unsigned int *sec, unsigned int *usec);
120  void AddInterface (void);
121  void SoftInterrupt (void);
122  friend class NscInterfaceImpl;
123  friend class NscTcpSocketImpl;
129  std::string m_nscLibrary;
131  std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
133 };
134 
135 } // namespace ns3
136 
137 #endif /* NSC_TCP_L4_PROTOCOL_H */