From 133069a10085a551b202967f09f4dda8d8457353 Mon Sep 17 00:00:00 2001 From: Dletta Date: Tue, 17 Aug 2021 15:00:38 -0500 Subject: [PATCH 1/7] Loop Logic with Flag Added --loop [Number of Loops] / Depending on your system this may cause high resource consumption. Added simple call (6 Messages) to use with loop option. --- README.md | 5 ++ config/loop_simple.js | 121 ++++++++++++++++++++++++++++++++++++++++++ hepgen.js | 86 +++++++++++++++++++----------- package.json | 2 +- 4 files changed, 181 insertions(+), 33 deletions(-) create mode 100644 config/loop_simple.js diff --git a/README.md b/README.md index b1f6ff1..85f64e9 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,8 @@ hepgen.js -s 127.0.0.1 -p 9063 -P "./path/to/SIP.pcap-txt" ``` hepgen.js -d ``` + +### Loop a Call multiple times (Be careful how you use it) +``` +hepgen.js -s 127.0.0.1 -p 9060 -c "./config/loop_simple.js" --loop 5 //loop same call 5 times +``` diff --git a/config/loop_simple.js b/config/loop_simple.js new file mode 100644 index 0000000..b9f7fd5 --- /dev/null +++ b/config/loop_simple.js @@ -0,0 +1,121 @@ +/* HEPGEN Autogenerated from file => pcap2021-08-17T16 22 30.428Z.txt */ +var callId = Math.random().toString(36).substring(7) + '@127.0.0.1'; + +var config = { + NAME:"HEPGEN Simple Call 1 Leg for Looping", + HEP_SERVER:"127.0.0.1", + HEP_PORT:9060, + HEP_ID:"2001", + HEP_AUTH:"myHep", + MESSAGES: [ + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"169.141.53.213", + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"INVITE sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nContact: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nAllow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS\r\nSupported: replaces, 100rel, timer, norefersub\r\nSession-Expires: 1800\r\nMin-SE: 90\r\nUser-Agent: Hepgen/123\r\nContent-Type: application/sdp\r\nContent-Length: 319\r\n\r\nv=0\r\no=- 3837167151 3837167151 IN IP4 192.168.153.1\r\ns=HepGen 127.0.0.1\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4000 RTP/AVP 8 101\r\nc=IN IP4 192.168.153.1\r\nb=TIAS:64000\r\na=rtcp:4001 IN IP4 192.168.153.1\r\na=sendrecv\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ssrc:1889210388 cname:1a107f3e441a1640\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:"169.141.53.213", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresher=uas\r\nContact: \r\nContent-Length: 319\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:"169.141.53.213", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresh=uas\r\nContact: \r\nRequire: timer\r\nContent-Type: application/sdp\r\nContent-Length: 254\r\n\r\nv=0\r\no=root 1850387284 1850387284 IN IP4 169.141.53.213\r\ns=Asterisk PBX 16.17.0.1\r\nc=IN IP4 169.141.53.213\r\nt=0 0\r\nm=audio 16110 RTP/AVP 8 101\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ptime:20\r\na=maxptime:150\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"169.141.53.213", + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"ACK sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nContact: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 ACK\r\nUser-Agent: Hepgen/123\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:"169.141.53.213", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"BYE sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 102 BYE\r\nUser-Agent: Hepgen/123\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"169.141.53.213", + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nCall-ID: "+callId+"\r\nFrom: \r\nTo: \r\nCSeq: 102 BYE\r\nContent-Length: 0\r\n\r\n\r\n", + }, + ] +}; +module.exports = config; diff --git a/hepgen.js b/hepgen.js index aed41ad..d2bbe83 100755 --- a/hepgen.js +++ b/hepgen.js @@ -7,7 +7,7 @@ var net = require('net') const execSync = require('child_process').execSync; const exec = require('child_process').exec; -var version = 'v1.0.9'; +var version = 'v1.1.0'; var debug = false; var stats = {rcvd: 0, parsed: 0, hepsent: 0, err: 0, heperr: 0 }; var socketUsers = 0; @@ -149,44 +149,60 @@ var count = 0; var pause = 0; const execHEP = function(messages) { + if(debug)console.log('loop', _config_.LOOP_MESSAGE) count = messages.length; - messages.forEach(function preHep(message) { + if(_config_.LOOP_MESSAGE > 0) { + count = messages.length * _config_.LOOP_MESSAGE; + while(_config_.LOOP_MESSAGE > 0) { + if(debug)console.log('loop', _config_.LOOP_MESSAGE) + var upperCall = _config_.LOOP_MESSAGE + Math.random().toString(36).substring(7) + '@127.0.0.1' + messages.forEach(preHep); + --_config_.LOOP_MESSAGE; + } + } else { + messages.forEach(preHep); + } +} - var rcinfo = message.rcinfo; - var msg = message.payload; - if (debug) console.log(msg); - stats.rcvd++; +/* messages processing and sending */ - if (message.sleep) { - console.log('sleeping '+message.sleep+' ms...'); - sleep( message.sleep ); - } +function preHep(message) { - var hrTime = process.hrtime(); - var datenow = new Date().getTime(); - rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; - - if (debug) console.log(rcinfo); - if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; - if (message.pause && message.pause > 0) { - pause += message.pause; - setTimeout(function() { - // delayed ts - var datenow = new Date().getTime(); - rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; - routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); - }, pause); - } else { - routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); - } - }); +var rcinfo = message.rcinfo; +var msg = message.payload; +if (debug) console.log(msg); +stats.rcvd++; + +if (message.sleep) { + console.log('sleeping '+message.sleep+' ms...'); + sleep( message.sleep ); +} + +var hrTime = process.hrtime(); +var datenow = new Date().getTime(); +rcinfo.time_sec = Math.floor( datenow / 1000); +rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + +if (debug) console.log(rcinfo); +if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; +if (message.pause && message.pause > 0) { + pause += message.pause; + setTimeout(function() { + // delayed ts + var datenow = new Date().getTime(); + rcinfo.time_sec = Math.floor( datenow / 1000); + rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + routeOUT(msg,rcinfo); + process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); + }, pause); +} else { + routeOUT(msg,rcinfo); + process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); +} } + /* Beginning of execution */ if(process.argv.indexOf("-d") != -1){ @@ -197,6 +213,7 @@ var _config_ = require("./config/default"); if(process.argv.indexOf("-c") != -1){ _config_ = require(process.argv[process.argv.indexOf("-c") + 1]); + if(process.argv.indexOf("-d") != -1){ debug = true; } @@ -215,6 +232,11 @@ if(process.argv.indexOf("-c") != -1){ } else { _config_.SOCKET_TYPE = 'udp4'; } + // loop flag for load testing + if(process.argv.indexOf("--loop") != -1) { + if(debug)console.log('Got Loop Setting with ', process.argv[process.argv.indexOf("--loop") + 1], process.argv) + _config_.LOOP_MESSAGE = new Number(process.argv[process.argv.indexOf("--loop") + 1]); + } if (debug) console.log(_config_); execHEP(_config_.MESSAGES); diff --git a/package.json b/package.json index cf36db9..1e98cd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hepgen.js", - "version": "1.0.9", + "version": "1.1.0", "description": "HEP Message Generator", "author": "lorenzo.mangani@gmail.com", "dependencies": { From df9840adb33c4e788b594ee4db3b9f862bec0b09 Mon Sep 17 00:00:00 2001 From: Dletta Date: Tue, 17 Aug 2021 15:02:14 -0500 Subject: [PATCH 2/7] line fix --- config/loop_simple.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/loop_simple.js b/config/loop_simple.js index b9f7fd5..51ef527 100644 --- a/config/loop_simple.js +++ b/config/loop_simple.js @@ -42,7 +42,7 @@ var config = { dstPort:5060, }, pause:1, - payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresher=uas\r\nContact: \r\nContent-Length: 319\r\n\r\n", + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresher=uas\r\nContact: \r\nContent-Length: 319\r\n\r\n", }, { rcinfo:{ @@ -60,7 +60,7 @@ var config = { dstPort:5060, }, pause:1, - payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresh=uas\r\nContact: \r\nRequire: timer\r\nContent-Type: application/sdp\r\nContent-Length: 254\r\n\r\nv=0\r\no=root 1850387284 1850387284 IN IP4 169.141.53.213\r\ns=Asterisk PBX 16.17.0.1\r\nc=IN IP4 169.141.53.213\r\nt=0 0\r\nm=audio 16110 RTP/AVP 8 101\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ptime:20\r\na=maxptime:150\r\na=sendrecv\r\n\r\n", + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresh=uas\r\nContact: \r\nRequire: timer\r\nContent-Type: application/sdp\r\nContent-Length: 254\r\n\r\nv=0\r\no=root 1850387284 1850387284 IN IP4 169.141.53.213\r\ns=Asterisk PBX 16.17.0.1\r\nc=IN IP4 169.141.53.213\r\nt=0 0\r\nm=audio 16110 RTP/AVP 8 101\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ptime:20\r\na=maxptime:150\r\na=sendrecv\r\n\r\n", }, { rcinfo:{ From 70f454796f33a90840e43afdb910e7a487aa3d06 Mon Sep 17 00:00:00 2001 From: Dletta Date: Wed, 29 Sep 2021 15:49:03 -0500 Subject: [PATCH 3/7] WIP - STILL BROKEN --- config/loop_random_src.js | 143 ++++++++++++++++++++++++++++++++++++++ hepgen.js | 104 ++++++++++++++------------- 2 files changed, 198 insertions(+), 49 deletions(-) create mode 100644 config/loop_random_src.js diff --git a/config/loop_random_src.js b/config/loop_random_src.js new file mode 100644 index 0000000..9c8efe7 --- /dev/null +++ b/config/loop_random_src.js @@ -0,0 +1,143 @@ +/* HEPGEN Autogenerated from file => pcap2021-08-17T16 22 30.428Z.txt */ + +var randomByte = function() { + return Math.round(Math.random()*254); +} + + +var randomIp = function() { + var ip = randomByte() +'.' + + randomByte() +'.' + + randomByte() +'.' + + randomByte(); + if (isPrivate(ip)) return randomIp(); + return ip; +} + +var isPrivate = function(ip) { + return /^10\.|^192\.168\.|^172\.16\.|^172\.17\.|^172\.18\.|^172\.19\.|^172\.20\.|^172\.21\.|^172\.22\.|^172\.23\.|^172\.24\.|^172\.25\.|^172\.26\.|^172\.27\.|^172\.28\.|^172\.29\.|^172\.30\.|^172\.31\./.test(ip); +} + +var srcIp = randomIp(); + +var callId = Math.random().toString(36).substring(7) + '@127.0.0.1'; + + +var config = { + NAME:"HEPGEN Simple Call 1 Leg for Looping", + HEP_SERVER:"127.0.0.1", + HEP_PORT:9060, + HEP_ID:"2001", + HEP_AUTH:"myHep", + MESSAGES: [ + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:srcIp, + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"INVITE sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nContact: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nAllow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS\r\nSupported: replaces, 100rel, timer, norefersub\r\nSession-Expires: 1800\r\nMin-SE: 90\r\nUser-Agent: Hepgen/123\r\nContent-Type: application/sdp\r\nContent-Length: 319\r\n\r\nv=0\r\no=- 3837167151 3837167151 IN IP4 192.168.153.1\r\ns=HepGen 127.0.0.1\r\nb=AS:84\r\nt=0 0\r\na=X-nat:0\r\nm=audio 4000 RTP/AVP 8 101\r\nc=IN IP4 192.168.153.1\r\nb=TIAS:64000\r\na=rtcp:4001 IN IP4 192.168.153.1\r\na=sendrecv\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ssrc:1889210388 cname:1a107f3e441a1640\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:srcIp, + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresher=uas\r\nContact: \r\nContent-Length: 319\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:srcIp, + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 INVITE\r\nServer: Hepgen Fake 123\r\nAllow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE\r\nSupported: replaces, timer\r\nSession-Expires: 1800;refresh=uas\r\nContact: \r\nRequire: timer\r\nContent-Type: application/sdp\r\nContent-Length: 254\r\n\r\nv=0\r\no=root 1850387284 1850387284 IN IP4 169.141.53.213\r\ns=Asterisk PBX 16.17.0.1\r\nc=IN IP4 169.141.53.213\r\nt=0 0\r\nm=audio 16110 RTP/AVP 8 101\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-16\r\na=ptime:20\r\na=maxptime:150\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:srcIp, + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"ACK sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nContact: \r\nCall-ID: "+callId+"\r\nCSeq: 31911 ACK\r\nUser-Agent: Hepgen/123\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"137.25.72.83", + dstIp:srcIp, + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"BYE sip:5000@sip.botauro.com SIP/2.0\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nMax-Forwards: 70\r\nFrom: \r\nTo: \r\nCall-ID: "+callId+"\r\nCSeq: 102 BYE\r\nUser-Agent: Hepgen/123\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:srcIp, + dstIp:"137.25.72.83", + srcPort:5060, + dstPort:5060, + }, + pause:1, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 169.141.53.213:5060\r\nCall-ID: "+callId+"\r\nFrom: \r\nTo: \r\nCSeq: 102 BYE\r\nContent-Length: 0\r\n\r\n\r\n", + }, + ] +}; +module.exports = config; diff --git a/hepgen.js b/hepgen.js index d2bbe83..ea339e6 100755 --- a/hepgen.js +++ b/hepgen.js @@ -148,60 +148,48 @@ function sleep(ms) { var count = 0; var pause = 0; -const execHEP = function(messages) { - if(debug)console.log('loop', _config_.LOOP_MESSAGE) +const execHEP = async function(messages) { count = messages.length; - if(_config_.LOOP_MESSAGE > 0) { - count = messages.length * _config_.LOOP_MESSAGE; - while(_config_.LOOP_MESSAGE > 0) { - if(debug)console.log('loop', _config_.LOOP_MESSAGE) - var upperCall = _config_.LOOP_MESSAGE + Math.random().toString(36).substring(7) + '@127.0.0.1' - messages.forEach(preHep); - --_config_.LOOP_MESSAGE; - } - } else { - messages.forEach(preHep); - } -} - -/* messages processing and sending */ -function preHep(message) { - -var rcinfo = message.rcinfo; -var msg = message.payload; -if (debug) console.log(msg); -stats.rcvd++; + for (var message of messages) { + console.log('processing count', count--); + await preHep(message) + } -if (message.sleep) { - console.log('sleeping '+message.sleep+' ms...'); - sleep( message.sleep ); } -var hrTime = process.hrtime(); -var datenow = new Date().getTime(); -rcinfo.time_sec = Math.floor( datenow / 1000); -rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; - -if (debug) console.log(rcinfo); -if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; -if (message.pause && message.pause > 0) { - pause += message.pause; - setTimeout(function() { - // delayed ts - var datenow = new Date().getTime(); - rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; - routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); - }, pause); -} else { - routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); -} -} +async function preHep(message) { + var rcinfo = message.rcinfo; + var msg = message.payload; + if (debug) console.log(msg); + stats.rcvd++; + if (message.sleep) { + console.log('sleeping '+message.sleep+' ms...'); + sleep( message.sleep ); + } + var hrTime = process.hrtime(); + var datenow = new Date().getTime(); + rcinfo.time_sec = Math.floor( datenow / 1000); + rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + + if (debug) console.log(rcinfo); + if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; + if (message.pause && message.pause > 0) { + pause += message.pause; + await new Promise(f => setTimeout(f, pause)) + var datenow = new Date().getTime(); + rcinfo.time_sec = Math.floor( datenow / 1000); + rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + routeOUT(msg,rcinfo); + process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); + } else { + routeOUT(msg,rcinfo); + process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); + } + return true +} /* Beginning of execution */ @@ -213,7 +201,6 @@ var _config_ = require("./config/default"); if(process.argv.indexOf("-c") != -1){ _config_ = require(process.argv[process.argv.indexOf("-c") + 1]); - if(process.argv.indexOf("-d") != -1){ debug = true; } @@ -236,10 +223,29 @@ if(process.argv.indexOf("-c") != -1){ if(process.argv.indexOf("--loop") != -1) { if(debug)console.log('Got Loop Setting with ', process.argv[process.argv.indexOf("--loop") + 1], process.argv) _config_.LOOP_MESSAGE = new Number(process.argv[process.argv.indexOf("--loop") + 1]); + _config_.LOOPED = true + var path = process.argv[process.argv.indexOf("-c") + 1] } if (debug) console.log(_config_); - execHEP(_config_.MESSAGES); + if(_config_.LOOPED){ + console.log('we are looping'); + startLoop(); + } else { + execHEP(_config_.MESSAGES); + } +} + +async function startLoop() { + var messages = _config_.MESSAGES; + while(_config_.LOOP_MESSAGE > 0) { + console.log("looping now", _config_.LOOP_MESSAGE); + await execHEP(messages); + delete require.cache[path] + let conf = require(path) + messages = conf.MESSAGES + --_config_.LOOP_MESSAGE + } } var socket = getSocket(_config_.SOCKET_TYPE); From 82e64a525a39c7095e912c451c0a757476d2eb80 Mon Sep 17 00:00:00 2001 From: Dletta Date: Thu, 30 Sep 2021 14:14:03 -0500 Subject: [PATCH 4/7] loop version --- hepgen.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hepgen.js b/hepgen.js index ea339e6..667526c 100755 --- a/hepgen.js +++ b/hepgen.js @@ -148,11 +148,12 @@ function sleep(ms) { var count = 0; var pause = 0; -const execHEP = async function(messages) { +const execHEP = async function(messages, loopCount) { count = messages.length; + count *= loopCount || 1; for (var message of messages) { - console.log('processing count', count--); + if(debug)console.log('processing count: ', count) await preHep(message) } @@ -240,7 +241,8 @@ async function startLoop() { var messages = _config_.MESSAGES; while(_config_.LOOP_MESSAGE > 0) { console.log("looping now", _config_.LOOP_MESSAGE); - await execHEP(messages); + await execHEP(messages, _config_.LOOP_MESSAGE); + // re-evaluate for randomness (otherwise callid stays the same) delete require.cache[path] let conf = require(path) messages = conf.MESSAGES From 629b687f1dffa0f93442f90be23e3743bead9ff2 Mon Sep 17 00:00:00 2001 From: Dletta Date: Thu, 30 Sep 2021 14:45:28 -0500 Subject: [PATCH 5/7] hide console.log when looped --- hepgen.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hepgen.js b/hepgen.js index 667526c..b12d638 100755 --- a/hepgen.js +++ b/hepgen.js @@ -52,8 +52,8 @@ var countDown = function(){ count--; if (count == 0) { if(socket && socket.hasOwnProperty('close')) socket.close(); - console.log(stats); - console.log('Done! Exiting...'); + if(!_config_.LOOPED)console.log(stats); + if(!_config_.LOOPED)console.log('Done! Exiting...'); process.exit(0); } } @@ -129,7 +129,7 @@ var sendAPI = function(msg,rcinfo){ } var routeOUT = function(msg,rcinfo){ - console.log('ROUTING',msg,rcinfo); + if(!_config_.LOOPED)console.log('ROUTING',msg,rcinfo); if (rcinfo.type === "HEP"){ sendHEP3(msg,rcinfo); } else if(rcinfo.type === "API") { @@ -184,10 +184,10 @@ async function preHep(message) { rcinfo.time_sec = Math.floor( datenow / 1000); rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); + if(!_config_.LOOPED)process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); } else { routeOUT(msg,rcinfo); - process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); + if(_config_.LOOPED)process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); } return true } @@ -230,7 +230,7 @@ if(process.argv.indexOf("-c") != -1){ if (debug) console.log(_config_); if(_config_.LOOPED){ - console.log('we are looping'); + if(debug)console.log('we are looping'); startLoop(); } else { execHEP(_config_.MESSAGES); @@ -240,7 +240,7 @@ if(process.argv.indexOf("-c") != -1){ async function startLoop() { var messages = _config_.MESSAGES; while(_config_.LOOP_MESSAGE > 0) { - console.log("looping now", _config_.LOOP_MESSAGE); + if(debug)console.log("looping now", _config_.LOOP_MESSAGE); await execHEP(messages, _config_.LOOP_MESSAGE); // re-evaluate for randomness (otherwise callid stays the same) delete require.cache[path] From e680aafaf15d17efe93d7fe56c16adcd05617980 Mon Sep 17 00:00:00 2001 From: Dletta Date: Wed, 17 Nov 2021 21:21:47 -0600 Subject: [PATCH 6/7] microseconds translated correctly --- .DS_Store | Bin 0 -> 6148 bytes hepgen.js | 6 +- package.json | 2 +- tools/pcap2hepgen.js | 368 ++++++++++---------- tools/test2.js | 811 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1007 insertions(+), 180 deletions(-) create mode 100644 .DS_Store create mode 100644 tools/test2.js diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a0b52f9a81ff9e2f1dd12fa214a3606e2890b59e GIT binary patch literal 6148 zcmeH~F%H5o3`K1y5)um|V-^m;4I)%dzy%O=tkj{f=jePpURsz@g}y82$4&z68|qp_ z^!(~hB6|_p!cFC9!^{-%MxHX@>SgT4M}HrN-qNy)y%xan8`JezrjP&$kN^pg00}IJ zfERJp|J{P_iMK)mB(Mwu_I^lk(;Ql=`l|zjw*b%vX*bNhmw+ZqKyzrRiVRGnd(b$l z-iBD-k3&=J%b}%eJuVu}hsHmvbulol$3+tYm}VCaBtQZ)0_z&@t^Qx&-}?XA5r!l{ z0)Iw8oA%nC@la7)KOWEWx5(POz@fe!!{j3XftBI|+zso=CeR#Osv-m9hk#??KmtD{ F@CNjO6RH3J literal 0 HcmV?d00001 diff --git a/hepgen.js b/hepgen.js index b12d638..b3efef6 100755 --- a/hepgen.js +++ b/hepgen.js @@ -7,7 +7,7 @@ var net = require('net') const execSync = require('child_process').execSync; const exec = require('child_process').exec; -var version = 'v1.1.0'; +var version = 'v1.1.5'; var debug = false; var stats = {rcvd: 0, parsed: 0, hepsent: 0, err: 0, heperr: 0 }; var socketUsers = 0; @@ -173,7 +173,7 @@ async function preHep(message) { var hrTime = process.hrtime(); var datenow = new Date().getTime(); rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + rcinfo.time_usec = ((datenow - (rcinfo.time_sec*1000))*1000)+rcinfo.time_usec; if (debug) console.log(rcinfo); if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; @@ -182,7 +182,7 @@ async function preHep(message) { await new Promise(f => setTimeout(f, pause)) var datenow = new Date().getTime(); rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = (datenow - (rcinfo.time_sec*1000))*1000; + rcinfo.time_usec = ((datenow - (rcinfo.time_sec*1000))*1000)+rcinfo.time_usec; routeOUT(msg,rcinfo); if(!_config_.LOOPED)process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); } else { diff --git a/package.json b/package.json index 1e98cd7..c4de78b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hepgen.js", - "version": "1.1.0", + "version": "1.1.5", "description": "HEP Message Generator", "author": "lorenzo.mangani@gmail.com", "dependencies": { diff --git a/tools/pcap2hepgen.js b/tools/pcap2hepgen.js index 600c158..7f0d5e4 100755 --- a/tools/pcap2hepgen.js +++ b/tools/pcap2hepgen.js @@ -2,199 +2,215 @@ /* PCAP TEXT to HEPGEN Convertor */ /* Modules import */ -const os = require('os'); -const fs = require('fs'); -var args = process.argv.slice(2); -const parSIP = require('parsip'); -const debug = false; + +const fs = require('fs') +const args = process.argv.slice(2) +const parSIP = require('parsip') +const debug = true if (!args || !args[0]) { - if(debug)console.log('{}'); - process.exit(1); + if (debug)console.log('{}') + process.exit(1) } -var cache = { previous: { time_sec:0, time_usec:0 } }; -var net_regex = /([A-Z]+) ([0-9]+-[0-9]+-[0-9]+)T[0-9]+:[0-9]+:([0-9]+).([0-9]+)(.*)\s([0-9]+.[0-9]+.[0-9]+.[0-9]+):([0-9]+)(.*)\s([0-9]+.[0-9]+.[0-9]+.[0-9]+):([0-9]+)/i -var callids = []; +/* when converting pcaps, we are only interested in the time difference + between messages, as we will use them for 'sleeping' + */ +const cache = { previous: { time: 0 } } // set this to 0 +const netRegex = /([A-Z]+) ([0-9]+-[0-9]+-[0-9]+)T[0-9]+:[0-9]+:([0-9]+).([0-9]+)(.*)\s([0-9]+.[0-9]+.[0-9]+.[0-9]+):([0-9]+)(.*)\s([0-9]+.[0-9]+.[0-9]+.[0-9]+):([0-9]+)/i +const callids = [] -if(debug)console.log('Reading SIP from file: ',args[0] ); +if (debug)console.log('Reading SIP from file: ', args[0]) /* Moved to Async Sugar */ -var fileContent = new Promise((res, rej) => { - //promisify readFile - fs.readFile(args[0], 'utf8', (err, contents)=>{ - if(debug)console.log('read file about to resolve', err, contents.length); - if(err) { - rej(err); - return; - } - - if(contents){ - if(debug)console.log('resolving content'); - res(contents); - return; - } - }) +const fileContent = new Promise((resolve, reject) => { + // promisify readFile + fs.readFile(args[0], 'utf8', (err, contents) => { + if (debug)console.log('read file about to resolve', err, contents.length) + if (err) { + reject(err) + return + } + + if (contents) { + if (debug)console.log('resolving content') + resolve(contents) + } + }) }) -fileContent.then(handleContent).catch(handleError); +fileContent.then(handleContent).catch(handleError) async function handleContent (contents) { - if(debug)console.log('handler Content called -----------------'); - var parsed = contents.split('proto:'); - - //console.log('parsed array of promises?', parsed, parsed.length); - - var messages = []; - - for(let key in parsed) { - //console.log('trying row', key, parsed[key]); - try{ - let msg = await handleRow(parsed[key]) - messages.push(msg) - } catch (err) { - console.log('caught in promise', err) - } - } - - var config = { - NAME: 'HEPGEN '+args[0], - HEP_SERVER: '127.0.0.1', - HEP_PORT: 9060, - HEP_ID: '2001', - HEP_AUTH: 'myHep', - // the Messages to send - MESSAGES: messages - }; - - var output = "/* HEPGEN Autogenerated from file => " + args[0] + " */\r\n" - output += 'var config = { \r\n'; - for(let key of Object.keys(config)) { - console.log(key, key !== "MESSAGES") - if(key !== "MESSAGES"){ - if(typeof config[key] == 'string') { - output += ' ' + key + ":" + '"' + config[key] + '",\r\n' - } else { - output += ' ' + key + ":" + config[key] + ",\r\n" - } - } - } - output += " MESSAGES: [ \r\n" - for(let item of config["MESSAGES"]) { - output += ' ' - output += item - output += ',\r\n' - } - output += " ]\r\n};\r\n" - output += "module.exports = config;" - if(debug)console.log('writing to file',output); - fs.writeFile(args[1], output, console.log) + if (debug)console.log('handler Content called -----------------') + const parsed = contents.split('proto:') + parsed.shift() + // console.log('parsed array of promises?', parsed, parsed.length); + + const messages = [] + + for (const key in parsed) { + try { + const msg = await handleRow(parsed[key], key) + messages.push(msg) + } catch (err) { + console.log('caught in promise', err) + } + } + + const config = { + NAME: 'HEPGEN ' + args[0], + HEP_SERVER: '127.0.0.1', + HEP_PORT: 9060, + HEP_ID: '2001', + HEP_AUTH: 'myHep', + // the Messages to send + MESSAGES: messages + } + + let output = '/* HEPGEN Autogenerated from file => ' + args[0] + ' */\r\n' + output += 'var config = { \r\n' + for (const key of Object.keys(config)) { + console.log(key, key !== 'MESSAGES') + if (key !== 'MESSAGES') { + if (typeof config[key] === 'string') { + output += ' ' + key + ':' + '"' + config[key] + '",\r\n' + } else { + output += ' ' + key + ':' + config[key] + ',\r\n' + } + } + } + output += ' MESSAGES: [ \r\n' + for (const item of config.MESSAGES) { + output += ' ' + output += item + output += ',\r\n' + } + output += ' ]\r\n};\r\n' + output += 'module.exports = config;' + if (debug)console.log('writing to file', output) + fs.writeFile(args[1], output, console.log) } function handleError (err) { - throw err; + throw err } /* function to handle each SIP Row / Message */ -async function handleRow (row) { - if(debug)console.log('handling row'); - return new Promise(function (res, rej) { - if(debug)console.log('IN PROMISE'); - var detectedEOL = '\r\n'; - var detect = row.split(/[0-9]\n|[a-z]\n/); - if(detect.length > 1){detectedEOL = '\n'} - if(debug)console.log('detected following EOL in file', JSON.stringify(detectedEOL)) - var tmp = row.split(/---> [0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+\r\n\r\n|---> [0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+\n\n/); - //if(debug)console.log('temp', tmp); - var match = []; - if (!tmp[1] || !row ) { - if(debug)console.log('stopped it', !tmp[1], !row); - rej('error'); - } - else { - if(debug)console.log('parsing') - var rawSIP = tmp[1].split(detectedEOL).join('\r\n'); - var mSIP = parSIP.getSIP( rawSIP ); - //console.log(mSIP, '-----------------'); - - // Replace Session Identifiers need to be unique - if (mSIP) { - if (mSIP.call_id) { - if (!callids[mSIP.call_id]) { callids[mSIP.call_id] = Math.random().toString(36).substring(8) + mSIP.call_id } - if(debug)console.log('replacing call_id',mSIP.call_id, callids[mSIP.call_id]); - rawSIP = rawSIP.split(mSIP.call_id).join(callids[mSIP.call_id]); - }; - if (mSIP.via_branch) { - if (!callids[mSIP.via_branch]) { callids[mSIP.via_branch] = Math.random().toString(36).substring(8) + mSIP.via_branch } - if(debug)console.log('replacing via_branch',mSIP.via_branch, callids[mSIP.via_branch]); - rawSIP = rawSIP.split(mSIP.via_branch).join(callids[mSIP.via_branch]) - }; - if (mSIP.from_tag) { - if (!callids[mSIP.from_tag]) { callids[mSIP.from_tag] = Math.random().toString(36).substring(8) + mSIP.from_tag } - if(debug)console.log('replacing from_tag',mSIP.from_tag, callids[mSIP.from_tag]); - rawSIP = rawSIP.split(mSIP.from_tag).join(callids[mSIP.from_tag]) - }; - if (mSIP.to_tag) { - if (!callids[mSIP.to_tag]) { callids[mSIP.to_tag] = Math.random().toString(36).substring(8) + mSIP.to_tag } - if(debug)console.log('replacing to_tag',mSIP.to_tag, callids[mSIP.to_tag]); - rawSIP = rawSIP.split(mSIP.to_tag).join(callids[mSIP.to_tag]) - }; - } - } - // create message block for configuration - if(debug)console.log('making a block from ', tmp[0]); - - var block = row.replace(net_regex, function(match, proto, date, time, time_micro, unused, from_ip, from_port, divide, to_ip, to_port ) { - //console.log("args for replace", arguments); - time = parseInt(time); time_micro = parseInt(time_micro); - from_port = parseInt(from_port); to_port = parseInt(to_port); - var block = { - rcinfo: { - type: 'HEP', - version: 3, - //time_sec: (time), - //time_usec: (time_micro), - payload_type: 1, - captureId: '2001', - capturePass: 'myHep', - ip_family: 2, - protocol: proto === 'UDP' ? 17 : 6, - proto_type: 1, - srcIp: from_ip, - dstIp: to_ip, - srcPort: from_port, - dstPort: to_port - }, - pause: parseInt(time - cache.previous.time_sec +''+ time_micro- cache.previous.time_usec) || 0, - payload: JSON.stringify(rawSIP || tmp[1]) - }; - cache.previous = { time_sec: time, time_usec: time_micro }; - var string = '{\r\n'; - for(let key of Object.keys(block)) { - if(key == 'rcinfo') { - string += ' rcinfo:{ \r\n' - for(let item2 of Object.keys(block.rcinfo)) { - string += ' ' + item2 + ":" - if(typeof block.rcinfo[item2] == 'string') { - string += '"' + block.rcinfo[item2] + '",\r\n' - } else { - string += block.rcinfo[item2] + ",\r\n" - } - } - string += ' },\r\n' - continue; - } else { - string += ' ' + key + ":" + block[key] + ",\r\n"; - } - } - string += 'XXX' - return string; - }); - var block = block.split('XXX')[0] - block += ' }' - if(debug)console.log('resolving', block); - res(block); - }) +async function handleRow (row, key) { + if (debug)console.log('handling row', row, key) + return new Promise(function (resolve, reject) { + if (debug)console.log('IN PROMISE', key) + let detectedEOL = '\r\n' + const detect = row.split(/[0-9]\n|[a-z]\n/) + if (detect.length > 1) { detectedEOL = '\n' } + if (debug)console.log('detected following EOL in file', JSON.stringify(detectedEOL)) + const tmp = row.split(/---> [0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+\r\n\r\n|---> [0-9]+.[0-9]+.[0-9]+.[0-9]+:[0-9]+\n\n/) + if (debug)console.log('temp', tmp, row, !tmp[1] || !row) + if (!tmp[1] || !row) { + if (debug)console.log('stopped it', !tmp[1], !row) + reject(new Error('error with row parsing')) + return + } else { + if (debug)console.log('parsing') + var rawSIP = tmp[1].split(detectedEOL).join('\r\n') + const mSIP = parSIP.getSIP(rawSIP) + // console.log(mSIP, '-----------------'); + + // Replace Session Identifiers need to be unique + if (mSIP) { + if (mSIP.call_id) { + if (!callids[mSIP.call_id]) { callids[mSIP.call_id] = Math.random().toString(36).substring(8) + mSIP.call_id } + if (debug)console.log('replacing call_id', mSIP.call_id, callids[mSIP.call_id]) + rawSIP = rawSIP.split(mSIP.call_id).join(callids[mSIP.call_id]) + }; + if (mSIP.via_branch) { + if (!callids[mSIP.via_branch]) { callids[mSIP.via_branch] = Math.random().toString(36).substring(8) + mSIP.via_branch } + if (debug)console.log('replacing via_branch', mSIP.via_branch, callids[mSIP.via_branch]) + rawSIP = rawSIP.split(mSIP.via_branch).join(callids[mSIP.via_branch]) + }; + if (mSIP.from_tag) { + if (!callids[mSIP.from_tag]) { callids[mSIP.from_tag] = Math.random().toString(36).substring(8) + mSIP.from_tag } + if (debug)console.log('replacing from_tag', mSIP.from_tag, callids[mSIP.from_tag]) + rawSIP = rawSIP.split(mSIP.from_tag).join(callids[mSIP.from_tag]) + }; + if (mSIP.to_tag) { + if (!callids[mSIP.to_tag]) { callids[mSIP.to_tag] = Math.random().toString(36).substring(8) + mSIP.to_tag } + if (debug)console.log('replacing to_tag', mSIP.to_tag, callids[mSIP.to_tag]) + rawSIP = rawSIP.split(mSIP.to_tag).join(callids[mSIP.to_tag]) + }; + } + } + // create message block for configuration + if (debug)console.log('making a block from ', tmp[0]) + + let block = row.replace(netRegex, function (match, proto, date, time, timeMicro, unused, fromIp, fromPort, divide, toIp, toPort) { + console.log('args for replace time', arguments) + time = parseInt(time) // in seconds + timeMicro = parseInt(timeMicro) // in microseconds + if (debug)console.log('TEST', time, timeMicro, cache.previous.time) + fromPort = parseInt(fromPort); toPort = parseInt(toPort) + const timePresent = addMicroSeconds(timeMicro, time) + const pauseTime = parseFloat(parseFloat(timePresent - cache.previous.time).toFixed(9)) || 0 + if (debug) console.log(`Pause Time on key ${key} is ${pauseTime}, based on ${parseFloat(parseFloat(timePresent - cache.previous.time).toFixed(9))}`) + const block = { + rcinfo: { + type: 'HEP', + version: 3, + time_sec: time, + time_usec: timeMicro, + payload_type: 1, + captureId: '2001', + capturePass: 'myHep', + ip_family: 2, + protocol: proto === 'UDP' ? 17 : 6, + proto_type: 1, + srcIp: fromIp, + dstIp: toIp, + srcPort: fromPort, + dstPort: toPort + }, + pause: pauseTime, + payload: JSON.stringify(rawSIP || tmp[1]) + } + if (debug)console.log('time before: ', time) + cache.previous = { time: timePresent } + let string = '{\r\n' + for (const key of Object.keys(block)) { + if (key === 'rcinfo') { + string += ' rcinfo:{ \r\n' + for (const item2 of Object.keys(block.rcinfo)) { + string += ' ' + item2 + ':' + if (typeof block.rcinfo[item2] === 'string') { + string += '"' + block.rcinfo[item2] + '",\r\n' + } else { + string += block.rcinfo[item2] + ',\r\n' + } + } + string += ' },\r\n' + continue + } else { + string += ' ' + key + ':' + block[key] + ',\r\n' + } + } + string += 'XXX' + return string + }) + block = block.split('XXX')[0] + block += ' }' + if (debug)console.log('resolving', block) + resolve(block) + }) +} + +/* time utility + returns total time in seconds as a float to allow pause math + */ +function addMicroSeconds (micro, sec) { + var milliSec = sec * 1000 + var milliMicro = micro / 1000 + var total = milliSec + milliMicro + return parseFloat(total/1000).toFixed(9) } diff --git a/tools/test2.js b/tools/test2.js new file mode 100644 index 0000000..593f6e1 --- /dev/null +++ b/tools/test2.js @@ -0,0 +1,811 @@ +/* HEPGEN Autogenerated from file => /Users/dletta/Downloads/export_0_669208915@10.200.67.32_internal-internal_/trace_data.txt */ +var config = { + NAME:"HEPGEN /Users/dletta/Downloads/export_0_669208915@10.200.67.32_internal-internal_/trace_data.txt", + HEP_SERVER:"127.0.0.1", + HEP_PORT:9060, + HEP_ID:"2001", + HEP_AUTH:"myHep", + MESSAGES: [ + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:444727, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.32", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:17.444727, + payload:"INVITE sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=vuykkz9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nMax-Forwards: 70\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 306\r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\na=sendrecv\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:447104, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:0.002377, + payload:"SIP/2.0 100 Giving it a try\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=vuykkz9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:447166, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000062, + payload:"INVITE sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nRecord-Route: \r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=31xabz9hG4bK3096.da6d9a2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nMax-Forwards: 32\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 306\r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\na=sendrecv\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:447434, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.000268, + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=31xabz9hG4bK3096.da6d9a2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK951113a89e7ba5e1b7656\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nUser-Agent: FVGVoIP\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:449658, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.002224, + payload:"SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=31xabz9hG4bK3096.da6d9a2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=tzkrbH95Fe7pe19rXc\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nUser-Agent: FVGVoIP\r\nAccept: application/sdp\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nProxy-Authenticate: Digest realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", algorithm=MD5, qop=\"auth\"\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:449721, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000063, + payload:"ACK sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=31xabz9hG4bK3096.da6d9a2.0\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nTo: ;tag=tzkrbH95Fe7pe19rXc\r\nCSeq: 1 ACK\r\nMax-Forwards: 70\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:449813, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:0.000092, + payload:"SIP/2.0 407 Proxy Authentication Required\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=vuykkz9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=tzkrbH95Fe7pe19rXc\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 INVITE\r\nUser-Agent: FVGVoIP\r\nAccept: application/sdp\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nProxy-Authenticate: Digest realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", algorithm=MD5, qop=\"auth\"\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:488829, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.32", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.039016, + payload:"ACK sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=vuykkz9hG4bK951113a89e7ba5e1b7656\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=tzkrbH95Fe7pe19rXc\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 1 ACK\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:49305, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.32", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:-0.439524, + payload:"INVITE sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=zhttz9hG4bK669294787\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nProxy-Authorization: Digest username=\"9502\", realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", uri=\"sip:9506@insiel.fvgvoip2.it:5060\", response=\"50345e59494799f01b76f5c580c18bd0\", algorithm=MD5, cnonce=\"669367423\", qop=auth, nc=00000001\r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nMax-Forwards: 70\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 306\r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\na=sendrecv\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:495313, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:0.446008, + payload:"SIP/2.0 100 Giving it a try\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=zhttz9hG4bK669294787\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:495416, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000103, + payload:"INVITE sip:9506@insiel.fvgvoip2.it:5060 SIP/2.0\r\nRecord-Route: \r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=90fewz9hG4bK0096.fddc979.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK669294787\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nProxy-Authorization: Digest username=\"9502\", realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", uri=\"sip:9506@insiel.fvgvoip2.it:5060\", response=\"50345e59494799f01b76f5c580c18bd0\", algorithm=MD5, cnonce=\"669367423\", qop=auth, nc=00000001\r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nMax-Forwards: 32\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 306\r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\na=sendrecv\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:495713, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.000297, + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=90fewz9hG4bK0096.fddc979.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK669294787\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: \r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nUser-Agent: FVGVoIP\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:571212, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.075499, + payload:"SIP/2.0 180 Ringing\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=90fewz9hG4bK0096.fddc979.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK669294787\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAccept: application/sdp\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nContent-Length: 0\r\nRemote-Party-ID: \"Barzelatto G.\" ;party=calling;privacy=off;screen=no\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:57138, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:-0.514074, + payload:"SIP/2.0 180 Ringing\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=zhttz9hG4bK669294787\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAccept: application/sdp\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nContent-Length: 0\r\nRemote-Party-ID: \"Barzelatto G.\" ;party=calling;privacy=off;screen=no\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:588544, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.531406, + payload:"INVITE sip:9506@10.200.67.35:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.21;rport;branch=r2o16z9hG4bK50X396ep4eU9p\r\nMax-Forwards: 31\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: \r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nPrivacy: none\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 294\r\nX-cid: 0_669208915@10.200.67.32\r\nX-FS-Support: update_display,send_info\r\nAlert-Info: ;info=internal\r\nP-Asserted-Identity: \"Benedet M.\" \r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:588832, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000288, + payload:"SIP/2.0 100 Giving it a try\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=r2o16z9hG4bK50X396ep4eU9p\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: \r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:17, + time_usec:588939, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.35", + srcPort:5060, + dstPort:5060, + }, + pause:0.000107, + payload:"INVITE sip:9506@10.200.67.35:5060 SIP/2.0\r\nRecord-Route: \r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=mhppbz9hG4bKe364.231efd57.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK50X396ep4eU9p\r\nMax-Forwards: 30\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: \r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nPrivacy: none\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 294\r\nX-cid: 0_669208915@10.200.67.32\r\nX-FS-Support: update_display,send_info\r\nAlert-Info: ;info=internal\r\nP-Asserted-Identity: \"Benedet M.\" \r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 0 8 18 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:18, + time_usec:126085, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.35", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.537146, + payload:"SIP/2.0 100 Trying\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=mhppbz9hG4bKe364.231efd57.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK50X396ep4eU9p\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: \r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:18, + time_usec:216643, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.35", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.090558, + payload:"SIP/2.0 180 Ringing\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=mhppbz9hG4bKe364.231efd57.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK50X396ep4eU9p\r\nRecord-Route: \r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:18, + time_usec:216831, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000188, + payload:"SIP/2.0 180 Ringing\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=r2o16z9hG4bK50X396ep4eU9p\r\nRecord-Route: \r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:961749, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.35", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:2.744918, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=mhppbz9hG4bKe364.231efd57.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK50X396ep4eU9p\r\nRecord-Route: \r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 211\r\n\r\nv=0\r\no=- 20008 20008 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=ptime:20\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:963692, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.001943, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=r2o16z9hG4bK50X396ep4eU9p\r\nRecord-Route: \r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 INVITE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 211\r\n\r\nv=0\r\no=- 20008 20008 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=ptime:20\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:966109, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.002417, + payload:"ACK sip:9506@10.200.67.35:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.21;rport;branch=6anzz9hG4bKU794gt134j54N\r\nRoute: \r\nMax-Forwards: 70\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 ACK\r\nContact: \r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:967839, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.35", + srcPort:5060, + dstPort:5060, + }, + pause:0.00173, + payload:"ACK sip:9506@10.200.67.35:5060 SIP/2.0\r\nRecord-Route: \r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=i0dh8z9hG4bKe364.231efd57.2\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bKU794gt134j54N\r\nMax-Forwards: 32\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298996 ACK\r\nContact: \r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:977947, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.010108, + payload:"UPDATE sip:9506@10.200.67.35:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.21;rport;branch=ggiy6z9hG4bKvg3XjNj71UUQH\r\nRoute: \r\nMax-Forwards: 70\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298997 UPDATE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 294\r\nP-Asserted-Identity: \"Benedet M.\" \r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 101 0 8 18\r\na=rtpmap:9 G722/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:97905, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:-0.880042, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=90fewz9hG4bK0096.fddc979.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK669294787\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 199\r\nRemote-Party-ID: \"Barzelatto G.\" ;party=calling;privacy=off;screen=no\r\n\r\nv=0\r\no=- 20008 20008 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:980753, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.35", + srcPort:5060, + dstPort:5060, + }, + pause:0.882848, + payload:"UPDATE sip:9506@10.200.67.35:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=fec2z9hG4bKf364.5660311.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bKvg3XjNj71UUQH\r\nMax-Forwards: 32\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298997 UPDATE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 294\r\nP-Asserted-Identity: \"Benedet M.\" \r\n\r\nv=0\r\no=- 20004 20004 IN IP4 10.200.67.32\r\ns=SDP data\r\nc=IN IP4 10.200.67.32\r\nt=0 0\r\nm=audio 12746 RTP/AVP 9 101 0 8 18\r\na=rtpmap:9 G722/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:18 G729/8000\r\na=fmtp:18 annexb=no\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:20, + time_usec:981317, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:0.000564, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=zhttz9hG4bK669294787\r\nRecord-Route: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 INVITE\r\nContact: \r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nAllow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer\r\nContent-Type: application/sdp\r\nContent-Disposition: session\r\nContent-Length: 199\r\nRemote-Party-ID: \"Barzelatto G.\" ;party=calling;privacy=off;screen=no\r\n\r\nv=0\r\no=- 20008 20008 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=ptime:20\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:21, + time_usec:30475, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.32", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.049158, + payload:"ACK sip:9506@10.100.1.21:5060;transport=UDP SIP/2.0\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=f5m6hz9hG4bK669494234\r\nRoute: \r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 ACK\r\nContact: \r\nProxy-Authorization: Digest username=\"9502\", realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", uri=\"sip:9506@insiel.fvgvoip2.it:5060\", response=\"50345e59494799f01b76f5c580c18bd0\", algorithm=MD5, cnonce=\"669367423\", qop=auth, nc=00000001\r\nMax-Forwards: 70\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:21, + time_usec:3229, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:-0.027246, + payload:"ACK sip:9506@10.100.1.21:5060;transport=UDP SIP/2.0\r\nRecord-Route: \r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=p33cqz9hG4bK0096.fddc979.2\r\nVia: SIP/2.0/UDP 10.200.67.32:5060;branch=z9hG4bK669494234\r\nFrom: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nTo: ;tag=gwl7ejjZ8F27HyjFgr\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 2 ACK\r\nContact: \r\nProxy-Authorization: Digest username=\"9502\", realm=\"insiel.fvgvoip2.it\", nonce=\"a3346686-63cb-415a-9ae5-ac36bff99eed\", uri=\"sip:9506@insiel.fvgvoip2.it:5060\", response=\"50345e59494799f01b76f5c580c18bd0\", algorithm=MD5, cnonce=\"669367423\", qop=auth, nc=00000001\r\nMax-Forwards: 32\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:21, + time_usec:121737, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.35", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.118508, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=fec2z9hG4bKf364.5660311.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bKvg3XjNj71UUQH\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298997 UPDATE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 211\r\n\r\nv=0\r\no=- 20008 20009 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=ptime:20\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:21, + time_usec:121901, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000164, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=ggiy6z9hG4bKvg3XjNj71UUQH\r\nFrom: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nTo: ;tag=mkzkr660185021\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 42298997 UPDATE\r\nContact: \r\nContent-Type: application/sdp\r\nAllow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nAllow-Events: talk,hold,conference,refer,check-sync\r\nSupported: replaces\r\nContent-Length: 211\r\n\r\nv=0\r\no=- 20008 20009 IN IP4 10.200.67.35\r\ns=SDP data\r\nc=IN IP4 10.200.67.35\r\nt=0 0\r\nm=audio 12570 RTP/AVP 9 101\r\na=rtpmap:9 G722/8000\r\na=ptime:20\r\na=rtpmap:101 telephone-event/8000\r\na=fmtp:101 0-15\r\na=sendrecv\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:640887, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.35", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:2.518986, + payload:"BYE sip:mod_sofia@10.100.1.21:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.200.67.35:5060;branch=mv82sz9hG4bK660238663\r\nRoute: \r\nFrom: ;tag=mkzkr660185021\r\nTo: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 2 BYE\r\nContact: \r\nMax-Forwards: 70\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:643453, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.002566, + payload:"BYE sip:mod_sofia@10.100.1.21:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=ijttoz9hG4bK915e.64780603.0\r\nVia: SIP/2.0/UDP 10.200.67.35:5060;branch=z9hG4bK660238663\r\nFrom: ;tag=mkzkr660185021\r\nTo: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 2 BYE\r\nContact: \r\nMax-Forwards: 32\r\nUser-Agent: Yealink SIP-T42S 66.85.0.61\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:651839, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.008386, + payload:"BYE sip:9502@10.200.67.32:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.21;rport;branch=xm8wjz9hG4bK6a0N43ta5mtjN\r\nRoute: \r\nMax-Forwards: 70\r\nFrom: ;tag=gwl7ejjZ8F27HyjFgr\r\nTo: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 42298999 BYE\r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nReason: Q.850;cause=16;text=\"NORMAL_CLEARING\"\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:651862, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.21", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.000023, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=ijttoz9hG4bK915e.64780603.0\r\nVia: SIP/2.0/UDP 10.200.67.35:5060;branch=z9hG4bK660238663\r\nFrom: ;tag=mkzkr660185021\r\nTo: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 2 BYE\r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:652069, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.35", + srcPort:5060, + dstPort:5060, + }, + pause:0.000207, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.200.67.35:5060;branch=mv82sz9hG4bK660238663\r\nFrom: ;tag=mkzkr660185021\r\nTo: \"Benedet M.\" ;tag=m2gqsKUr1HXrNUU52K\r\nCall-ID: ljovq210fe1f0-a2ec-123a-e083-000c29e8b676\r\nCSeq: 2 BYE\r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:653373, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.200.67.32", + srcPort:5060, + dstPort:5060, + }, + pause:0.001304, + payload:"BYE sip:9502@10.200.67.32:5060 SIP/2.0\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=iv9v4z9hG4bK23ac.8227a041.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK6a0N43ta5mtjN\r\nMax-Forwards: 32\r\nFrom: ;tag=gwl7ejjZ8F27HyjFgr\r\nTo: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 42298999 BYE\r\nUser-Agent: FVGVoIP\r\nAllow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE\r\nSupported: timer, path, replaces\r\nReason: Q.850;cause=16;text=\"NORMAL_CLEARING\"\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:692926, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.200.67.32", + dstIp:"10.100.1.10", + srcPort:5060, + dstPort:5060, + }, + pause:0.039553, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.10:5060;branch=iv9v4z9hG4bK23ac.8227a041.0\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=z9hG4bK6a0N43ta5mtjN\r\nFrom: ;tag=gwl7ejjZ8F27HyjFgr\r\nTo: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 42298999 BYE\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nContent-Length: 0\r\n\r\n\r\n", + }, + { + rcinfo:{ + type:"HEP", + version:3, + time_sec:23, + time_usec:693001, + payload_type:1, + captureId:"2001", + capturePass:"myHep", + ip_family:2, + protocol:17, + proto_type:1, + srcIp:"10.100.1.10", + dstIp:"10.100.1.21", + srcPort:5060, + dstPort:5060, + }, + pause:0.000075, + payload:"SIP/2.0 200 OK\r\nVia: SIP/2.0/UDP 10.100.1.21;received=10.100.1.21;rport=5060;branch=xm8wjz9hG4bK6a0N43ta5mtjN\r\nFrom: ;tag=gwl7ejjZ8F27HyjFgr\r\nTo: \"9502 Benedet M.\" ;tag=1uwss669136668\r\nCall-ID: ba8tq0_669208915@10.200.67.32\r\nCSeq: 42298999 BYE\r\nUser-Agent: Yealink SIP-T46U 108.86.0.20\r\nContent-Length: 0\r\n\r\n\r\n", + }, + ] +}; +module.exports = config; \ No newline at end of file From 53df95a1afac13a54b322231ca94f3ed4f6d234f Mon Sep 17 00:00:00 2001 From: Dletta Date: Fri, 19 Nov 2021 21:48:09 -0600 Subject: [PATCH 7/7] final math --- hepgen.js | 12 ++++++------ tools/pcap2hepgen.js | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hepgen.js b/hepgen.js index b3efef6..bf7b658 100755 --- a/hepgen.js +++ b/hepgen.js @@ -171,18 +171,18 @@ async function preHep(message) { } var hrTime = process.hrtime(); - var datenow = new Date().getTime(); - rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = ((datenow - (rcinfo.time_sec*1000))*1000)+rcinfo.time_usec; + var datenow = new Date(); + rcinfo.time_sec = rcinfo.time_sec || Math.floor( datenow.getTime() / 1000); + rcinfo.time_usec = rcinfo.time_usec || datenow.getMilliseconds() * 1000; if (debug) console.log(rcinfo); if (message.pause && (message.pause > 10000 || message.pause < 0 )) message.pause = 100; if (message.pause && message.pause > 0) { pause += message.pause; await new Promise(f => setTimeout(f, pause)) - var datenow = new Date().getTime(); - rcinfo.time_sec = Math.floor( datenow / 1000); - rcinfo.time_usec = ((datenow - (rcinfo.time_sec*1000))*1000)+rcinfo.time_usec; + var datenow = new Date(); + rcinfo.time_sec = rcinfo.time_sec || Math.floor( datenow.getTime() / 1000); + rcinfo.time_usec = rcinfo.time_usec || datenow.getMilliseconds() * 1000; routeOUT(msg,rcinfo); if(!_config_.LOOPED)process.stdout.write("rcvd: "+stats.rcvd+", parsed: "+stats.parsed+", hepsent: "+stats.hepsent+", err: "+stats.err+", heperr: "+stats.heperr+"\r"); } else { diff --git a/tools/pcap2hepgen.js b/tools/pcap2hepgen.js index 7f0d5e4..c103d47 100755 --- a/tools/pcap2hepgen.js +++ b/tools/pcap2hepgen.js @@ -146,8 +146,9 @@ async function handleRow (row, key) { // create message block for configuration if (debug)console.log('making a block from ', tmp[0]) + let block = row.replace(netRegex, function (match, proto, date, time, timeMicro, unused, fromIp, fromPort, divide, toIp, toPort) { - console.log('args for replace time', arguments) + if(debug) console.log('args for replace time', arguments) time = parseInt(time) // in seconds timeMicro = parseInt(timeMicro) // in microseconds if (debug)console.log('TEST', time, timeMicro, cache.previous.time) @@ -159,8 +160,6 @@ async function handleRow (row, key) { rcinfo: { type: 'HEP', version: 3, - time_sec: time, - time_usec: timeMicro, payload_type: 1, captureId: '2001', capturePass: 'myHep',