A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mpi-receiver.h
Go to the documentation of this file.
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation;
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 *
15 * Author: George Riley <riley@ece.gatech.edu>
16 */
17
18/**
19 * \file
20 * \ingroup mpi
21 * ns3::MpiReceiver declaration,
22 * provides an interface to aggregate to MPI-compatible NetDevices.
23 */
24
25#ifndef NS3_MPI_RECEIVER_H
26#define NS3_MPI_RECEIVER_H
27
28#include "ns3/object.h"
29#include "ns3/packet.h"
30
31namespace ns3
32{
33
34/**
35 * \ingroup mpi
36 *
37 * \brief Class to aggregate to a NetDevice if it supports MPI capability
38 *
39 * MpiInterface::ReceiveMessages () needs to send packets to a NetDevice
40 * Receive() method. Since each NetDevice's Receive() method is specific
41 * to the derived class, and since we do not know whether such a NetDevice
42 * is MPI-capable, we aggregate one of these objects to each MPI-capable
43 * device. In addition, we must hook up a NetDevice::Receive() method
44 * to the callback. So the two steps to enable MPI capability are to
45 * aggregate this object to a NetDevice, and to set the callback.
46 */
47class MpiReceiver : public Object
48{
49 public:
50 /**
51 * Register this type.
52 * \return The object TypeId.
53 */
54 static TypeId GetTypeId();
55 ~MpiReceiver() override;
56
57 /**
58 * \brief Direct an incoming packet to the device Receive() method
59 * \param p Packet to receive
60 */
61 void Receive(Ptr<Packet> p);
62 /**
63 * \brief Set the receive callback to get packets to net devices
64 * \param callback the callback itself
65 */
66 void SetReceiveCallback(Callback<void, Ptr<Packet>> callback);
67
68 private:
69 void DoDispose() override;
70
71 /** Callback to send received packets to. */
73};
74
75} // namespace ns3
76
77#endif /* NS3_MPI_RECEIVER_H */
Callback template class.
Definition: callback.h:438
Class to aggregate to a NetDevice if it supports MPI capability.
Definition: mpi-receiver.h:48
Callback< void, Ptr< Packet > > m_rxCallback
Callback to send received packets to.
Definition: mpi-receiver.h:72
void Receive(Ptr< Packet > p)
Direct an incoming packet to the device Receive() method.
Definition: mpi-receiver.cc:51
static TypeId GetTypeId()
Register this type.
Definition: mpi-receiver.cc:31
void DoDispose() override
Destructor implementation.
Definition: mpi-receiver.cc:58
~MpiReceiver() override
Definition: mpi-receiver.cc:40
void SetReceiveCallback(Callback< void, Ptr< Packet > > callback)
Set the receive callback to get packets to net devices.
Definition: mpi-receiver.cc:45
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.