src/stats/helper/delay-jitter-estimation.h
changeset 10122 91258aa2436b
parent 10121 d6fc35b77a85
child 10123 332a850cd191
equal deleted inserted replaced
10121:d6fc35b77a85 10122:91258aa2436b
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2007 INRIA
       
     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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    19  */
       
    20 #ifndef DELAY_JITTER_ESTIMATION_H
       
    21 #define DELAY_JITTER_ESTIMATION_H
       
    22 
       
    23 #include "ns3/nstime.h"
       
    24 #include "ns3/packet.h"
       
    25 
       
    26 namespace ns3 {
       
    27 
       
    28 /**
       
    29  * \ingroup stats
       
    30  *
       
    31  * \brief quick and dirty delay and jitter estimation
       
    32  *
       
    33  */
       
    34 class DelayJitterEstimation
       
    35 {
       
    36 public:
       
    37   DelayJitterEstimation ();
       
    38 
       
    39   /**
       
    40    * \param packet the packet to send over a wire
       
    41    *
       
    42    * This method should be invoked once on each packet to
       
    43    * record within the packet the tx time which is used upon
       
    44    * packet reception to calculate the delay and jitter. The
       
    45    * tx time is stored in the packet as an ns3::Tag which means
       
    46    * that it does not use any network resources and is not
       
    47    * taken into account in transmission delay calculations.
       
    48    */
       
    49   static void PrepareTx (Ptr<const Packet> packet);
       
    50   /**
       
    51    * \param packet the packet received
       
    52    *
       
    53    * Invoke this method to update the delay and jitter calculations
       
    54    * After a call to this method, \ref GetLastDelay and \ref GetLastJitter
       
    55    * will return an updated delay and jitter.
       
    56    */
       
    57   void RecordRx (Ptr<const Packet> packet);
       
    58 
       
    59   /**
       
    60    * \returns the updated delay.
       
    61    */
       
    62   Time GetLastDelay (void) const;
       
    63   /**
       
    64    * The jitter is calculated using the RFC 1889 (RTP) jitter
       
    65    * definition.
       
    66    *
       
    67    * \returns the updated jitter.
       
    68    */
       
    69   uint64_t GetLastJitter (void) const;
       
    70 
       
    71 private:
       
    72   Time m_previousRx;
       
    73   Time m_previousRxTx;
       
    74   int64x64_t m_jitter;
       
    75   Time m_delay;
       
    76 };
       
    77 
       
    78 } // namespace ns3
       
    79 
       
    80 #endif /* DELAY_JITTER_ESTIMATION_H */