A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
19
namespace
ns3
20
{
21
22
class
SimpleNetDevice;
23
class
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
*/
37
class
SimpleChannel
:
public
Channel
38
{
39
public
:
40
/**
41
* \brief Get the type ID.
42
* \return the object TypeId
43
*/
44
static
TypeId
GetTypeId
();
45
SimpleChannel
();
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,
63
Ptr<SimpleNetDevice>
sender);
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
*/
79
virtual
void
BlackList
(
Ptr<SimpleNetDevice>
from,
Ptr<SimpleNetDevice>
to);
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
*/
88
virtual
void
UnBlackList
(
Ptr<SimpleNetDevice>
from,
Ptr<SimpleNetDevice>
to);
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 */
ns3::Channel
Abstract Channel Base Class.
Definition
channel.h:34
ns3::Mac48Address
an EUI-48 address
Definition
mac48-address.h:35
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SimpleChannel
A simple channel, for simple things and testing.
Definition
simple-channel.h:38
ns3::SimpleChannel::BlackList
virtual void BlackList(Ptr< SimpleNetDevice > from, Ptr< SimpleNetDevice > to)
Blocks the communications from a NetDevice to another NetDevice.
Definition
simple-channel.cc:102
ns3::SimpleChannel::m_devices
std::vector< Ptr< SimpleNetDevice > > m_devices
devices connected by the channel
Definition
simple-channel.h:96
ns3::SimpleChannel::GetDevice
Ptr< NetDevice > GetDevice(std::size_t i) const override
Definition
simple-channel.cc:95
ns3::SimpleChannel::m_blackListedDevices
std::map< Ptr< SimpleNetDevice >, std::vector< Ptr< SimpleNetDevice > > > m_blackListedDevices
devices blocked on a device
Definition
simple-channel.h:98
ns3::SimpleChannel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
simple-channel.cc:27
ns3::SimpleChannel::Add
virtual void Add(Ptr< SimpleNetDevice > device)
Attached a net device to the channel.
Definition
simple-channel.cc:81
ns3::SimpleChannel::m_delay
Time m_delay
The assigned speed-of-light delay of the channel.
Definition
simple-channel.h:95
ns3::SimpleChannel::GetNDevices
std::size_t GetNDevices() const override
Definition
simple-channel.cc:88
ns3::SimpleChannel::SimpleChannel
SimpleChannel()
Definition
simple-channel.cc:41
ns3::SimpleChannel::UnBlackList
virtual void UnBlackList(Ptr< SimpleNetDevice > from, Ptr< SimpleNetDevice > to)
Un-Blocks the communications from a NetDevice to another NetDevice.
Definition
simple-channel.cc:119
ns3::SimpleChannel::Send
virtual void Send(Ptr< Packet > p, uint16_t protocol, Mac48Address to, Mac48Address from, Ptr< SimpleNetDevice > sender)
A packet is sent by a net device.
Definition
simple-channel.cc:47
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
mac48-address.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
simple-channel.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0