A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
non-communicating-net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Nicola Baldo <nbaldo@cttc.es>
7 */
8
9#ifndef NON_COMMUNICATING_NET_DEVICE_H
10#define NON_COMMUNICATING_NET_DEVICE_H
11
12#include <ns3/address.h>
13#include <ns3/callback.h>
14#include <ns3/net-device.h>
15#include <ns3/node.h>
16#include <ns3/packet.h>
17#include <ns3/ptr.h>
18#include <ns3/traced-callback.h>
19
20#include <cstring>
21
22namespace ns3
23{
24
25class SpectrumChannel;
26class Channel;
27class SpectrumErrorModel;
28
29/**
30 * \ingroup spectrum
31 *
32 * This class implements a device which does not communicate, in the
33 * sense that it does not interact with the above protocol stack. The
34 * purpose of this NetDevice is to be used for devices such as
35 * microwave ovens, waveform generators and spectrum
36 * analyzers. Since the ns-3 channel API is strongly based on the presence of
37 * NetDevice class instances, it is convenient to provide a NetDevice that can
38 * be used with such non-communicating devices.
39 */
41{
42 public:
43 /**
44 * \brief Get the type ID.
45 * \return the object TypeId
46 */
47 static TypeId GetTypeId();
48
51
52 /**
53 * This class doesn't talk directly with the underlying channel (a
54 * dedicated PHY class is expected to do it), however the NetDevice
55 * specification features a GetChannel() method. This method here
56 * is therefore provide to allow NonCommunicatingNetDevice::GetChannel() to have
57 * something meaningful to return.
58 *
59 * @param c the underlying channel
60 */
62
63 /**
64 * Set the Phy object which is attached to this device.
65 * This object is needed so that we can set/get attributes and
66 * connect to trace sources of the PHY from the net device.
67 *
68 * @param phy the Phy object embedded within this device.
69 */
70 void SetPhy(Ptr<Object> phy);
71
72 /**
73 * @return a reference to the PHY object embedded in this NetDevice.
74 */
75 Ptr<Object> GetPhy() const;
76
77 // inherited from NetDevice
78 void SetIfIndex(const uint32_t index) override;
79 uint32_t GetIfIndex() const override;
80 Ptr<Channel> GetChannel() const override;
81 bool SetMtu(const uint16_t mtu) override;
82 uint16_t GetMtu() const override;
83 void SetAddress(Address address) override;
84 Address GetAddress() const override;
85 bool IsLinkUp() const override;
86 void AddLinkChangeCallback(Callback<void> callback) override;
87 bool IsBroadcast() const override;
88 Address GetBroadcast() const override;
89 bool IsMulticast() const override;
90 bool IsPointToPoint() const override;
91 bool IsBridge() const override;
92 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
93 bool SendFrom(Ptr<Packet> packet,
94 const Address& source,
95 const Address& dest,
96 uint16_t protocolNumber) override;
97 Ptr<Node> GetNode() const override;
98 void SetNode(Ptr<Node> node) override;
99 bool NeedsArp() const override;
101 Address GetMulticast(Ipv4Address addr) const override;
102 Address GetMulticast(Ipv6Address addr) const override;
104 bool SupportsSendFrom() const override;
105
106 private:
107 void DoDispose() override;
108
109 Ptr<Node> m_node; //!< node this NetDevice is associated to
110 Ptr<Channel> m_channel; //!< Channel used by the NetDevice
111 uint32_t m_ifIndex; //!< Interface index
112 Ptr<Object> m_phy; //!< Phy object
113};
114
115} // namespace ns3
116
117#endif /* NON_COMMUNICATING_NET_DEVICE_H */
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Network layer to device interface.
Definition net-device.h:87
This class implements a device which does not communicate, in the sense that it does not interact wit...
Ptr< Node > m_node
node this NetDevice is associated to
void SetIfIndex(const uint32_t index) override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void AddLinkChangeCallback(Callback< void > callback) override
Ptr< Channel > GetChannel() const override
Address GetMulticast(Ipv4Address addr) const override
Make and return a MAC multicast address using the provided multicast group.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void SetAddress(Address address) override
Set the address of this interface.
Ptr< Channel > m_channel
Channel used by the NetDevice.
bool SetMtu(const uint16_t mtu) override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void SetChannel(Ptr< Channel > c)
This class doesn't talk directly with the underlying channel (a dedicated PHY class is expected to do...
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetPhy(Ptr< Object > phy)
Set the Phy object which is attached to this device.
void SetNode(Ptr< Node > node) override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
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.