A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mpi-receiver.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Author: George Riley <riley@ece.gatech.edu>
5 */
6
7/**
8 * \file
9 * \ingroup mpi
10 * ns3::MpiReceiver declaration,
11 * provides an interface to aggregate to MPI-compatible NetDevices.
12 */
13
14#ifndef NS3_MPI_RECEIVER_H
15#define NS3_MPI_RECEIVER_H
16
17#include "ns3/object.h"
18#include "ns3/packet.h"
19
20namespace ns3
21{
22
23/**
24 * \ingroup mpi
25 *
26 * \brief Class to aggregate to a NetDevice if it supports MPI capability
27 *
28 * MpiInterface::ReceiveMessages () needs to send packets to a NetDevice
29 * Receive() method. Since each NetDevice's Receive() method is specific
30 * to the derived class, and since we do not know whether such a NetDevice
31 * is MPI-capable, we aggregate one of these objects to each MPI-capable
32 * device. In addition, we must hook up a NetDevice::Receive() method
33 * to the callback. So the two steps to enable MPI capability are to
34 * aggregate this object to a NetDevice, and to set the callback.
35 */
36class MpiReceiver : public Object
37{
38 public:
39 /**
40 * Register this type.
41 * \return The object TypeId.
42 */
43 static TypeId GetTypeId();
44 ~MpiReceiver() override;
45
46 /**
47 * \brief Direct an incoming packet to the device Receive() method
48 * \param p Packet to receive
49 */
50 void Receive(Ptr<Packet> p);
51 /**
52 * \brief Set the receive callback to get packets to net devices
53 * \param callback the callback itself
54 */
55 void SetReceiveCallback(Callback<void, Ptr<Packet>> callback);
56
57 private:
58 void DoDispose() override;
59
60 /** Callback to send received packets to. */
62};
63
64} // namespace ns3
65
66#endif /* NS3_MPI_RECEIVER_H */
Callback template class.
Definition callback.h:422
Class to aggregate to a NetDevice if it supports MPI capability.
Callback< void, Ptr< Packet > > m_rxCallback
Callback to send received packets to.
void Receive(Ptr< Packet > p)
Direct an incoming packet to the device Receive() method.
static TypeId GetTypeId()
Register this type.
void DoDispose() override
Destructor implementation.
~MpiReceiver() override
void SetReceiveCallback(Callback< void, Ptr< Packet > > callback)
Set the receive callback to get packets to net devices.
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.