TAO_AV_RTCP Class Reference

Encapsulate the header format for the Real Time Control Protocol (RTCP). More...

#include <RTCP.h>

List of all members.

Static Public Member Functions

static void send_report (ACE_Message_Block *mb)
static ACE_UINT32 alloc_srcid (ACE_UINT32 addr)
static double rtcp_interval (int members, int senders, double rtcp_bw, int we_sent, int packet_size, int *avg_rtcp_size, int initial)

Classes

struct  md5_string
struct  ntp64
struct  rtcphdr


Detailed Description

Encapsulate the header format for the Real Time Control Protocol (RTCP).

Definition at line 72 of file RTCP.h.


Member Function Documentation

ACE_UINT32 TAO_AV_RTCP::alloc_srcid ( ACE_UINT32  addr  )  [static]

Definition at line 191 of file RTCP.cpp.

References ACE_OS::getgid(), ACE_OS::getpgid(), ACE_OS::getpid(), ACE_OS::getppid(), ACE_OS::gettimeofday(), ACE_OS::getuid(), TAO_AV_RTCP::md5_string::gid, MD5Final(), MD5Init(), MD5Update(), TAO_AV_RTCP::md5_string::pgid, TAO_AV_RTCP::md5_string::pid, TAO_AV_RTCP::md5_string::ppid, TAO_AV_RTCP::md5_string::tv, TAO_AV_RTCP::md5_string::type, and TAO_AV_RTCP::md5_string::uid.

Referenced by TAO_AV_RTP_Object::TAO_AV_RTP_Object(), and TAO_StreamCtrl::TAO_StreamCtrl().

00192 {
00193   md5_string s;
00194 
00195   s.type = addr;
00196   s.tv = ACE_OS::gettimeofday ();
00197   s.pid = ACE_OS::getpid();
00198   s.pgid = ACE_OS::getpgid(s.pid);
00199   s.ppid = ACE_OS::getppid();
00200   s.uid = ACE_OS::getuid();
00201   s.gid = ACE_OS::getgid();
00202 
00203   unsigned char *string_val = (unsigned char *) &s;
00204   int length = sizeof(s);
00205 
00206   MD5_CTX context;
00207   union
00208     {
00209       char c[16];
00210       u_long x[4];
00211     } digest;
00212   ACE_UINT32 r;
00213   int i;
00214 
00215   MD5Init (&context);
00216   MD5Update (&context, string_val, length);
00217   MD5Final ((unsigned char*)&digest, &context);
00218   r=0;
00219   for (i=0; i<3; i++)
00220     r ^= digest.x[i];
00221 
00222   return r;
00223 
00224 /* used to be this
00225   ACE_Time_Value tv = ACE_OS::gettimeofday ();
00226   ACE_UINT32 srcid = ACE_UINT32 (tv.sec () + tv.usec ());
00227   srcid += (ACE_UINT32)ACE_OS::getuid();
00228   srcid += (ACE_UINT32)ACE_OS::getpid();
00229   srcid += addr;
00230   return (srcid);
00231 */
00232 }

double TAO_AV_RTCP::rtcp_interval ( int  members,
int  senders,
double  rtcp_bw,
int  we_sent,
int  packet_size,
int *  avg_rtcp_size,
int  initial 
) [static]

Definition at line 236 of file RTCP.cpp.

References ACE_OS::rand(), RTCP_MIN_RPT_TIME, RTCP_RECEIVER_BW_FRACTION, RTCP_SENDER_BW_FRACTION, RTCP_SIZE_GAIN, ACE_OS::srand(), and ACE_OS::time().

Referenced by TAO_AV_RTCP_Callback::get_timeout().

00243 {
00244   // Minimum time between RTCP packets from this site (in sec.).
00245   // This time prevents the reports from 'clumping' when sessions
00246   // are small and the law of large numbers isn't helping to smooth
00247   // out the traffic.  It also keeps the report interval from
00248   // becoming ridiculously small during transient outages like a
00249   // network partition.
00250 //  double const RTCP_MIN_TIME = 5.0;   (from RTP.h)
00251 
00252   // Fraction of the RTCP bandwidth to be shared among active
00253   // senders.  (This fraction was chosen so that in a typical
00254   // session with one or two active senders, the computed report
00255   // time would be roughly equal to the minimum report time so that
00256   // we don't unnecessarily slow down receiver reports.) The
00257   // receiver fraction must be 1 - the sender fraction.
00258 //  double const RTCP_SENDER_BW_FRACTION = 0.25;   (from RTP.h)
00259 //  double const RTCP_RCVR_BW_FRACTION = (1-RTCP_SENDER_BW_FRACTION); (from RTP.h)
00260 
00261   // Gain (smoothing constant) for the low-pass filter that
00262   // estimates the average RTCP packet size
00263 //  double const RTCP_SIZE_GAIN = (1.0/16.0);   (from RTP.h)
00264 
00265   double t;
00266   double rtcp_min_time = RTCP_MIN_RPT_TIME;
00267   int n;   // number of members for computation
00268 
00269   // Very first call at application start-up uses half the min
00270   // delay for quicker notification while still allowing some time
00271   // before reporting for randomization and to learn about other
00272   // sources so the report interval will converge to the correct
00273   // interval more quickly.  The average RTCP size is initialized
00274   // to 128 octets which is conservative (it assumes everyone else
00275   // is generating SRs instead of RRs: 20 IP + 8 UDP + 52 SR + 48
00276   // SDES CNAME).
00277   if (initial)
00278     {
00279       // initialize the random number generator
00280       ACE_OS::srand(ACE_OS::time(0L));
00281 
00282       rtcp_min_time /= 2;
00283       *avg_rtcp_size = 128;
00284     }
00285 
00286   // If there were active senders, give them at least a minimum
00287   // share of the RTCP bandwidth.  Otherwise all participants share
00288   // the RTCP bandwidth equally.
00289   n = members;
00290   if ((senders > 0) && (senders < members*RTCP_SENDER_BW_FRACTION))
00291     {
00292       if (we_sent)
00293         {
00294           rtcp_bw *= RTCP_SENDER_BW_FRACTION;
00295           n = senders;
00296         }
00297       else
00298         {
00299           rtcp_bw *= RTCP_RECEIVER_BW_FRACTION;
00300           n -= senders;
00301         }
00302     }
00303 
00304   // Update the average size estimate by the size of the report
00305   // packet we just sent.
00306   *avg_rtcp_size += (int)((packet_size - *avg_rtcp_size)*RTCP_SIZE_GAIN);
00307 
00308   // The effective number of sites times the average packet size is
00309   // the total number of octets sent when each site sends a report.
00310   // Dividing this by the effective bandwidth gives the time
00311   // interval over which those packets must be sent in order to
00312   // meet the bandwidth target, with a minimum enforced.  In that
00313   // time interval we send one report so this time is also our
00314   // average time between reports.
00315   t = (*avg_rtcp_size) * n / rtcp_bw;
00316   if (t < rtcp_min_time)
00317     t = rtcp_min_time;
00318 
00319   // To avoid traffic bursts from unintended synchronization with
00320   // other sites, we then pick our actual next report interval as a
00321   // random number uniformly distributed between 0.5*t and 1.5*t.
00322 
00323   // TODO: this may not be right.  need a random number between 0 and 1
00324   int max_rand = 32768;
00325 
00326   return t * ((double)ACE_OS::rand()/max_rand + 0.5);
00327 //  return t * (drand48() + 0.5);
00328 }

static void TAO_AV_RTCP::send_report ( ACE_Message_Block mb  )  [static]


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:48:02 2010 for TAO_AV by  doxygen 1.4.7