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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7 */
8#ifndef ERROR_CHANNEL_H
9#define ERROR_CHANNEL_H
10
11#include "error-model.h"
12#include "mac48-address.h"
13#include "simple-channel.h"
14
15#include "ns3/channel.h"
16#include "ns3/nstime.h"
17
18#include <vector>
19
20namespace ns3
21{
22
23class SimpleNetDevice;
24class Packet;
25
26/**
27 * \ingroup channel
28 * \brief A Error channel, introducing deterministic delays on even/odd packets. Used for testing
29 */
31{
32 public:
33 /**
34 * \brief Get the type ID.
35 * \return the object TypeId
36 */
37 static TypeId GetTypeId();
39
40 // inherited from ns3::SimpleChannel
41 void Send(Ptr<Packet> p,
42 uint16_t protocol,
43 Mac48Address to,
44 Mac48Address from,
45 Ptr<SimpleNetDevice> sender) override;
46
47 void Add(Ptr<SimpleNetDevice> device) override;
48
49 // inherited from ns3::Channel
50 std::size_t GetNDevices() const override;
51 Ptr<NetDevice> GetDevice(std::size_t i) const override;
52
53 /**
54 * \brief Set the delay for the odd packets (even ones are not delayed)
55 * \param delay Delay for the odd packets.
56 */
57 void SetJumpingTime(Time delay);
58
59 /**
60 * \brief Set if the odd packets are delayed (even ones are not delayed ever)
61 * \param mode true if the odd packets should be delayed.
62 */
63 void SetJumpingMode(bool mode);
64
65 /**
66 * \brief Set the delay for the odd duplicate packets (even ones are not duplicated)
67 * \param delay Delay for the odd packets.
68 */
69 void SetDuplicateTime(Time delay);
70
71 /**
72 * \brief Set if the odd packets are duplicated (even ones are not duplicated ever)
73 * \param mode true if the odd packets should be duplicated.
74 */
75 void SetDuplicateMode(bool mode);
76
77 private:
78 std::vector<Ptr<SimpleNetDevice>> m_devices; //!< devices connected by the channel
79 Time m_jumpingTime; //!< Delay time in Jumping mode.
80 uint8_t m_jumpingState; //!< Counter for even/odd packets in Jumping mode.
81 bool m_jumping; //!< Flag for Jumping mode.
82 Time m_duplicateTime; //!< Duplicate time in Duplicate mode.
83 bool m_duplicate; //!< Flag for Duplicate mode.
84 uint8_t m_duplicateState; //!< Counter for even/odd packets in Duplicate mode.
85};
86
87} // namespace ns3
88
89#endif /* ERROR_CHANNEL_H */
A Error channel, introducing deterministic delays on even/odd packets.
Time m_duplicateTime
Duplicate time in Duplicate mode.
uint8_t m_duplicateState
Counter for even/odd packets in Duplicate mode.
static TypeId GetTypeId()
Get the type ID.
std::size_t GetNDevices() const override
bool m_jumping
Flag for Jumping mode.
std::vector< Ptr< SimpleNetDevice > > m_devices
devices connected by the channel
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.
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.
bool m_duplicate
Flag for Duplicate mode.
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
A simple channel, for simple things and testing.
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.