Source: congestionmanagerclient.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                      RTP Audio Server Project                    ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Congestion Manager Client                                        ####
// ####                                                                  ####
// #### Version 1.00  --  February 23, 2001                              ####
// ####                                                                  ####
// #### Copyright (C) 1999  Thomas Dreibholz                             ####
// ####               2000  Universität Bonn, Abt. IV                    ####
// ####               2001  EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef CONGESTIONMANAGERCLIENT_H
#define CONGESTIONMANAGERCLIENT_H


#include "system.h"
#include "timedthread.h"
#include "socket.h"
#include "internetaddress.h"
#include "extendedtransportinfo.h"
#include "congestionmanagerpacket.h"


#include <multimap.h>
#include <algo.h>


namespace Coral {


/**
  * This class implements a client for the congestion manager. Multiple streams
  * can be managed over one connection to the manager.
  *
  * @short   Congestion Manager Client
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
class CongestionManagerClient : public TimedThread
{
   // ====== Constructor/Destructor =========================================
   public:
   /**
     * Constructor for a new CongestionManagerClient.
     *
     * @param manager Address to congestion manager (e.g. "odin:7600").
     */
   CongestionManagerClient(const char* manager);

   /**
     * Destructor.
     */
   ~CongestionManagerClient();


   // ====== Status functions ===============================================
   /**
     * Check, if CongestionManagerClient is ready.
     *
     * @return true, if ready; false otherwise.
     */
   inline bool ready() const;

   /**
     * Get number of streams manager by this client.
     *
     * @return Number of streams.
     */
   inline cardinal getStreams();


   // ====== Adding and removing streams ====================================
   /**
     * Add a new stream.
     *
     * @param identifier Identifer for the stream (has to be unique within the client, but not the manager!).
     * @param streamDescription ExtendedTransportInfo of the stream.
     * @return true, if stream has been added; false otherwise.
     */
   bool addStream(const cardinal               identifier,
                  const ExtendedTransportInfo& streamDescription);

   /**
     * Remove stream with given identifier.
     *
     * @param identifier Identifer of the stream.
     */
   void removeStream(const cardinal identifier);


   // ====== TransportInfo functions ========================================
   /**
     * Get suggested transport info of a given identifier.
     *
     * @param identifier Identifer of the stream.
     * @param streamDescription Memory to store the ExtendedTransportInfo structure.
     * @return true, if transportInfo contains a new suggestion; false if there is no valid suggestion receiver from manager.
     */
   bool getSuggestedTransportInfo(const cardinal         identifier,
                                  ExtendedTransportInfo& streamDescription);

   /**
     * Set transport info of a given identifier for a given identifier.
     *
     * @param identifier Identifer of the stream.
     * @param streamDescription New ExtendedTransportInfo.
     */
   void setTransportInfo(const cardinal               identifier,
                         const ExtendedTransportInfo& streamDescription);


   // ====== Constants ======================================================
   /**
     * IPv6 traffic class of CongestionManagerClient.
     */
   static const card8 CongestionManagerClientTrafficClass = 0x00;


   // ====== Private data ===================================================
   private:
   void timerEvent();
   void sendRequests();
   void receiveResponses();
   void handleSuggestion(const CongestionManagerSuggestion* suggestion);


   struct ManagedStream {
      ExtendedTransportInfo                StreamDescription;
      card32                               Identifier;
      ExtendedTransportInfo                Suggestion;
      card16                               SequenceNumber;
      card16                               LastSuggestion;
   };


   Socket                                  ManagerSocket;
   InternetFlow                            Flow;
   Socket                                  ReplySocket;
   PortableAddress                         ReplyAddress;
   multimap<const cardinal,ManagedStream*> StreamSet;
   card16                                  SequenceNumber;
   bool                                    Ready;
};


}


#include "congestionmanagerclient.icc"


#endif

Generated by: viper@odin on Fri Feb 23 12:41:26 2001, using kdoc 2.0a36.