Add base class IPAddr; L4Protocol; Protocol; OnOff Application, and base class Socket

This commit is contained in:
Tom Henderson committed 2007-03-18 14:35:44 -07:00
1 parent 080a57c8b5
commit 5d6b5e3873
6 files changed
+776

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
// -*- Mode:NS3 -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// NS3 Base class for IPV4 and IPV6 addresses, and masks.
// George F. Riley, Georgia Tech, Spring 2007
#ifndef __IPADDR_H__
#define __IPADDR_H__
#include <string>
#include "protocol.h"
namespace ns3 {
class IPMask
{
public:
virtual ~IPMask();
virtual uint32_t Size() const = 0; // Size of mask in bytes
virtual IPMask* Copy() const = 0; // Copy this mask
virtual Proto_t L3Proto() const = 0; // Associated layer 3 protocol number
};
class IPAddr {
public:
virtual ~IPAddr() {}
virtual uint32_t Size() const = 0; // Number of bytes in this address
virtual IPAddr* Copy() const = 0; // Copy this address
virtual Proto_t L3Proto() const = 0; // Associated layer 3 protocol number
virtual std::string ToString() const = 0;// Convert to dotted notation
virtual operator std::string() const = 0;// For convenience, a string typecast
virtual IPMask& GetMask(uint32_t) const;// Get a compatible mask
};
} //namespace ns3
#endif
+45
View File
@@ -0,0 +1,45 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// NS3 - Layer 4 Protocol base class
// George F. Riley, Georgia Tech, Spring 2007
#ifndef __l4proto_h__
#define __l4proto_h__
#include "protocol.h"
namespace ns3 {
class Node;
class L4Protocol : public Protocol {
public:
L4Protocol() : m_node(0) {}
virtual Layer_t Layer () const { return 4; }
virtual L4Protocol* Copy() const = 0;
// L4 protocols have an associated Node object
public:
Node* m_node;
};
} // Namespace ns3
#endif
+262
View File
@@ -0,0 +1,262 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// ns3 - On/Off Data Source Application class
// George F. Riley, Georgia Tech, Spring 2007
// Adapted from ApplicationOnOff in GTNetS.
#include "ipaddr.h"
#include "l4protocol.h"
#include "node.h"
#include "node-reference.h"
#include "ns3/nstime.h"
#include "onoff-application.h"
#include "ns3/random-variable.h"
#include "socket.h"
#include "udp.h"
//#include "tcp.h"
#include "ns3/simulator.h"
using namespace std;
namespace ns3 {
#if 0
// Defaults for rate/size
double OnOffApplication::g_defaultRate = 500000.0;
uint32_t OnOffApplication::g_defaultSize = 512;
#define nil 0
// Constructors
OnOffApplication::OnOffApplication(const IPAddr& rip, // Remote IP addr
PortId_t rport, // Remote port
const RandomVariable& ontime,
const RandomVariable& offtime,
double rate,
uint32_t size,
const L4Protocol& l4p)
: m_l4Proto(l4p.Copy()),
m_socket(nil), // Socket allocated on Start
m_peerIP(rip.Copy()),
m_peerPort(rport),
m_connected(false),
m_onTime(ontime.Copy()),
m_offTime(offtime.Copy()),
m_cbrRate(rate),
m_pktSize(size),
m_residualBits(0),
m_lastStartTime(0),
m_maxBytes(0xffffffff),
m_totBytes(0),
m_startStopScheduled(false),
m_sendScheduled(false)
{
}
OnOffApplication::OnOffApplication(const OnOffApplication& c)
: m_l4Proto(c.m_l4Proto->Copy()),
m_socket(nil),
m_peerIP(c.m_peerIP->Copy()),
m_peerPort(c.m_peerPort),
m_connected(c.m_connected),
m_onTime(c.m_onTime->Copy()),
m_offTime(c.m_offTime->Copy()),
m_cbrRate(c.m_cbrRate),
m_pktSize(c.m_pktSize),
m_residualBits(c.m_residualBits),
m_lastStartTime(c.m_lastStartTime),
m_maxBytes(c.m_maxBytes),
m_totBytes(c.m_totBytes),
m_startStopScheduled(false),
m_sendScheduled(false)
{
}
OnOffApplication::~OnOffApplication()
{
delete m_l4Proto;
delete m_socket;
delete m_peerIP;
delete m_onTime;
delete m_offTime;
}
#ifdef REMOVE_THIS
// Handler Methods
void OnOffApplication::Handle(Event* e, Time_t t)
{
AppOOEvent* ev = (AppOOEvent*)e;
switch (ev->event) {
case AppOOEvent::SEND_PKT :
{
SendPkt(false); // Send the packet
return;
}
case AppOOEvent::START_GEN :
{
DEBUG0((cout << "StartGen at " << Simulator::Now() << endl));
lastStartTime = Simulator::Now();
ScheduleNextTx();
Time_t onInterval = onTime->Value();
pendingOO->event = AppOOEvent::STOP_GEN;
// Schedule the stop event
Simulator::Schedule(pendingOO, onInterval, this);
return;
}
case AppOOEvent::STOP_GEN :
{
DEBUG0((cout << "StopGen at " << Simulator::Now() << endl));
if (totBytes < maxBytes)
{ // Only schedule if not execeeded maxBytes
Time_t offInterval = offTime->Value();
pendingOO->event = AppOOEvent::START_GEN;
// Schedule the start event
Simulator::Schedule(pendingOO, offInterval, this);
}
if (pendingEvent)
{
// Calculate residual bits since last packet sent
residualBits += (uint32_t)(cbrRate*(Simulator::Now()-lastStartTime));
Simulator::Cancel(pendingEvent);
delete pendingEvent;
pendingEvent = nil;
}
return;
}
}
Application::Handle(e, t); // May be application event
}
#endif
// Application Methods
void OnOffApplication::StartApp() // Called at time specified by Start
{
// Create the socket if not already
if (!m_socket)
{ // Create the socket using the specified layer 4 protocol
#ifdef NOTYET
m_socket = GetNode()->GetKernel()->CreateGenericSocket(*m_l4Proto);
#endif
m_socket->Bind(); // Choose any available port local port
m_socket->Connect(*m_peerIP, m_peerPort,
MakeCallback(&OnOffApplication::ConnectionSucceeded,
this),
MakeCallback(&OnOffApplication::ConnectionFailed,
this));
}
StopApp(); // Insure no pending event
// If we are not yet connected, there is nothing to do here
// The ConnectionComplete upcall will start timers at that time
if (!m_connected) return;
ScheduleStartEvent();
}
void OnOffApplication::StopApp() // Called at time specified by Stop
{
if (m_startStopScheduled)
{ // Cancel the startStop event
Simulator::Cancel(m_startStopEvent);
m_startStopScheduled = false;
}
if (m_sendScheduled)
{ // Cancel the pending send packet event
Simulator::Cancel(m_sendEvent);
m_sendScheduled = false;
// Calculate residual bits since last packet sent
Time delta(Simulator::Now() - m_lastStartTime);
m_residualBits += (uint32_t)(m_cbrRate * delta.GetSeconds());
}
}
OnOffApplication* OnOffApplication::Copy() const
{
return new OnOffApplication(*this);
}
// Event handlers
void OnOffApplication::StartSending()
{
m_startStopScheduled = true;
ScheduleNextTx(); // Schedule the send packet event
}
void OnOffApplication::StopSending()
{
m_startStopScheduled = true;
if (m_sendScheduled) Simulator::Cancel(m_sendEvent);
}
// Private helpers
void OnOffApplication::ScheduleNextTx()
{
if (m_totBytes < m_maxBytes)
{
uint32_t bits = m_pktSize * 8 - m_residualBits;
Time nextTime(Seconds (bits / m_cbrRate)); // Time till next packet
Simulator::Schedule(nextTime, &OnOffApplication::SendPacket, this);
}
else
{ // All done, cancel any pending events
StopApp();
}
}
void OnOffApplication::ScheduleStartEvent()
{ // Schedules the event to start sending data (switch to the "On" state)
Time offInterval = Seconds(m_offTime->GetValue());
Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this);
m_startStopScheduled = true;
}
void OnOffApplication::ScheduleStopEvent()
{ // Schedules the event to stop sending data (switch to "Off" state)
Time onInterval = Seconds(m_onTime->GetValue());
Simulator::Schedule(onInterval, &OnOffApplication::StopSending, this);
m_startStopScheduled = true;
}
void OnOffApplication::SendPacket()
{
m_sendScheduled = false;
m_socket->Send(0, m_pktSize); // Send the packet
m_totBytes += m_pktSize;
m_lastStartTime = Simulator::Now();
m_residualBits = 0;
ScheduleNextTx();
}
void OnOffApplication::ConnectionSucceeded(Socket*)
{
m_connected = true;
ScheduleStartEvent();
}
void OnOffApplication::ConnectionFailed(Socket*)
{
cout << "OnOffApplication, Connection Failed" << endl;
}
#endif
} // Namespace ns3
+148
View File
@@ -0,0 +1,148 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// ns3 - On/Off Data Source Application class
// George F. Riley, Georgia Tech, Spring 2007
// Adapted from ApplicationOnOff in GTNetS.
// Define an on/off data source application class
#ifndef __onoff_application_h__
#define __onoff_application_h__
#include "application.h"
#include "udp.h"
#include "ns3/event-id.h"
#define nil 0
namespace ns3 {
class IPAddr;
class L4Protocol;
class RandomVariable;
class Socket;
#if 0
class Time;
//Doc:ClassXRef
class OnOffApplication : public Application {
//Doc:Class Defines an application that uses the on--off data generator
//Doc:Class model.
public:
// Define a number of constructors for different needs
// Endpoints, on/off rng, l4 protocol
//Doc:Method
OnOffApplication(const IPAddr&, // Peer IP Address
PortId_t, // Peer port
const RandomVariable&, // Random variable for On time
const RandomVariable&, // Random variable for Off time
double = g_defaultRate, // Data rate when on
uint32_t = g_defaultSize, // Size of packets
const L4Protocol& = Udp(nil));// Layer 4 protocol to use
//Doc:Desc Constructor specifying destination IP/Port, a single random
//Doc:Desc number generator for both the {\em On} and {\em Off}
//Doc:Desc distributions, and a layer 4 protocol object. Optionally
//Doc:Desc specifies bit rate (when {\em On} (defaults to a globally
//Doc:Desc specified default rate), and optionally a packet size
//Doc:Desc (defaults to a globally specified default size). See
//Doc:Desc {\tt SetDefaultRate} and {\tt SetDefaultSize} below.
//Doc:Arg1 IPAddress of remote endpoint (destination)
//Doc:Arg2 Port number for remote endpoing (destination)
//Doc:Arg3 Random number generator to use for {\em On} time period.
//Doc:Arg4 Random number generator to use for both {\em Off} time period.
//Doc:Arg5 Data rate to generate when {\em On}.
//Doc:Arg6 Packet size.
//Doc:Arg7 A layer 4 protocol object to copy.
OnOffApplication(const OnOffApplication&); // Copy constructor
virtual ~OnOffApplication(); // Destructor
virtual void StartApp(); // Called at time specified by Start
virtual void StopApp(); // Called at time specified by Stop
virtual OnOffApplication* Copy() const;// Make a copy of the application
virtual L4Protocol* GetL4() const { return m_l4Proto;}
// Event handlers
void StartSending();
void StopSending();
void SendPacket();
//Doc:Method
virtual void MaxBytes(uint32_t m) { m_maxBytes = m;}
//Doc:Desc Specify a maximum number of bytes to send, after which the
//Doc:Desc application shuts down.
//Doc:Arg1 Maximum number of bytes to send.
public: // Static methods
//Doc:Method
static void DefaultRate(double r) { g_defaultRate = r;}
//Doc:Desc Specify a default data rate to use for all On/Off applications
//Doc:Desc by default
//Doc:Arg1 The default data rate (when the application is {\em On}.
//Doc:Method
static void DefaultSize(uint32_t s) { g_defaultSize = s;}
//Doc:Desc Specifies a default packet size to use for all
//Doc:Desc On/Off applcations
//Doc:Desc by default.
//Doc:Arg1 The default packet size.
public:
L4Protocol* m_l4Proto; // Points to the specified Layer 4 protocol
Socket* m_socket; // Associated socket
IPAddr* m_peerIP; // PeerIP
PortId_t m_peerPort; // Peer port
bool m_connected; // True if connected
RandomVariable* m_onTime; // rng for On Time
RandomVariable* m_offTime; // rng for Off Time
double m_cbrRate; // Rate that data is generated
uint32_t m_pktSize; // Size of packets
uint32_t m_residualBits; // Number of generated, but not sent, bits
Time m_lastStartTime;// Time last packet sent
uint32_t m_maxBytes; // Limit total number of bytes sent
uint32_t m_totBytes; // Total bytes sent so far
bool m_startStopScheduled; // True if start or stop event scheduled
EventId m_startStopEvent; // Event id for next start or stop event
bool m_sendScheduled;// True of send event scheduled
EventId m_sendEvent; // Eventid of pending "send packet" event
bool m_sending; // True if currently in sending state
public:
static double g_defaultRate; // Default sending rate when on
static uint32_t g_defaultSize; // Default packet size
private:
void ScheduleNextTx();
void ScheduleStartEvent();
void ScheduleStopEvent();
void ConnectionSucceeded(Socket*);
void ConnectionFailed(Socket*);
void Ignore(Socket*);
protected:
};
#endif
} // namespace ns3
#endif
+63
View File
@@ -0,0 +1,63 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// NS3 - Protocol base class
// George F. Riley. Georgia Tech, Spring 2007
// Class protocol is for any protocol stack layer implementation
#include <stdint.h>
#ifndef __PROTOCOL_H__
#define __PROTOCOL_H__
namespace ns3{
typedef int Layer_t; // Protocol layer number
typedef int Proto_t; // Protocol identifier
typedef int Version_t; // Which version of protocol
typedef int Priority_t; // Protocol priority
typedef int32_t PortId_t;
#define NO_PORT ((PortId_t)-1)
typedef uint32_t Size_t;
// All Protocol subclasses must implement the Layer, Proto, and
// Version methods, although they are free to indicate that the
// particular value if meaningless by returning -1. For example,
// most layer 2 protocols do not include a "version number", nor
// a "protocol number". The Proto values must be used
// if the protocol is to be inserted into the protocol graph.
//
// Additionally, all protocols must be able to copy themselves, using
// the virtual Copy method. THis is used when copying protocol graphs
// when creating Node objects from a pre-configured node. See the
// code in Node::Create() and Node::Prototype() in the node implementation.
class Protocol {
public:
Protocol() { }
virtual ~Protocol() { }
virtual Layer_t GetLayer() const = 0; // Get protocol layer
virtual Proto_t GetProtocolNumber() const = 0; // Get proto number
virtual Version_t GetVersion() const = 0; // Get proto version number
virtual Protocol* Copy() const = 0; // Copy this protocol
};
} //namespace ns3
#endif
+204
View File
@@ -0,0 +1,204 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation;
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// Define the Sockets API for ns3.
// George F. Riley, Georgia Tech, Fall 2006
// The Socket class defines an API based on the well-known
// BSD sockets. However, in a simulation environment, it is difficult
// to implement the semantics "blocking" calls, such as recv.
// The ns3 API will always return immediately from the blocking calls,
// with an upcall at a later time when the call would unblock.
// All blocking calls have a parameters with callbacks
// to the desired upcall. However, the design supports the upcall
// even if the owner of the socket has not posted the corresponding
// blocking call, which eases implementation slightly.
//
// The ns3 class "Process"is anticipated to be a common way to create
// and manipulate sockets, so a set of member functions are provided
// in class Process to give a syntactically easy way to access the
// sockets with default upcall virtual functions for each of the
// defined blocking calls. See the definition and implementation
// Process in process.h for details.
//
// As designed, the Socket class is a virtual base class, which defines
// the services that each layer 4 protocol must provide.
#ifndef __SOCKET_H__
#define __SOCKET_H__
#include "ns3/callback.h"
#include "protocol.h"
namespace ns3{
class IPAddr;
class L4Protocol;
class Process;
// \brief Define the BSD Sockets API
class Socket {
public:
Socket(); // Constructor
virtual ~Socket() {}
private:
// These static methods are default, do-nothing callbacks. They are
// provided as default arguments to the various socket calls, so callers who
// are not interested in a particular callback can ignore the
// parameters. Since these are used as formal parameters to MakeCallbac,
// each must have a unique name (they can't be disambiguated by argument
// list). The naming convention is a single letter indicating the
// return type (V = void for example) and a single letter for each
// argument type (S = Socket for exampls).
static void CBIgnoreVS(Socket*) {}
static void CBIgnoreVSIP(Socket*, const IPAddr&, PortId_t) {}
static void CBIgnoreVSU(Socket*, uint32_t) {}
static void CBIgnoreVSCU(Socket*, char*, uint32_t) {}
static bool CBIgnoreBSIP(Socket*, const IPAddr&, PortId_t){ return true;}
static void CBIgnoreVSCUIP(Socket*, char*, uint32_t, const IPAddr&, PortId_t);
public:
// Define the BSD Socket API, with some slight variations.
// \brief Bind the socket to a particular port number
// \param Port number to bind. If zero is specified, an available
// transient port is assigned.
// \return Port number assigned, or -1 if port already in use.
virtual PortId_t Bind(PortId_t = 0);
// \brief Close a socket.
// After the Close call, the socket is no longer valid, and cannot
// safely be used for subsequent operations.
// \param Callback for close completed.
virtual void Close(ns3::Callback<void, Socket*>
= MakeCallback(&Socket::CBIgnoreVS));
// \brief Initiate a connection to a remote host
// \param IP Address of remote.
// \param Port number of remote
// \param Callback for connection succeeded
// \param Callback for connection failed
// \param Callback for connection close requested by peer
virtual void Connect(const IPAddr&, // IPAddress of peer
PortId_t, // Port number
ns3::Callback<void, Socket*> = // COnnection succeeded callback,
MakeCallback(&Socket::CBIgnoreVS),
ns3::Callback<void, Socket*> = // Connection failed callback
MakeCallback(&Socket::CBIgnoreVS),
ns3::Callback<void, Socket*> = // CloseRequested callback
MakeCallback(&Socket::CBIgnoreVS));
// \brief Specify the number of pending connections to buffer
// while not blocked on accept. We include this for completeness,
// but with the callback approach to connection acceptance this
// does nothing.
virtual void Listen(uint32_t);
// \brief Accept connection requests from remote hosts
// \param Callback for connection request from peer
// \param Callback for new connection
// \param Callback for connection close request from peer
virtual void Accept(
// Connection request callback
ns3::Callback<bool, Socket*, const IPAddr&, PortId_t> =
MakeCallback(&Socket::CBIgnoreBSIP),
// New connection callback
ns3::Callback<void, Socket*, const IPAddr&, PortId_t> =
MakeCallback(&Socket::CBIgnoreVSIP),
// CloseRequested callback
ns3::Callback<void, Socket*> =
MakeCallback(&Socket::CBIgnoreVS));
// \brief Send data (or dummy data) to the remote host
// \param Data to send (nil if dummy data).
// NOTE. The data (if any) is copied by this call, so pointers
// to local data is allowed and processed correctly.
// \param Number of bytes to send.
// \param Data sent callback. A suitable "ignore" callback
// is used if not specified.
virtual void Send(char*, // Data to send
uint32_t, // Number of bytes
ns3::Callback<void, Socket*, uint32_t> =
MakeCallback(&CBIgnoreVSU)); // Sent cb
// \brief Send data to a specified peer.
// \param IP Address of remote host
// \param port number
// \param Data to send (nil if dummy data).
// NOTE. The data (if any) is copied by this call, so pointers
// to local data is allowed and processed correctly.
// \param Number of bytes to send.
// \param Data sent callback
virtual void SendTo(const IPAddr&, // IP Address of remote peer
PortId_t, // Port number of remote peer
char*, // Data to send
uint32_t, // Number of bytes
ns3::Callback<void, Socket*, uint32_t> =
MakeCallback(&Socket::CBIgnoreVSU)); // Sent cb
// \brief Receive data
// Note that due to the callback nature of the ns3 implementation,
// there is no data pointer provided here. Rather, the callback
// will specify where the data can be found, and the callback should
// copy it to a local buffer if needed at that time.
// \param Received data callback.
virtual void Recv(ns3::Callback<void, Socket*, char*, uint32_t,
const IPAddr&, PortId_t> =
MakeCallback(&Socket::CBIgnoreVSCUIP));
private:
// upcalls
// The members below are all callbacks, created with MakeCallback,
ns3::Callback<void, Socket*> m_cbCloseComplete; // Socket Closed upcall
ns3::Callback<void, Socket*> m_cbCloseRequested; // Close req by peer
ns3::Callback<void, Socket*> m_cbConnectionSucceeded;// Connection successful
ns3::Callback<void, Socket*> m_cbConnectionFailed; // Connection failed
// \brief For TCP sockets, the cbSent upcall call is made when the data packet
// is sent, but not acknowledged. For UDP sockets, it is called
// immediately.
ns3::Callback<void, Socket*, uint32_t> m_cbSent; // Data delivered
// \brief For the cbRecv callback, the char* to the data may be nil if
// no actual data is present.
ns3::Callback<void, Socket*, char*, uint32_t,
const IPAddr&, PortId_t> m_cbRecv;
// \brief The cbConnectionRequest callback is called when a socket has
// called Listen, and indicates a remote peer has sent a connection
// request. The callback can return false to indicate the connection
// is to be rejected, for example in a peer-to-peer application that
// wants to limit the number of connections at any one time.
ns3::Callback<bool, Socket*, const IPAddr&, PortId_t> m_cbConnectionRequest;
// \brief The cbNewConnection callback is called when a connection request
// from a peer has been received and accepted by the process owning
// this socket. Note the Socket* passed to the upcall is a new
// socket. The original socket using accept is still accepting connections.
ns3::Callback<void, Socket*, const IPAddr&, PortId_t> m_cbNewConnection;
};
} //namespace ns3
#endif