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 */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::Ipv4Header
Packet header for IPv4.
Definition: ipv4-header.h:34
ns3::NscTcpL4Protocol::m_dlopenHandle
void * m_dlopenHandle
dynamic library handle.
Definition: nsc-tcp-l4-protocol.h:223
ns3::Callback< void, Ptr< Packet >, Ipv4Address, Ipv4Address, uint8_t, Ptr< Ipv4Route > >
ns3::NscTcpL4Protocol::m_nscInterface
NscInterfaceImpl * m_nscInterface
the NSC Interface.
Definition: nsc-tcp-l4-protocol.h:222
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::NscTcpL4Protocol::SetNode
void SetNode(Ptr< Node > node)
Set node associated with this stack.
Definition: nsc-tcp-l4-protocol.cc:196
ns3::NscInterfaceImpl
Nsc interface implementation class.
Definition: nsc-tcp-l4-protocol.cc:62
ns3::NscTcpL4Protocol::gettime
void gettime(unsigned int *sec, unsigned int *usec)
Called by the Linux stack RNG initialization.
Definition: nsc-tcp-l4-protocol.cc:442
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::NscTcpL4Protocol::wakeup
void wakeup()
Called by the NSC stack whenever something of interest has happened.
Definition: nsc-tcp-l4-protocol.cc:428
ns3::NscTcpL4Protocol::CreateSocket
Ptr< Socket > CreateSocket(void)
Definition: nsc-tcp-l4-protocol.cc:290
ns3::NscTcpL4Protocol::m_nscStack
INetStack * m_nscStack
the NSC stack.
Definition: nsc-tcp-l4-protocol.h:221
ns3::NscTcpL4Protocol
Nsc wrapper glue, to interface with the Ipv4 protocol underneath.
Definition: nsc-tcp-l4-protocol.h:47
ns3::NscTcpL4Protocol::NscTcpL4Protocol
NscTcpL4Protocol()
Definition: nsc-tcp-l4-protocol.cc:161
ns3::NscTcpL4Protocol::SetDownTarget
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...
Definition: nsc-tcp-l4-protocol.cc:503
ns3::Ipv6Header
Packet header for IPv6.
Definition: ipv6-header.h:36
ns3::NscTcpL4Protocol::m_endPoints
Ipv4EndPointDemux * m_endPoints
A list of IPv4 end points.
Definition: nsc-tcp-l4-protocol.h:220
ns3::NscTcpL4Protocol::~NscTcpL4Protocol
virtual ~NscTcpL4Protocol()
Definition: nsc-tcp-l4-protocol.cc:171
ns3::Timer
A simple virtual Timer class.
Definition: timer.h:74
ns3::Ptr< Node >
ns3::NscTcpL4Protocol::GetVersion
virtual int GetVersion(void) const
Get the NSC version.
Definition: nsc-tcp-l4-protocol.cc:260
ns3::NscTcpL4Protocol::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: nsc-tcp-l4-protocol.cc:129
ns3::NscTcpL4Protocol::GetNscLibrary
std::string GetNscLibrary(void) const
Get the NSC library being used.
Definition: nsc-tcp-l4-protocol.cc:191
ns3::NscTcpL4Protocol::DeAllocate
void DeAllocate(Ipv4EndPoint *endPoint)
Remove an IPv4 Endpoint.
Definition: nsc-tcp-l4-protocol.cc:341
ns3::NscTcpL4Protocol::Allocate
Ipv4EndPoint * Allocate(void)
Allocate an IPv4 Endpoint.
Definition: nsc-tcp-l4-protocol.cc:302
ns3::IpL4Protocol::RxStatus
RxStatus
Rx status codes.
Definition: ip-l4-protocol.h:56
ns3::NscTcpL4Protocol::PROT_NUMBER
static const uint8_t PROT_NUMBER
protocol number (0x6)
Definition: nsc-tcp-l4-protocol.h:49
data
uint8_t data[writeSize]
Definition: socket-bound-tcp-static-routing.cc:53
ns3::Ipv4EndPointDemux
Demultiplexes packets to various transport layer endpoints.
Definition: ipv4-end-point-demux.h:45
first.address
address
Definition: first.py:44
ns3::NscTcpL4Protocol::Receive
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.
Definition: nsc-tcp-l4-protocol.cc:348
ns3::NscTcpSocketImpl
Socket logic for the NSC TCP sockets.
Definition: nsc-tcp-socket-impl.h:54
ns3::NscTcpL4Protocol::AddInterface
void AddInterface(void)
Add an interface.
Definition: nsc-tcp-l4-protocol.cc:454
ns3::NscTcpL4Protocol::m_nscLibrary
std::string m_nscLibrary
path to the NSC library.
Definition: nsc-tcp-l4-protocol.h:224
ns3::IpL4Protocol
L4 Protocol abstract base class.
Definition: ip-l4-protocol.h:51
ns3::NscTcpL4Protocol::m_sockets
std::vector< Ptr< NscTcpSocketImpl > > m_sockets
list of sockets
Definition: nsc-tcp-l4-protocol.h:226
ns3::NscTcpL4Protocol::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: nsc-tcp-l4-protocol.cc:266
ns3::NscTcpL4Protocol::GetDownTarget6
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...
Definition: nsc-tcp-l4-protocol.cc:520
ns3::NscTcpL4Protocol::SoftInterrupt
void SoftInterrupt(void)
Provide a "soft" interrupt to NSC.
Definition: nsc-tcp-l4-protocol.cc:390
ns3::NscTcpL4Protocol::GetDownTarget
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...
Definition: nsc-tcp-l4-protocol.cc:514
ns3::NscTcpL4Protocol::m_node
Ptr< Node > m_node
the node this stack is associated with
Definition: nsc-tcp-l4-protocol.h:219
ns3::NscTcpL4Protocol::send_callback
void send_callback(const void *data, int datalen)
Invoked by NSCs 'ethernet driver' to re-inject a packet into ns-3.
Definition: nsc-tcp-l4-protocol.cc:397
ns3::NscTcpL4Protocol::NscTcpL4Protocol
NscTcpL4Protocol(NscTcpL4Protocol const &)
Copy constructor.
ns3::NscTcpL4Protocol::m_downTarget
IpL4Protocol::DownTargetCallback m_downTarget
Callback to send packets over IPv4.
Definition: nsc-tcp-l4-protocol.h:227
ns3::NscTcpL4Protocol::SetNscLibrary
void SetNscLibrary(const std::string &lib)
Set the NSC library to be used.
Definition: nsc-tcp-l4-protocol.cc:178
ns3::NscTcpL4Protocol::m_softTimer
Timer m_softTimer
Soft interrupt timer.
Definition: nsc-tcp-l4-protocol.h:225
ns3::NscTcpL4Protocol::NotifyNewAggregate
virtual void NotifyNewAggregate()
Notify all Objects aggregated to this one of a new Object being aggregated.
Definition: nsc-tcp-l4-protocol.cc:232
INetStack
Struct interface to NSC stack.
Definition: sim_interface.h:32
ns3::NscTcpL4Protocol::GetProtocolNumber
virtual int GetProtocolNumber(void) const
Returns the protocol number of this protocol.
Definition: nsc-tcp-l4-protocol.cc:255
ip-l4-protocol.h
ns3::NscTcpL4Protocol::operator=
NscTcpL4Protocol & operator=(NscTcpL4Protocol const &)
Copy constructor.
ns3::Ipv4EndPoint
A representation of an internet endpoint/connection.
Definition: ipv4-end-point.h:49
ns3::NscTcpL4Protocol::SetDownTarget6
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...
Definition: nsc-tcp-l4-protocol.cc:509
port
uint16_t port
Definition: dsdv-manet.cc:45