reSIProcate/stack  9694
Classes | Public Member Functions | Private Member Functions | Private Attributes
Loadgen::InviteClient Class Reference

#include <InviteClient.hxx>

Collaboration diagram for Loadgen::InviteClient:
Collaboration graph
[legend]

List of all members.

Classes

class  Exception

Public Member Functions

 InviteClient (Transceiver &tranceiver, const resip::Uri &proxy, int firstExtension, int lastExtension, int numInvites=0)
void go ()

Private Member Functions

resip::SipMessagewaitForResponse (int responseCode, int waitMs)

Private Attributes

TransceivermTransceiver
resip::Uri mProxy
int mFirstExtension
int mLastExtension
int mNumInvites

Detailed Description

Definition at line 13 of file InviteClient.hxx.


Constructor & Destructor Documentation

InviteClient::InviteClient ( Transceiver tranceiver,
const resip::Uri proxy,
int  firstExtension,
int  lastExtension,
int  numInvites = 0 
)

Definition at line 20 of file InviteClient.cxx.

References mFirstExtension, mLastExtension, and mNumInvites.

   : mTransceiver(transceiver),
     mProxy(proxy),
     mFirstExtension(firstExtension),
     mLastExtension(lastExtension),
     mNumInvites(numInvites)
{
   if (mNumInvites == 0)
   {
      mNumInvites = (mLastExtension - mFirstExtension) / 2;
   }
}

Member Function Documentation

void InviteClient::go ( )

Definition at line 36 of file InviteClient.cxx.

References Loadgen::Transceiver::contactUri(), resip::DeprecatedDialog::createDialogAsUAC(), DebugLog, ErrLog, InfoLog, resip::DeprecatedDialog::makeAck(), resip::DeprecatedDialog::makeBye(), mFirstExtension, mLastExtension, mNumInvites, mProxy, mTransceiver, Loadgen::Transceiver::send(), resip::NameAddr::uri(), resip::Uri::user(), and waitForResponse().

Referenced by main().

{
   int numInvited = 0;
   
   Resolver target(mProxy);

   NameAddr to;
   to.uri() = mProxy;
   
   NameAddr from;
   from.uri() = mProxy;
   
   NameAddr contact;
   contact.uri() = mTransceiver.contactUri();
   
   UInt64 startTime = Timer::getTimeMs();
   InfoLog(<< "Invite client is attempting " << mNumInvites << " calls.");
   while (numInvited < mNumInvites)
   {
      for (int i=mFirstExtension; i < mLastExtension-1 && numInvited < mNumInvites; i+=2)
      {
         contact.uri().user() = Data(i);
         from.uri().user() = Data(i);
         to.uri().user() = Data(i+1);
         
         auto_ptr<SipMessage> invite(Helper::makeInvite(to, from, contact));
         
         mTransceiver.send(target, *invite);
         
         try
         {
            auto_ptr<SipMessage> i_100(waitForResponse(100, 1000));
            auto_ptr<SipMessage> i_180(waitForResponse(180, 1000));
            auto_ptr<SipMessage> i_200(waitForResponse(200, 1000));

            DebugLog(<< "Creating dialog.");
            
            DeprecatedDialog dlog(contact);

            DebugLog(<< "Creating dialog as UAC.");
            dlog.createDialogAsUAC(*i_200);
            
            DebugLog(<< "making ack.");
            auto_ptr<SipMessage> ack(dlog.makeAck(*invite));
            DebugLog(<< "making bye.");
            auto_ptr<SipMessage> bye(dlog.makeBye());

            DebugLog(<< "Sending ack: << *ack");
            
            mTransceiver.send(*ack);
            mTransceiver.send(*bye);
            auto_ptr<SipMessage> b_200(waitForResponse(200, 1000));
            numInvited++;
         }
         catch(Exception e)
         {
            ErrLog(<< "Proxy not responding.");
            exit(-1);
         }
      }
   }
   UInt64 elapsed = Timer::getTimeMs() - startTime;
   cout << mNumInvites << " peformed in " << elapsed << " ms, a rate of " 
        << mNumInvites / ((float) elapsed / 1000.0) << " calls per second." << endl;
}

Here is the call graph for this function:

SipMessage * InviteClient::waitForResponse ( int  responseCode,
int  waitMs 
) [private]

Definition at line 103 of file InviteClient.cxx.

References DebugLog, resip::SipMessage::header(), resip::SipMessage::isResponse(), mTransceiver, and Loadgen::Transceiver::receive().

Referenced by go().

{
   DebugLog(<< "Waiting for a " << responseCode << " for " << waitMs  << "ms");
   SipMessage* reg = mTransceiver.receive(waitMs);
   DebugLog(<< "Finished waiting for " << responseCode);
   if(reg)
   {         
      if (reg->isResponse() &&
          reg->header(h_StatusLine).responseCode() == responseCode)
      {
         return reg;
      }
      else
      {
         throw Exception("Invalid response.", __FILE__, __LINE__);
      }
   }
   else
   {
      throw Exception("Timed out.", __FILE__, __LINE__);
   }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file InviteClient.hxx.

Referenced by go(), and InviteClient().

Definition at line 43 of file InviteClient.hxx.

Referenced by go(), and InviteClient().

Definition at line 44 of file InviteClient.hxx.

Referenced by go(), and InviteClient().

Definition at line 41 of file InviteClient.hxx.

Referenced by go().

Definition at line 40 of file InviteClient.hxx.

Referenced by go(), and waitForResponse().


The documentation for this class was generated from the following files: