A Discrete-Event Network Simulator
API
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 class NetDevice;
41 
48 public:
49  static const uint8_t PROT_NUMBER;
50 
54  static TypeId GetTypeId (void);
55 
57  virtual ~NscTcpL4Protocol ();
58 
63  void SetNode (Ptr<Node> node);
64 
69  void SetNscLibrary (const std::string &lib);
70 
75  std::string GetNscLibrary (void) const;
76  virtual int GetProtocolNumber (void) const;
77 
82  virtual int GetVersion (void) const;
83 
89 
94  Ipv4EndPoint *Allocate (void);
107  Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice, uint16_t port);
115  Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice, Ipv4Address address, uint16_t port);
125  Ipv4EndPoint *Allocate (Ptr<NetDevice> boundNetDevice,
126  Ipv4Address localAddress, uint16_t localPort,
127  Ipv4Address peerAddress, uint16_t peerPort);
128 
129 
134  void DeAllocate (Ipv4EndPoint *endPoint);
135 
137  Ipv4Header const &header,
138  Ptr<Ipv4Interface> incomingInterface);
140  Ipv6Header const &header,
141  Ptr<Ipv6Interface> interface);
142 
143  // From IpL4Protocol
146  // From IpL4Protocol
147  virtual IpL4Protocol::DownTargetCallback GetDownTarget (void) const;
149 protected:
150  virtual void DoDispose (void);
151  virtual void NotifyNewAggregate ();
152 private:
166 
167  // NSC callbacks.
168  // NSC invokes these hooks to interact with the simulator.
169  // In any case, these methods are only to be called by NSC.
170 
180  void send_callback (const void *data, int datalen);
187  void wakeup ();
196  void gettime (unsigned int *sec, unsigned int *usec);
202  void AddInterface (void);
203 
207  void SoftInterrupt (void);
212  friend class NscInterfaceImpl;
217  friend class NscTcpSocketImpl;
218 
224  std::string m_nscLibrary;
226  std::vector<Ptr<NscTcpSocketImpl> > m_sockets;
228 };
229 
230 } // namespace ns3
231 
232 #endif /* NSC_TCP_L4_PROTOCOL_H */
std::string GetNscLibrary(void) const
Get the NSC library being used.
Nsc wrapper glue, to interface with the Ipv4 protocol underneath.
void SoftInterrupt(void)
Provide a "soft" interrupt to NSC.
Packet header for IPv6.
Definition: ipv6-header.h:34
A simple Timer class.
Definition: timer.h:73
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4.
std::string m_nscLibrary
path to the NSC library.
Ptr< Socket > CreateSocket(void)
static TypeId GetTypeId(void)
Get the type ID.
void wakeup()
Called by the NSC stack whenever something of interest has happened.
void SetNscLibrary(const std::string &lib)
Set the NSC library to be used.
uint16_t port
Definition: dsdv-manet.cc:45
NscInterfaceImpl * m_nscInterface
the NSC Interface.
Demultiplexes packets to various transport layer endpoints.
Packet header for IPv4.
Definition: ipv4-header.h:33
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...
void SetNode(Ptr< Node > node)
Set node associated with this stack.
uint8_t data[writeSize]
Socket logic for the NSC TCP sockets.
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
virtual void DoDispose(void)
Destructor implementation.
Struct interface to NSC stack.
Definition: sim_interface.h:31
NscTcpL4Protocol & operator=(NscTcpL4Protocol const &)
Copy constructor.
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...
void AddInterface(void)
Add an interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:37
Nsc interface implementation class.
INetStack * m_nscStack
the NSC stack.
virtual 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.
L4 Protocol abstract base class.
static const uint8_t PROT_NUMBER
protocol number (0x6)
Ptr< Node > m_node
the node this stack is associated with
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...
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
virtual int GetVersion(void) const
Get the NSC version.
std::vector< Ptr< NscTcpSocketImpl > > m_sockets
list of sockets
virtual int GetProtocolNumber(void) const
Returns the protocol number of this protocol.
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint.
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...
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint.
RxStatus
Rx status codes.
a unique identifier for an interface.
Definition: type-id.h:58
void * m_dlopenHandle
dynamic library handle.
void gettime(unsigned int *sec, unsigned int *usec)
Called by the Linux stack RNG initialization.
Timer m_softTimer
Soft interrupt timer.
A representation of an internet endpoint/connection.
void send_callback(const void *data, int datalen)
Invoked by NSCs &#39;ethernet driver&#39; to re-inject a packet into ns-3.