A Discrete-Event Network Simulator
API
error-channel.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Universita' di Firenze, Italy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  */
20 #ifndef ERROR_CHANNEL_H
21 #define ERROR_CHANNEL_H
22 
23 #include "ns3/simple-channel.h"
24 #include "ns3/error-model.h"
25 #include "ns3/mac48-address.h"
26 #include "ns3/nstime.h"
27 #include <vector>
28 
29 namespace ns3 {
30 
31 class SimpleNetDevice;
32 class Packet;
33 
39 {
40 public:
41  static TypeId GetTypeId (void);
42  ErrorChannel ();
43 
44  virtual void Send (Ptr<Packet> p, uint16_t protocol, Mac48Address to, Mac48Address from,
45  Ptr<SimpleNetDevice> sender);
46 
47  virtual void Add (Ptr<SimpleNetDevice> device);
48 
49  // inherited from ns3::Channel
50  virtual uint32_t GetNDevices (void) const;
51  virtual Ptr<NetDevice> GetDevice (uint32_t i) const;
52 
57  void SetJumpingTime(Time delay);
58 
63 void SetJumpingMode(bool mode);
64 
65 private:
66  std::vector<Ptr<SimpleNetDevice> > m_devices;
68  uint8_t jumpingState;
69  bool jumping;
70 
71 };
72 
74 {
75 public:
76  static TypeId GetTypeId (void);
77 
79  virtual ~BinaryErrorModel ();
80  void Reset (void);
81 
82 private:
83  virtual bool DoCorrupt (Ptr<Packet> p);
84  virtual void DoReset (void);
85 
86  uint8_t counter;
87 
88 };
89 
90 } // namespace ns3
91 
92 #endif /* ERROR_CHANNEL_H */
virtual bool DoCorrupt(Ptr< Packet > p)
Corrupt a packet according to the specified model.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
std::vector< Ptr< SimpleNetDevice > > m_devices
Definition: error-channel.h:66
static TypeId GetTypeId(void)
General error model that can be used to corrupt packets.
Definition: error-model.h:115
virtual void DoReset(void)
Re-initialize any state.
static TypeId GetTypeId(void)
void SetJumpingMode(bool mode)
Set if the odd packets are delayed (even ones are not delayed ever)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
an EUI-48 address
Definition: mac48-address.h:43
A Error channel, introducing deterministic delays on even/odd packets.
Definition: error-channel.h:38
A simple channel, for simple things and testing.
void SetJumpingTime(Time delay)
Set the delay for the odd packets (even ones are not delayed)
virtual void Add(Ptr< SimpleNetDevice > device)
Attached a net device to the channel.
virtual void Send(Ptr< Packet > p, uint16_t protocol, Mac48Address to, Mac48Address from, Ptr< SimpleNetDevice > sender)
A packet is sent by a net device.
virtual uint32_t GetNDevices(void) const
a unique identifier for an interface.
Definition: type-id.h:58
virtual Ptr< NetDevice > GetDevice(uint32_t i) const