repl.it
HTML, CSS, JS

No description

fork
loading
Files
  • index.html
  • samplecf
  • EthernetFrame.js
  • filereader.js
  • Ipv4Packet.js
  • jquery-3.4.1.min.js
  • KaitaiStream.js
  • Pcap.js
  • ProtocolBody.js
  • script.js
  • sequence-diagram-min.css
  • sequence-diagram-min.js
  • snap.svg-min.js
  • style.css
  • underscore-min.js
  • webfontloader.js
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="https://fonts.googleapis.com/css?family=Architects+Daughter" rel="stylesheet" type="text/css">

    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

	<link rel="stylesheet" type="text/css" href="sequence-diagram-min.css" media="screen" />
    <!-- <link rel="stylesheet" type="text/css" href="css/style.css" media="screen" /> -->

    <title>Call Flow</title>
  </head>

  <body>
    <header>
      <div class="inner">
        <h1 style="text-align: center;">Simple Call Flow Generator</h1>
        <!-- <h3 style="margin: 20px;">* Upload pcap and convert to call flow</h3> -->
        <form id='file-form' method="post" enctype="multipart/form-data" style="display: none;";>
          <input type="hidden" name="extra-data" multiple />
          <input type="file" id="file-input" name="file-input" multiple />
        </form>
        <div id="dropzone" style="margin: 20px; padding: 15px; border: 1px dashed black;text-align: center;">Drop .pcap here to convert to call flow</div>
        <!--<h3>* Compare with standard call flow, Mark mismatches</h3> -->
        <!--
        <a href="https://github.com/bramp/svg-js-sequence-diagrams" class="button">
        <small>View project on</small>GitHub</a>
      -->
      </div>
      <!-- <a href="https://github.com/bramp/js-sequence-diagrams">
        <img class="gh-forkme" src="//s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub">
      </a> -->
    </header>

    <div id="main">
		<div class="diagram"></div>
	</div>
	
	
	<script src="jquery-3.4.1.min.js" ></script>
	<script src="webfontloader.js" ></script>
	<script src="snap.svg-min.js" ></script>
	<script src="underscore-min.js" ></script>
	<script src="sequence-diagram-min.js" ></script>
	
  <script src="KaitaiStream.js" ></script>
  <script src="ProtocolBody.js" ></script>
  <script src="Ipv4Packet.js" ></script>
  <script src="EthernetFrame.js" ></script>
  
	<script src="Pcap.js" ></script>

  <script src="filereader.js" ></script>
  <script>
    var options = {
      // CSS Class to add to the drop element when a drag is active
      //dragClass: "drag",

      // A string to match MIME types, for instance
      //accept: false,

      // An object specifying how to read certain MIME types
      // For example: {
      //  'image/*': 'DataURL',
      //  'data/*': 'ArrayBuffer',
      //  'text/*' : 'Text'
      // }
      readAsMap: { 'data/*': 'ArrayBuffer' },

      // How to read any files not specified by readAsMap
      readAsDefault: 'ArrayBuffer',
      on: {
        beforestart: function(e, file) {
            // return false if you want to skip this file
        },
        loadstart: function(e, file) { /* Native ProgressEvent */
          $("#dropzone").after('<p id="loading" style="text-align:center;">Loading...</p>');
         },
        progress: function(e, file) { /* Native ProgressEvent */ },
        load: function(e, file) { 
          console.log("file loaded");
          $("#loading").remove();
          var localfileab = e.target.result;
          fromAB(localfileab);
          /* Native ProgressEvent */
        },
        error: function(e, file) { /* Native ProgressEvent */ },
        loadend: function(e, file) { /* Native ProgressEvent */ },
        abort: function(e, file) { /* Native ProgressEvent */ },
        skip: function(e, file) {
          // Called when a file is skipped.  This happens when:
          //  1) A file doesn't match the accept option
          //  2) false is returned in the beforestart callback
        },
        groupstart: function(group) {
          // Called when a 'group' (a single drop / copy / select that may
          // contain multiple files) is receieved.
          // You can ignore this event if you don't care about groups
        },
        groupend: function(group) {
          // Called when a 'group' is finished.
          // You can ignore this event if you don't care about groups
        }
      }
    };
    $("#file-input, #dropzone").fileReaderJS(options);

    $('#dropzone').click (function () {
      $('input:file')[0].click();
    });

  </script>

	<script>
		//var options = {theme: 'simple'};
		//$(".diagram").sequenceDiagram(options);	
	</script>
	
	<script>
		var oReq = new XMLHttpRequest();
		oReq.open("GET", "samplecf/InterMME_HO.pcap", true);
		oReq.responseType = "arraybuffer";

		oReq.onload = function (oEvent) {
      console.log("got data");
			var arrayBuffer = oReq.response;
      fromAB(arrayBuffer);
		};
		//oReq.send(null);

function fromAB(arrayBuffer){
  		var data = new Pcap(new KaitaiStream(arrayBuffer));
      //console.log("data:", data);
			//console.log("data.hdr:", data.hdr);
      //console.log("data.packets:", data.packets);
      //console.log("data.packets[0].tsSec:", data.packets[0].tsSec);
      //console.log("data.packets[0].body:", data.packets[0].body);
      //console.log("data.packets[0].body.body:", data.packets[0].body.body);

      var diagramtext = "";
      //loop thru each packet
      for(var k=0;k<data.packets.length;k++){

      //console.log("bodybody: ", data.packets[k].body);

      var srcIpAddrStr,dstIpAddrStr, packetTimestamp;
      var srcIpAddr = data.packets[k].body.body.srcIpAddr;
      //console.log("srcIpAddr: ", srcIpAddr, "tostring: ", srcIpAddr.toString());
      if(srcIpAddr == null){
        alert("Error: not IP over Ethernet");
        break;
      }
      srcIpAddrStr=srcIpAddr.toString().replace(/,/g,".");
      
      var dstIpAddr = data.packets[k].body.body.dstIpAddr;
      dstIpAddrStr=dstIpAddr.toString().replace(/,/g,".");

      packetTimestamp = data.packets[k].tsSec + "." +data.packets[k].tsUsec;
      //console.log("ts: ",packetTimestamp);
      //for(var j=0;j<srcIpAddr;j++){
      //  srcIpAddrStr += ""+srcIpAddr[j];
      //  dstIpAddrStr += ""+dstIpAddr[j];
      //}
      //console.log("srcIpAddrStr: ", srcIpAddrStr);
      //console.log("data.packets[0].body.body.body:", data.packets[0].body.body._raw_body);
      var rawdata = data.packets[k].body.body._raw_body;
      var prev1,prev2,prev3,latest,foundprotocol,procedureCode, procedureName;
      for(var i=0;i<rawdata.length;i++){
        latest = rawdata[i];
        if(i>3){
          prev1 = rawdata[i-3];
          prev2 = rawdata[i-2];
          prev3 = rawdata[i-1];
        }      
        if(prev1 == 0 && prev2 == 0 && prev3 == 0 && latest == 18){
          //console.log("found s1ap!: i", i);
          foundprotocol = latest;
          procedureCode = rawdata[i+2];
          //console.log("procedureCode: ", procedureCode);
        }
        if(i>3){
          prev1 = rawdata[i-3];
          prev2 = rawdata[i-2];
          prev3 = rawdata[i-1];
        }      
      } //end of parse for loop single packet
      procedureName = getProcedureName(procedureCode);
//build the Message A->B: Message
//diagramtext += "Note left of " +srcIpAddrStr+ ":" + packetTimestamp + "\n";
diagramtext += ""+srcIpAddrStr+"->"+dstIpAddrStr+":"+procedureName+ "\n";
}

    //console.log("end of big loop build diagram: ", diagramtext);
    buildDiagram(diagramtext);
}

function buildDiagram(diagramtext){
  $(".diagram").text(diagramtext);
  var options = {theme: 'simple'};
  $(".diagram").sequenceDiagram(options);	

}

function getProcedureName(procedureCode){
  if(procedureCode == 0)	procedureName="HandoverPreparation";
if(procedureCode == 1)	procedureName="HandoverResourceAllocation";
if(procedureCode == 10)	procedureName="Paging";
if(procedureCode == 11)	procedureName="downlinkNASTransport";
if(procedureCode == 12)	procedureName="initialUEMessage";
if(procedureCode == 13)	procedureName="uplinkNASTransport";
if(procedureCode == 14)	procedureName="Reset";
if(procedureCode == 15)	procedureName="ErrorIndication";
if(procedureCode == 16)	procedureName="NASNonDeliveryIndication";
if(procedureCode == 17)	procedureName="S1Setup";
if(procedureCode == 18)	procedureName="UEContextReleaseRequest";
if(procedureCode == 19)	procedureName="DownlinkS1cdma2000tunneling";
if(procedureCode == 2)	procedureName="HandoverNotification";
if(procedureCode == 20)	procedureName="UplinkS1cdma2000tunneling";
if(procedureCode == 21)	procedureName="UEContextModification";
if(procedureCode == 22)	procedureName="UECapabilityInfoIndication";
if(procedureCode == 23)	procedureName="UEContextRelease";
if(procedureCode == 24)	procedureName="eNBStatusTransfer";
if(procedureCode == 25)	procedureName="MMEStatusTransfer";
if(procedureCode == 26)	procedureName="DeactivateTrace";
if(procedureCode == 27)	procedureName="TraceStart";
if(procedureCode == 28)	procedureName="TraceFailureIndication";
if(procedureCode == 29)	procedureName="ENBConfigurationUpdate";
if(procedureCode == 3)	procedureName="PathSwitchRequest";
if(procedureCode == 30)	procedureName="MMEConfigurationUpdate";
if(procedureCode == 31)	procedureName="LocationReportingControl";
if(procedureCode == 32)	procedureName="LocationReportingFailureIndication";
if(procedureCode == 33)	procedureName="LocationReport";
if(procedureCode == 34)	procedureName="OverloadStart";
if(procedureCode == 35)	procedureName="OverloadStop";
if(procedureCode == 36)	procedureName="WriteReplaceWarning";
if(procedureCode == 37)	procedureName="eNBDirectInformationTransfer";
if(procedureCode == 38)	procedureName="MMEDirectInformationTransfer";
if(procedureCode == 39)	procedureName="PrivateMessage";
if(procedureCode == 4)	procedureName="HandoverCancel";
if(procedureCode == 40)	procedureName="eNBConfigurationTransfer";
if(procedureCode == 41)	procedureName="MMEConfigurationTransfer";
if(procedureCode == 42)	procedureName="CellTrafficTrace";
if(procedureCode == 43)	procedureName="Kill";
if(procedureCode == 44)	procedureName="downlinkUEAssociatedLPPaTransport";
if(procedureCode == 45)	procedureName="uplinkUEAssociatedLPPaTransport";
if(procedureCode == 46)	procedureName="downlinkNonUEAssociatedLPPaTransport";
if(procedureCode == 47)	procedureName="uplinkNonUEAssociatedLPPaTransport";
if(procedureCode == 48)	procedureName="UERadioCapabilityMatch";
if(procedureCode == 5)	procedureName="E-RABSetup";
if(procedureCode == 6)	procedureName="E-RABModify";
if(procedureCode == 7)	procedureName="E-RABRelease";
if(procedureCode == 8)	procedureName="E-RABReleaseIndication";
if(procedureCode == 9)	procedureName="InitialContextSetup";

//console.log("procedureName: ", procedureName);
return procedureName;
}
    </script>
  </body>
</html>
result
console