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
* 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
30
namespace
ns3
31
{
32
33
class
SimpleNetDevice;
34
class
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
*/
48
class
SimpleChannel
:
public
Channel
49
{
50
public
:
51
/**
52
* \brief Get the type ID.
53
* \return the object TypeId
54
*/
55
static
TypeId
GetTypeId
();
56
SimpleChannel
();
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,
74
Ptr<SimpleNetDevice>
sender);
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
*/
90
virtual
void
BlackList
(
Ptr<SimpleNetDevice>
from,
Ptr<SimpleNetDevice>
to);
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
*/
99
virtual
void
UnBlackList
(
Ptr<SimpleNetDevice>
from,
Ptr<SimpleNetDevice>
to);
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 */
ns3::Channel
Abstract Channel Base Class.
Definition:
channel.h:45
ns3::Mac48Address
an EUI-48 address
Definition:
mac48-address.h:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::SimpleChannel
A simple channel, for simple things and testing.
Definition:
simple-channel.h:49
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:113
ns3::SimpleChannel::m_devices
std::vector< Ptr< SimpleNetDevice > > m_devices
devices connected by the channel
Definition:
simple-channel.h:107
ns3::SimpleChannel::GetDevice
Ptr< NetDevice > GetDevice(std::size_t i) const override
Definition:
simple-channel.cc:106
ns3::SimpleChannel::m_blackListedDevices
std::map< Ptr< SimpleNetDevice >, std::vector< Ptr< SimpleNetDevice > > > m_blackListedDevices
devices blocked on a device
Definition:
simple-channel.h:109
ns3::SimpleChannel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
simple-channel.cc:38
ns3::SimpleChannel::Add
virtual void Add(Ptr< SimpleNetDevice > device)
Attached a net device to the channel.
Definition:
simple-channel.cc:92
ns3::SimpleChannel::m_delay
Time m_delay
The assigned speed-of-light delay of the channel.
Definition:
simple-channel.h:106
ns3::SimpleChannel::GetNDevices
std::size_t GetNDevices() const override
Definition:
simple-channel.cc:99
ns3::SimpleChannel::SimpleChannel
SimpleChannel()
Definition:
simple-channel.cc:52
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:130
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:58
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
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 Tue May 28 2024 23:38:50 for ns-3 by
1.9.6