A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
simple-channel.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_CHANNEL_H
20#define SIMPLE_CHANNEL_H
21
22#include "mac48-address.h"
23
24#include "ns3/channel.h"
25#include "ns3/nstime.h"
26
27#include <map>
28#include <vector>
29
30namespace ns3
31{
32
33class SimpleNetDevice;
34class Packet;
35
36/**
37 * \ingroup channel
38 * \brief A simple channel, for simple things and testing.
39 *
40 * This channel doesn't check for packet collisions and it
41 * does not introduce any error.
42 * By default, it does not add any delay to the packets.
43 * Furthermore, it assumes that the associated NetDevices
44 * are using 48-bit MAC addresses.
45 *
46 * This channel is meant to be used by ns3::SimpleNetDevices.
47 */
48class SimpleChannel : public Channel
49{
50 public:
51 /**
52 * \brief Get the type ID.
53 * \return the object TypeId
54 */
55 static TypeId GetTypeId();
57
58 /**
59 * A packet is sent by a net device. A receive event will be
60 * scheduled for all net device connected to the channel other
61 * than the net device who sent the packet
62 *
63 * \param p packet to be sent
64 * \param protocol protocol number
65 * \param to address to send packet to
66 * \param from address the packet is coming from
67 * \param sender netdevice who sent the packet
68 *
69 */
70 virtual void Send(Ptr<Packet> p,
71 uint16_t protocol,
72 Mac48Address to,
73 Mac48Address from,
75
76 /**
77 * Attached a net device to the channel.
78 *
79 * \param device the device to attach to the channel
80 */
81 virtual void Add(Ptr<SimpleNetDevice> device);
82
83 /**
84 * Blocks the communications from a NetDevice to another NetDevice.
85 * The block is unidirectional
86 *
87 * \param from the device to BlackList
88 * \param to the device wanting to block the other one
89 */
91
92 /**
93 * Un-Blocks the communications from a NetDevice to another NetDevice.
94 * The block is unidirectional
95 *
96 * \param from the device to BlackList
97 * \param to the device wanting to block the other one
98 */
100
101 // inherited from ns3::Channel
102 std::size_t GetNDevices() const override;
103 Ptr<NetDevice> GetDevice(std::size_t i) const override;
104
105 private:
106 Time m_delay; //!< The assigned speed-of-light delay of the channel
107 std::vector<Ptr<SimpleNetDevice>> m_devices; //!< devices connected by the channel
108 std::map<Ptr<SimpleNetDevice>, std::vector<Ptr<SimpleNetDevice>>>
109 m_blackListedDevices; //!< devices blocked on a device
110};
111
112} // namespace ns3
113
114#endif /* SIMPLE_CHANNEL_H */
Abstract Channel Base Class.
Definition: channel.h:45
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
A simple channel, for simple things and testing.
virtual void BlackList(Ptr< SimpleNetDevice > from, Ptr< SimpleNetDevice > to)
Blocks the communications from a NetDevice to another NetDevice.
std::vector< Ptr< SimpleNetDevice > > m_devices
devices connected by the channel
Ptr< NetDevice > GetDevice(std::size_t i) const override
std::map< Ptr< SimpleNetDevice >, std::vector< Ptr< SimpleNetDevice > > > m_blackListedDevices
devices blocked on a device
static TypeId GetTypeId()
Get the type ID.
virtual void Add(Ptr< SimpleNetDevice > device)
Attached a net device to the channel.
Time m_delay
The assigned speed-of-light delay of the channel.
std::size_t GetNDevices() const override
virtual void UnBlackList(Ptr< SimpleNetDevice > from, Ptr< SimpleNetDevice > to)
Un-Blocks the communications from a NetDevice to another NetDevice.
virtual void Send(Ptr< Packet > p, uint16_t protocol, Mac48Address to, Mac48Address from, Ptr< SimpleNetDevice > sender)
A packet is sent by a net device.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.