src/test/ns3tcp/receive-list-error-model.h
changeset 6192 cf8ef89e65c4
child 6273 8d70de29d514
equal deleted inserted replaced
6191:5cde5bcbc902 6192:cf8ef89e65c4
       
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * This program is free software; you can redistribute it and/or modify
       
     4  * it under the terms of the GNU General Public License version 2 as
       
     5  * published by the Free Software Foundation;
       
     6  *
       
     7  * This program is distributed in the hope that it will be useful,
       
     8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
     9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    10  * GNU General Public License for more details.
       
    11  *
       
    12  * You should have received a copy of the GNU General Public License
       
    13  * along with this program; if not, write to the Free Software
       
    14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    15  *
       
    16  * This code should be moved to src/common/error-model.h during ns-3.9 
       
    17  * release cycle with some minor modifications, such as adding GetTypeId 
       
    18  * method and logging to all methods. This can be done by uncommenting 
       
    19  * relavent code below.
       
    20  */
       
    21 #ifndef RECEIVE_LIST_ERROR_MODEL_H
       
    22 #define RECEIVE_LIST_ERROR_MODEL_H
       
    23 
       
    24 #include <list>
       
    25 #include "ns3/error-model.h"
       
    26 #include "ns3/object.h"
       
    27 #include "ns3/random-variable.h"
       
    28 
       
    29 namespace ns3 {
       
    30 
       
    31 class Packet;
       
    32 
       
    33 /**
       
    34  * \brief Provide a list of Packets to corrupt
       
    35  *
       
    36  * This model also processes a user-generated list of packets to
       
    37  * corrupt, except that the list corresponds to the sequence of
       
    38  * received packets as observed by this error model, and not the
       
    39  * Packet UID.
       
    40  * 
       
    41  * Reset() on this model will clear the list
       
    42  *
       
    43  * IsCorrupt() will not modify the packet data buffer
       
    44  */
       
    45 class ReceiveListErrorModel : public ErrorModel
       
    46 {
       
    47 public:
       
    48   /* uncomment GetTypeId when moving to src/common/error-model.h */
       
    49   //static TypeId GetTypeId (void);
       
    50   ReceiveListErrorModel ();
       
    51   virtual ~ReceiveListErrorModel ();
       
    52 
       
    53   /**
       
    54    * \return a copy of the underlying list
       
    55    */
       
    56   std::list<uint32_t> GetList (void) const;
       
    57   /**
       
    58    * \param packetlist The list of packets to error.
       
    59    *
       
    60    * This method overwrites any previously provided list.
       
    61    */
       
    62   void SetList (const std::list<uint32_t> &packetlist);
       
    63 
       
    64 private:
       
    65   virtual bool DoCorrupt (Ptr<Packet> p);
       
    66   virtual void DoReset (void);
       
    67 
       
    68   typedef std::list<uint32_t> PacketList;
       
    69   typedef std::list<uint32_t>::const_iterator PacketListCI;
       
    70 
       
    71   PacketList m_packetList;
       
    72   uint32_t m_timesInvoked;
       
    73   
       
    74 };
       
    75 
       
    76 
       
    77 } //namespace ns3
       
    78 #endif