A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef SIMPLE_NET_DEVICE_H
20#define SIMPLE_NET_DEVICE_H
21
22#include "mac48-address.h"
23
24#include "ns3/data-rate.h"
25#include "ns3/event-id.h"
26#include "ns3/net-device.h"
27#include "ns3/queue-fwd.h"
28#include "ns3/traced-callback.h"
29
30#include <stdint.h>
31#include <string>
32
33namespace ns3
34{
35
36class SimpleChannel;
37class Node;
38class ErrorModel;
39
55{
56 public:
61 static TypeId GetTypeId();
63
74 void Receive(Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
75
83 void SetChannel(Ptr<SimpleChannel> channel);
84
90 void SetQueue(Ptr<Queue<Packet>> queue);
91
98
109
110 // inherited from NetDevice base class.
111 void SetIfIndex(const uint32_t index) override;
112 uint32_t GetIfIndex() const override;
113 Ptr<Channel> GetChannel() const override;
114 void SetAddress(Address address) override;
115 Address GetAddress() const override;
116 bool SetMtu(const uint16_t mtu) override;
117 uint16_t GetMtu() const override;
118 bool IsLinkUp() const override;
119 void AddLinkChangeCallback(Callback<void> callback) override;
120 bool IsBroadcast() const override;
121 Address GetBroadcast() const override;
122 bool IsMulticast() const override;
123 Address GetMulticast(Ipv4Address multicastGroup) const override;
124 bool IsPointToPoint() const override;
125 bool IsBridge() const override;
126 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
127 bool SendFrom(Ptr<Packet> packet,
128 const Address& source,
129 const Address& dest,
130 uint16_t protocolNumber) override;
131 Ptr<Node> GetNode() const override;
132 void SetNode(Ptr<Node> node) override;
133 bool NeedsArp() const override;
135
136 Address GetMulticast(Ipv6Address addr) const override;
137
139 bool SupportsSendFrom() const override;
140
141 protected:
142 void DoDispose() override;
143
144 private:
149 uint16_t m_mtu;
153
163
170 void StartTransmission();
171
177 void FinishTransmission(Ptr<Packet> packet);
178
179 bool m_linkUp;
180
186
190
195};
196
197} // namespace ns3
198
199#endif /* SIMPLE_NET_DEVICE_H */
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:438
Class for representing data rates.
Definition: data-rate.h:89
An identifier for simulation events.
Definition: event-id.h:55
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
Network layer to device interface.
Definition: net-device.h:98
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Template class for packet Queues.
Definition: queue.h:267
This device assumes 48-bit mac addressing; there is also the possibility to add an ErrorModel if you ...
bool NeedsArp() const override
void DoDispose() override
Destructor implementation.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received due to the error model being...
TracedCallback m_linkChangeCallbacks
List of callbacks to fire if the link changes state (up or down).
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void SetNode(Ptr< Node > node) override
void SetAddress(Address address) override
Set the address of this interface.
void SetIfIndex(const uint32_t index) override
void SetQueue(Ptr< Queue< Packet > > queue)
Attach a queue to the SimpleNetDevice.
bool SetMtu(const uint16_t mtu) override
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
static TypeId GetTypeId()
Get the type ID.
DataRate m_bps
The device nominal Data rate.
Ptr< Queue< Packet > > m_queue
The Queue for outgoing packets.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
Ptr< Channel > GetChannel() const override
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
uint16_t GetMtu() const override
EventId FinishTransmissionEvent
the Tx Complete event
bool m_linkUp
Flag indicating whether or not the link is up.
void AddLinkChangeCallback(Callback< void > callback) override
bool m_pointToPointMode
Flag indicating whether or not the NetDevice is a Point to Point model.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
void FinishTransmission(Ptr< Packet > packet)
The FinishTransmission method is used internally to finish the process of sending a packet out on the...
uint32_t GetIfIndex() const override
Ptr< ErrorModel > m_receiveErrorModel
Receive error model.
bool IsMulticast() const override
Ptr< SimpleChannel > m_channel
the channel the device is connected to
Ptr< Node > m_node
Node this netDevice is associated to.
uint32_t m_ifIndex
Interface index.
Mac48Address m_address
MAC address.
Ptr< Queue< Packet > > GetQueue() const
Get a copy of the attached Queue.
Ptr< Node > GetNode() const override
bool IsLinkUp() const override
void StartTransmission()
The StartTransmission method is used internally to start the process of sending a packet out on the c...
Address GetBroadcast() const override
NetDevice::PromiscReceiveCallback m_promiscCallback
Promiscuous receive callback.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
bool IsBroadcast() const override
bool SupportsSendFrom() const override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void Receive(Ptr< Packet > packet, uint16_t protocol, Mac48Address to, Mac48Address from)
Receive a packet from a connected SimpleChannel.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
Address GetAddress() const override
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.