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);
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  Ipv6Header const &header,
88  Ptr<Ipv6Interface> interface);
89 
90  // From IpL4Protocol
93  // From IpL4Protocol
96 protected:
97  virtual void DoDispose (void);
98  virtual void NotifyNewAggregate ();
99 private:
102 
103  // NSC callbacks.
104  // NSC invokes these hooks to interact with the simulator.
105  // In any case, these methods are only to be called by NSC.
106  //
107  // send_callback is invoked by NSCs 'ethernet driver' to re-inject
108  // a packet (i.e. an octet soup consisting of an IP Header, TCP Header
109  // and user payload, if any), into ns-3.
110  void send_callback (const void *data, int datalen);
111  // This is called by the NSC stack whenever something of interest
112  // has happened, e.g. when data arrives on a socket, a listen socket
113  // has a new connection pending, etc.
114  void wakeup ();
115  // This is called by the Linux stack RNG initialization.
116  // Its also used by the cradle code to add a timestamp to
117  // printk/printf/debug output.
118  void gettime (unsigned int *sec, unsigned int *usec);
119  void AddInterface (void);
120  void SoftInterrupt (void);
121  friend class NscInterfaceImpl;
122  friend class NscTcpSocketImpl;
128  std::string m_nscLibrary;
130  std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
132 };
133 
134 } // namespace ns3
135 
136 #endif /* NSC_TCP_L4_PROTOCOL_H */
Nsc wrapper glue, to interface with the Ipv4 protocol underneath.
Packet header for IPv6.
Definition: ipv6-header.h:33
a simple Timer class
Definition: timer.h:45
IpL4Protocol::DownTargetCallback m_downTarget
Ptr< Socket > CreateSocket(void)
static TypeId GetTypeId(void)
virtual IpL4Protocol::DownTargetCallback6 GetDownTarget6(void) const
void SetNscLibrary(const std::string &lib)
uint16_t port
Definition: dsdv-manet.cc:44
virtual int GetVersion(void) const
NscInterfaceImpl * m_nscInterface
Demultiplexes packets to various transport layer endpoints.
Packet header for IPv4.
Definition: ipv4-header.h:31
virtual void SetDownTarget6(IpL4Protocol::DownTargetCallback6 cb)
void SetNode(Ptr< Node > node)
uint8_t data[writeSize]
Socket logic for the NSC TCP sockets.
virtual void NotifyNewAggregate()
virtual void DoDispose(void)
NscTcpL4Protocol & operator=(NscTcpL4Protocol const &)
std::string GetNscLibrary(void) const
virtual void SetDownTarget(IpL4Protocol::DownTargetCallback cb)
virtual IpL4Protocol::RxStatus Receive(Ptr< Packet > p, Ipv4Header const &header, Ptr< Ipv4Interface > incomingInterface)
Receive a packet up the protocol stack.
L4 Protocol abstract base class.
static const uint8_t PROT_NUMBER
Ipv4EndPointDemux * m_endPoints
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
std::vector< Ptr< NscTcpSocketImpl > > m_sockets
void DeAllocate(Ipv4EndPoint *endPoint)
virtual int GetProtocolNumber(void) const
Ipv4EndPoint * Allocate(void)
tuple address
Definition: first.py:37
a unique identifier for an interface.
Definition: type-id.h:49
void gettime(unsigned int *sec, unsigned int *usec)
A representation of an internet endpoint/connection.
void send_callback(const void *data, int datalen)
virtual IpL4Protocol::DownTargetCallback GetDownTarget(void) const