00001 #ifndef DELAY_JITTER_ESTIMATION_H 00002 #define DELAY_JITTER_ESTIMATION_H 00003 00004 #include "ns3/nstime.h" 00005 #include "ns3/packet.h" 00006 00007 namespace ns3 { 00008 00009 /** 00010 * \brief quick and dirty delay and jitter estimation 00011 * 00012 */ 00013 class DelayJitterEstimation 00014 { 00015 public: 00016 DelayJitterEstimation (); 00017 00018 /** 00019 * \param packet the packet to send over a wire 00020 * 00021 * This method should be invoked once on each packet to 00022 * record within the packet the tx time which is used upon 00023 * packet reception to calculate the delay and jitter. The 00024 * tx time is stored in the packet as an ns3::Tag which means 00025 * that it does not use any network ressources and is not 00026 * taken into account in transmission delay calculations. 00027 */ 00028 static void PrepareTx (Ptr<const Packet> packet); 00029 /** 00030 * \param packet the packet received 00031 * 00032 * Invoke this method to update the delay and jitter calculations 00033 * After a call to this method, \ref GetLastDelay and \ref GetLastJitter 00034 * will return an updated delay and jitter. 00035 */ 00036 void RecordRx (Ptr<const Packet> packet); 00037 00038 /** 00039 * \returns the updated delay. 00040 */ 00041 Time GetLastDelay (void) const; 00042 /** 00043 * The jitter is calculated using the RFC 1889 (RTP) jitter 00044 * definition. 00045 * 00046 * \returns the updated jitter. 00047 */ 00048 Time GetLastJitter (void) const; 00049 00050 private: 00051 Time m_previousRx; 00052 Time m_previousRxTx; 00053 Time m_jitter; 00054 Time m_delay; 00055 }; 00056 00057 } // namespace ns3 00058 00059 #endif /* DELAY_JITTER_ESTIMATION_H */