A Discrete-Event Network Simulator
API
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 
31 namespace ns3
32 {
33 
34 class SimpleNetDevice;
35 class Packet;
36 
42 {
43  public:
48  static TypeId GetTypeId();
49  ErrorChannel();
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 
68  void SetJumpingTime(Time delay);
69 
74  void SetJumpingMode(bool mode);
75 
80  void SetDuplicateTime(Time delay);
81 
86  void SetDuplicateMode(bool mode);
87 
88  private:
89  std::vector<Ptr<SimpleNetDevice>> m_devices;
91  uint8_t m_jumpingState;
92  bool m_jumping;
94  bool m_duplicate;
95  uint8_t m_duplicateState;
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
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.