< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

[reSIProcate] (no subject)


I compile resiprocate-0.9.0-5019 on MS WIndows and want to test its sample with
OnDo SIP server (running on my local pc) I want to send registration
request to server from that test application.
I modify the program as follow. but it not getting sucess ... what can
be the problem ..

int
main(int argc, char* argv[])
{
 char* logType = "cout";
   char* logLevel = "ALERT";
   char* proto = "tcp";
   char* bindAddr = 0;

   int runs = 1;
   int window = 5;
   int seltime = 100;
   int v6 = 0;

#ifdef WIN32
  // logLevel = "ALERT";
  //logLevel = "INFO";
  logLevel = "DEBUG";
#endif

#if defined(HAVE_POPT_H)
   struct poptOption table[] = {
      {"log-type",    'l', POPT_ARG_STRING, &logType,   0, "where to
send logging messages", "syslog|cerr|cout"},
      {"log-level",   'v', POPT_ARG_STRING, &logLevel,  0, "specify
the default log level", "DEBUG|INFO|WARNING|ALERT"},
      {"num-runs",    'r', POPT_ARG_INT,    &runs,      0, "number of
calls in test", 0},
      {"window-size", 'w', POPT_ARG_INT,    &window,    0, "number of
concurrent transactions", 0},
      {"select-time", 's', POPT_ARG_INT,    &seltime,   0, "number of
runs in test", 0},
      {"protocol",    'p', POPT_ARG_STRING, &proto,     0, "protocol
to use (tcp | udp)", 0},
      {"bind",        'b', POPT_ARG_STRING, &bindAddr,  0, "interface
address to bind to",0},
      {"v6",          '6', POPT_ARG_NONE,   &v6     ,   0, "ipv6", 0},
      POPT_AUTOHELP
      { NULL, 0, 0, NULL, 0 }
   };
   
   poptContext context = poptGetContext(NULL, argc, const_cast<const
char**>(argv), table, 0);
   poptGetNextOpt(context);
#endif
   Log::initialize(logType, logLevel, argv[0]);
   cout << "Performing " << runs << " runs." << endl;

   IpVersion version = (v6 ? V6 : V4);
   SipStack receiver;
   SipStack sender;
//   sender.addTransport(UDP, 25060, version); // !ah! just for
debugging TransportSelector
//   sender.addTransport(TCP, 25060, version);
   if (bindAddr)
   {
      InfoLog(<<"Binding to address: " << bindAddr);
      sender.addTransport(UDP, 25070,version,bindAddr);
      sender.addTransport(TCP, 25070,version,bindAddr);
   }
   else
   {
      sender.addTransport(UDP, 25070, version);
      sender.addTransport(TCP, 25070, version);
   }

   
   NameAddr target;
   target.uri().scheme() = "sip";
   target.uri().user() = "a";
   target.uri().host() = bindAddr?bindAddr:DnsUtil::getLocalHostName();
   target.uri().port() = 5060; /* +++ 25080;*/
   target.uri().param(p_transport) = proto;
  
   NameAddr contact;
   contact.uri().scheme() = "sip";
   contact.uri().user() = "ali";

#ifdef WIN32
     target.uri().host() = Data("127.0.0.1");
#endif
   NameAddr from = target;
   from.uri().port() = 25070;
   
   UInt64 startTime = Timer::getTimeMs();
   int outstanding=0;
   int count = 0;
   int sent = 0;
   while (count < runs)
   {
      //InfoLog (<< "count=" << count << " messages=" << messages.size());
      
      // load up the send window
      while (sent < runs && outstanding < window)
      {
         DebugLog (<< "Sending " << count << " / " << runs << " (" <<
outstanding << ")");
         target.uri().port() = 5060;//+++25080; // +(sent%window);
         SipMessage* next = Helper::makeRegister( target, from, contact);
         next->header(h_Vias).front().sentPort() = 25070;
         sender.send(*next);
         outstanding++;
         sent++;
         delete next;
      }

      SipMessage* response = sender.receive();
      if (response)
      {
         assert(response->isResponse());
         assert(response->header(h_CSeq).method() == REGISTER);
         assert(response->header(h_StatusLine).statusCode() == 200);
         outstanding--;
         count++;
         delete response;
      }
   }
   InfoLog (<< "Finished " << count << " runs");
   
   UInt64 elapsed = Timer::getTimeMs() - startTime;
   cout << runs << " registrations peformed in " << elapsed << " ms, a
rate of "
        << runs / ((float) elapsed / 1000.0) << " transactions per
second.]" << endl;
#if defined(HAVE_POPT_H)
   poptFreeContext(context);
#endif
   return 0;
}

-- 
Muhammad Ali