|
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 |
* Author: George Riley <riley@ece.gatech.edu> |
17 |
*/ |
18 |
|
19 |
// Provides an interface to aggregate to MPI-compatible NetDevices |
20 |
|
21 |
#ifndef NS3_MPI_RECEIVER_H |
22 |
#define NS3_MPI_RECEIVER_H |
23 |
|
24 |
#include "ns3/object.h" |
25 |
#include "ns3/packet.h" |
26 |
|
27 |
namespace ns3 { |
28 |
|
29 |
/** |
30 |
* Class to aggregate to a NetDevice if it supports MPI capability |
31 |
* |
32 |
* MpiInterface::ReceiveMessages () needs to send packets to a NetDevice |
33 |
* Receive() method. Since each NetDevice's Receive() method is specific |
34 |
* to the derived class, and since we do not know whether such a NetDevice |
35 |
* is MPI-capable, we aggregate one of these objects to each MPI-capable |
36 |
* device. In addition, we must hook up a NetDevice::Receive() method |
37 |
* to the callback. So the two steps to enable MPI capability are to |
38 |
* aggregate this object to a NetDevice, and to set the callback. |
39 |
*/ |
40 |
class MpiReceiver : public Object |
41 |
{ |
42 |
public: |
43 |
static TypeId GetTypeId (void); |
44 |
virtual ~MpiReceiver (); |
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 |
private: |
57 |
Callback<void, Ptr<Packet> > m_rxCallback; |
58 |
}; |
59 |
|
60 |
} // namespace ns3 |
61 |
|
62 |
#endif /* NS3_MPI_RECEIVER_H */ |