OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2013 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_SIXLOW_H |
| 21 #define ERROR_CHANNEL_SIXLOW_H |
| 22 |
| 23 #include "ns3/channel.h" |
| 24 #include "ns3/simple-channel.h" |
| 25 #include "ns3/error-model.h" |
| 26 #include "ns3/mac48-address.h" |
| 27 #include "ns3/nstime.h" |
| 28 #include <vector> |
| 29 |
| 30 namespace ns3 { |
| 31 |
| 32 class SimpleNetDevice; |
| 33 class Packet; |
| 34 |
| 35 /** |
| 36 * \ingroup channel |
| 37 * \brief A Error channel, introducing deterministic delays on even/odd packets.
Used for testing |
| 38 */ |
| 39 class ErrorChannelSixlow : public SimpleChannel |
| 40 { |
| 41 public: |
| 42 static TypeId GetTypeId (void); |
| 43 ErrorChannelSixlow (); |
| 44 |
| 45 void Send (Ptr<Packet> p, uint16_t protocol, Mac48Address to, Mac48Address fro
m, |
| 46 Ptr<SimpleNetDevice> sender); |
| 47 |
| 48 void Add (Ptr<SimpleNetDevice> device); |
| 49 |
| 50 // inherited from ns3::Channel |
| 51 virtual uint32_t GetNDevices (void) const; |
| 52 virtual Ptr<NetDevice> GetDevice (uint32_t i) const; |
| 53 |
| 54 /** |
| 55 * \brief Set the delay for the odd packets (even ones are not delayed) |
| 56 * \param delay Delay for the odd packets. |
| 57 */ |
| 58 void SetJumpingTime (Time delay); |
| 59 |
| 60 /** |
| 61 * \brief Set if the odd packets are delayed (even ones are not delayed ever) |
| 62 * \param mode true if the odd packets should be delayed. |
| 63 */ |
| 64 void SetJumpingMode (bool mode); |
| 65 |
| 66 /** |
| 67 * \brief Set the delay for the odd duplicate packets (even ones are not dupli
cated) |
| 68 * \param delay Delay for the odd packets. |
| 69 */ |
| 70 void SetDuplicateTime (Time delay); |
| 71 |
| 72 /** |
| 73 * \brief Set if the odd packets are duplicated (even ones are not duplicated
ever) |
| 74 * \param mode true if the odd packets should be duplicated. |
| 75 */ |
| 76 void SetDuplicateMode (bool mode); |
| 77 |
| 78 private: |
| 79 std::vector<Ptr<SimpleNetDevice> > m_devices; |
| 80 Time m_jumpingTime; |
| 81 uint8_t m_jumpingState; |
| 82 bool m_jumping; |
| 83 Time m_duplicateTime; |
| 84 bool m_duplicate; |
| 85 uint8_t m_duplicateState; |
| 86 }; |
| 87 |
| 88 class BinaryErrorSixlowModel : public ErrorModel |
| 89 { |
| 90 public: |
| 91 static TypeId GetTypeId (void); |
| 92 |
| 93 BinaryErrorSixlowModel (); |
| 94 virtual ~BinaryErrorSixlowModel (); |
| 95 void Reset (void); |
| 96 |
| 97 private: |
| 98 virtual bool DoCorrupt (Ptr<Packet> p); |
| 99 virtual void DoReset (void); |
| 100 |
| 101 uint8_t m_counter; |
| 102 |
| 103 }; |
| 104 |
| 105 } // namespace ns3 |
| 106 |
| 107 #endif /* ERROR_CHANNEL_SIXLOW_H */ |
OLD | NEW |