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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef SIMPLE_CHANNEL_H
9#define SIMPLE_CHANNEL_H
10
11#include "mac48-address.h"
12
13#include "ns3/channel.h"
14#include "ns3/nstime.h"
15
16#include <map>
17#include <vector>
18
19namespace ns3
20{
21
22class SimpleNetDevice;
23class Packet;
24
25/**
26 * \ingroup channel
27 * \brief A simple channel, for simple things and testing.
28 *
29 * This channel doesn't check for packet collisions and it
30 * does not introduce any error.
31 * By default, it does not add any delay to the packets.
32 * Furthermore, it assumes that the associated NetDevices
33 * are using 48-bit MAC addresses.
34 *
35 * This channel is meant to be used by ns3::SimpleNetDevices.
36 */
37class SimpleChannel : public Channel
38{
39 public:
40 /**
41 * \brief Get the type ID.
42 * \return the object TypeId
43 */
44 static TypeId GetTypeId();
46
47 /**
48 * A packet is sent by a net device. A receive event will be
49 * scheduled for all net device connected to the channel other
50 * than the net device who sent the packet
51 *
52 * \param p packet to be sent
53 * \param protocol protocol number
54 * \param to address to send packet to
55 * \param from address the packet is coming from
56 * \param sender netdevice who sent the packet
57 *
58 */
59 virtual void Send(Ptr<Packet> p,
60 uint16_t protocol,
61 Mac48Address to,
62 Mac48Address from,
64
65 /**
66 * Attached a net device to the channel.
67 *
68 * \param device the device to attach to the channel
69 */
70 virtual void Add(Ptr<SimpleNetDevice> device);
71
72 /**
73 * Blocks the communications from a NetDevice to another NetDevice.
74 * The block is unidirectional
75 *
76 * \param from the device to BlackList
77 * \param to the device wanting to block the other one
78 */
80
81 /**
82 * Un-Blocks the communications from a NetDevice to another NetDevice.
83 * The block is unidirectional
84 *
85 * \param from the device to BlackList
86 * \param to the device wanting to block the other one
87 */
89
90 // inherited from ns3::Channel
91 std::size_t GetNDevices() const override;
92 Ptr<NetDevice> GetDevice(std::size_t i) const override;
93
94 private:
95 Time m_delay; //!< The assigned speed-of-light delay of the channel
96 std::vector<Ptr<SimpleNetDevice>> m_devices; //!< devices connected by the channel
97 std::map<Ptr<SimpleNetDevice>, std::vector<Ptr<SimpleNetDevice>>>
98 m_blackListedDevices; //!< devices blocked on a device
99};
100
101} // namespace ns3
102
103#endif /* SIMPLE_CHANNEL_H */
Abstract Channel Base Class.
Definition channel.h:34
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
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:94
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.