A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
error-channel.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Universita' di Firenze, Italy
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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19#ifndef ERROR_CHANNEL_H
20#define ERROR_CHANNEL_H
21
22#include "error-model.h"
23#include "mac48-address.h"
24#include "simple-channel.h"
25
26#include "ns3/channel.h"
27#include "ns3/nstime.h"
28
29#include <vector>
30
31namespace ns3
32{
33
34class SimpleNetDevice;
35class Packet;
36
37/**
38 * \ingroup channel
39 * \brief A Error channel, introducing deterministic delays on even/odd packets. Used for testing
40 */
42{
43 public:
44 /**
45 * \brief Get the type ID.
46 * \return the object TypeId
47 */
48 static TypeId GetTypeId();
50
51 // inherited from ns3::SimpleChannel
52 void Send(Ptr<Packet> p,
53 uint16_t protocol,
54 Mac48Address to,
55 Mac48Address from,
56 Ptr<SimpleNetDevice> sender) override;
57
58 void Add(Ptr<SimpleNetDevice> device) override;
59
60 // inherited from ns3::Channel
61 std::size_t GetNDevices() const override;
62 Ptr<NetDevice> GetDevice(std::size_t i) const override;
63
64 /**
65 * \brief Set the delay for the odd packets (even ones are not delayed)
66 * \param delay Delay for the odd packets.
67 */
68 void SetJumpingTime(Time delay);
69
70 /**
71 * \brief Set if the odd packets are delayed (even ones are not delayed ever)
72 * \param mode true if the odd packets should be delayed.
73 */
74 void SetJumpingMode(bool mode);
75
76 /**
77 * \brief Set the delay for the odd duplicate packets (even ones are not duplicated)
78 * \param delay Delay for the odd packets.
79 */
80 void SetDuplicateTime(Time delay);
81
82 /**
83 * \brief Set if the odd packets are duplicated (even ones are not duplicated ever)
84 * \param mode true if the odd packets should be duplicated.
85 */
86 void SetDuplicateMode(bool mode);
87
88 private:
89 std::vector<Ptr<SimpleNetDevice>> m_devices; //!< devices connected by the channel
90 Time m_jumpingTime; //!< Delay time in Jumping mode.
91 uint8_t m_jumpingState; //!< Counter for even/odd packets in Jumping mode.
92 bool m_jumping; //!< Flag for Jumping mode.
93 Time m_duplicateTime; //!< Duplicate time in Duplicate mode.
94 bool m_duplicate; //!< Flag for Duplicate mode.
95 uint8_t m_duplicateState; //!< Counter for even/odd packets in Duplicate mode.
96};
97
98} // namespace ns3
99
100#endif /* ERROR_CHANNEL_H */
A Error channel, introducing deterministic delays on even/odd packets.
Definition: error-channel.h:42
Time m_duplicateTime
Duplicate time in Duplicate mode.
Definition: error-channel.h:93
uint8_t m_duplicateState
Counter for even/odd packets in Duplicate mode.
Definition: error-channel.h:95
static TypeId GetTypeId()
Get the type ID.
std::size_t GetNDevices() const override
bool m_jumping
Flag for Jumping mode.
Definition: error-channel.h:92
std::vector< Ptr< SimpleNetDevice > > m_devices
devices connected by the channel
Definition: error-channel.h:89
void Send(Ptr< Packet > p, uint16_t protocol, Mac48Address to, Mac48Address from, Ptr< SimpleNetDevice > sender) override
A packet is sent by a net device.
void SetJumpingTime(Time delay)
Set the delay for the odd packets (even ones are not delayed)
void SetJumpingMode(bool mode)
Set if the odd packets are delayed (even ones are not delayed ever)
Ptr< NetDevice > GetDevice(std::size_t i) const override
void SetDuplicateMode(bool mode)
Set if the odd packets are duplicated (even ones are not duplicated ever)
Time m_jumpingTime
Delay time in Jumping mode.
Definition: error-channel.h:90
void Add(Ptr< SimpleNetDevice > device) override
Attached a net device to the channel.
void SetDuplicateTime(Time delay)
Set the delay for the odd duplicate packets (even ones are not duplicated)
uint8_t m_jumpingState
Counter for even/odd packets in Jumping mode.
Definition: error-channel.h:91
bool m_duplicate
Flag for Duplicate mode.
Definition: error-channel.h:94
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.
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.