Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a simple application for measuring response time. #127

Open
DmitryIsakbayev opened this issue Nov 15, 2017 · 2 comments
Open

Need a simple application for measuring response time. #127

DmitryIsakbayev opened this issue Nov 15, 2017 · 2 comments

Comments

@DmitryIsakbayev
Copy link

I need a simple application that measures response times for the progress and final messages. It is working, but the calculated times are very different from the times reported on the wire.

For example, while my application reports 14ms progress and 29ms final, the actual messages on the wire arrive after less than 1ms and 16ms.

I have tried a similar test using SIPp and its results are very close to the actual messages on the wire.

What can I do to improve accuracy?

Here is a simplified version of my code

function ping(fromUser,toUser,toHost) {
  var to = 'sip:' + toUser + '@' + toHost;
  var from='sip:'+fromUser + '@' + 'sip-ping-test';
  var startTime = new Date();

  sip.send({
    method: 'INVITE',
    uri: to,
    headers: {
      to: {uri: to},
      from: {uri: from, params: {tag: rstring()}},
      'call-id': rstring(),
      cseq: {method: 'INVITE', seq: Math.floor(Math.random() * 1e5)},
      contact: [{uri: from}]
    }
  },
  function(rs) {
    if (rs.status < 200) { 
      console.info('progressResponseTime = ' + (new Date() - startTime));
    } else {
      console.info('finalResponseTime = ' + (new Date() - startTime));
    }
  });
}
@DmitryIsakbayev
Copy link
Author

Perhaps a stateless client will be more accurate. Is there an example? I see an example for stateless-registrar-redirector.js

@DmitryIsakbayev
Copy link
Author

Using the transport API seems to produce similar results.

var startTime;

var transport = sip.makeTransport({publicAddress : localIp}, function(rs, remote) {
  if (rs.status < 200) {
    console.info('progressResponseTime = ' + (new Date() - startTime));
  } else {
    console.info('finalResponseTime = ' + (new Date() - startTime));
  }
});

function ping(fromUser,toUser,toHost) {
  var to = 'sip:' + toUser + '@' + toHost;
  var from='sip:'+fromUser + '@' + 'sip-ping-test';

  var remote =
    {
      "protocol": "UDP",
      "address": toHost,
      "port": 5060
    };

  var message = 
    {
      method: 'INVITE',
      uri: to,
      headers: {
        to: {uri: to},
        from: {uri: from, params: {tag: rstring()}},
        'call-id': rstring(),
        cseq: {method: 'INVITE', seq: Math.floor(Math.random() * 1e5)},
        contact: [{uri: from}],
        via: [{params: {}}]
      }
    };

  startTime = new Date();
  transport.send(remote,message);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant