/[resiprocate]/main/resip/stack/test/Register.cxx
ViewVC logotype

Contents of /main/resip/stack/test/Register.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5948 - (show annotations) (download)
Fri Feb 17 15:30:16 2006 UTC (13 years, 8 months ago) by dworley
File MIME type: text/plain
File size: 4493 byte(s)
Setting more svn: properties, and adding EOLs to the ends of files
that need it.

1 #include <memory>
2
3 #include "rutil/Logger.hxx"
4 #include "rutil/Timer.hxx"
5
6 #include "resip/stack/SipMessage.hxx"
7 #include "resip/stack/Helper.hxx"
8 #include "Resolver.hxx"
9
10 #include "Register.hxx"
11 #include "Transceiver.hxx"
12
13 using namespace resip;
14 using namespace Loadgen;
15 using namespace std;
16
17 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP
18
19 Register::Register(Transceiver& transceiver, const resip::Uri& registrand,
20 int firstExtension, int lastExtension,
21 int numRegistrations)
22 : mTransceiver(transceiver),
23 mRegistrand(registrand),
24 mFirstExtension(firstExtension),
25 mLastExtension(lastExtension),
26 mNumRegistrations(numRegistrations)
27 {
28 if (mNumRegistrations == 0)
29 {
30 mNumRegistrations = mLastExtension - mFirstExtension;
31 }
32 }
33
34 void
35 Register::go()
36 {
37 int numRegistered = 0;
38
39 Resolver target(mRegistrand);
40 NameAddr registrand;
41 registrand.uri() = mRegistrand;
42 NameAddr aor(registrand);
43
44 NameAddr contact;
45 contact.uri() = mTransceiver.contactUri();
46
47 UInt64 startTime = Timer::getTimeMs();
48 while (numRegistered < mNumRegistrations)
49 {
50 for (int i=mFirstExtension; i < mLastExtension && numRegistered < mNumRegistrations; i++)
51 {
52 aor.uri().user() = Data(i);
53 contact.uri().user() = Data(i);
54
55 auto_ptr<SipMessage> registration(Helper::makeRegister(registrand, aor, contact) );
56 //registration->header(h_Contacts).push_back(contact);
57
58 mTransceiver.send(target, *registration);
59
60 SipMessage* reg = mTransceiver.receive(2000);
61 if(reg)
62 {
63 auto_ptr<SipMessage> forDel(reg);
64 //validate here
65 numRegistered++;
66 }
67 else
68 {
69 ErrLog(<< "Registrar not responding.");
70 assert(0);
71 }
72 }
73 }
74 UInt64 elapsed = Timer::getTimeMs() - startTime;
75 cout << mNumRegistrations << " peformed in " << elapsed << " ms, a rate of "
76 << mNumRegistrations / ((float) elapsed / 1000.0) << " registrations per second." << endl;
77 }
78 /* ====================================================================
79 * The Vovida Software License, Version 1.0
80 *
81 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
82 *
83 * Redistribution and use in source and binary forms, with or without
84 * modification, are permitted provided that the following conditions
85 * are met:
86 *
87 * 1. Redistributions of source code must retain the above copyright
88 * notice, this list of conditions and the following disclaimer.
89 *
90 * 2. Redistributions in binary form must reproduce the above copyright
91 * notice, this list of conditions and the following disclaimer in
92 * the documentation and/or other materials provided with the
93 * distribution.
94 *
95 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
96 * and "Vovida Open Communication Application Library (VOCAL)" must
97 * not be used to endorse or promote products derived from this
98 * software without prior written permission. For written
99 * permission, please contact vocal@vovida.org.
100 *
101 * 4. Products derived from this software may not be called "VOCAL", nor
102 * may "VOCAL" appear in their name, without prior written
103 * permission of Vovida Networks, Inc.
104 *
105 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
106 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
107 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
108 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
109 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
110 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
111 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
112 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
113 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
114 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
116 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
117 * DAMAGE.
118 *
119 * ====================================================================
120 *
121 * This software consists of voluntary contributions made by Vovida
122 * Networks, Inc. and many individuals on behalf of Vovida Networks,
123 * Inc. For more information on Vovida Networks, Inc., please see
124 * <http://www.vovida.org/>.
125 *
126 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27