1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5 <!-- Generated by javadoc (1.8.0_191) on Thu Mar 28 11:26:59 PDT 2019 -->
6 <title>PrintUtils</title>
7 <meta name="date" content="2019-03-28">
8 <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
9 <script type="text/javascript" src="../../../../script.js"></script>
12 <script type="text/javascript"><!--
14 if (location.href.indexOf('is-external=true') == -1) {
15 parent.document.title="PrintUtils";
21 var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9};
22 var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
23 var altColor = "altColor";
24 var rowColor = "rowColor";
25 var tableTab = "tableTab";
26 var activeTableTab = "activeTableTab";
29 <div>JavaScript is disabled on your browser.</div>
31 <!-- ========= START OF TOP NAVBAR ======= -->
32 <div class="topNav"><a name="navbar.top">
35 <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
36 <a name="navbar.top.firstrow">
39 <ul class="navList" title="Navigation">
40 <li><a href="../../../../overview-summary.html">Overview</a></li>
41 <li><a href="package-summary.html">Package</a></li>
42 <li class="navBarCell1Rev">Class</li>
43 <li><a href="package-tree.html">Tree</a></li>
44 <li><a href="../../../../deprecated-list.html">Deprecated</a></li>
45 <li><a href="../../../../index-files/index-1.html">Index</a></li>
46 <li><a href="../../../../help-doc.html">Help</a></li>
51 <li><a href="../../../../edu/uci/iotproject/util/PcapPacketUtils.html" title="class in edu.uci.iotproject.util"><span class="typeNameLink">Prev Class</span></a></li>
52 <li>Next Class</li>
55 <li><a href="../../../../index.html?edu/uci/iotproject/util/PrintUtils.html" target="_top">Frames</a></li>
56 <li><a href="PrintUtils.html" target="_top">No Frames</a></li>
58 <ul class="navList" id="allclasses_navbar_top">
59 <li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
62 <script type="text/javascript"><!--
63 allClassesLink = document.getElementById("allclasses_navbar_top");
65 allClassesLink.style.display = "block";
68 allClassesLink.style.display = "none";
74 <ul class="subNavList">
75 <li>Summary: </li>
76 <li>Nested | </li>
77 <li>Field | </li>
78 <li>Constr | </li>
79 <li><a href="#method.summary">Method</a></li>
81 <ul class="subNavList">
82 <li>Detail: </li>
83 <li>Field | </li>
84 <li>Constr | </li>
85 <li><a href="#method.detail">Method</a></li>
88 <a name="skip.navbar.top">
91 <!-- ========= END OF TOP NAVBAR ========= -->
92 <!-- ======== START OF CLASS DATA ======== -->
94 <div class="subTitle">edu.uci.iotproject.util</div>
95 <h2 title="Class PrintUtils" class="title">Class PrintUtils</h2>
97 <div class="contentContainer">
98 <ul class="inheritance">
99 <li>java.lang.Object</li>
101 <ul class="inheritance">
102 <li>edu.uci.iotproject.util.PrintUtils</li>
106 <div class="description">
107 <ul class="blockList">
108 <li class="blockList">
111 <pre>public class <span class="typeNameLabel">PrintUtils</span>
112 extends java.lang.Object</pre>
113 <div class="block">Utility methods for generating (output) strings.</div>
117 <div class="summary">
118 <ul class="blockList">
119 <li class="blockList">
120 <!-- ========== METHOD SUMMARY =========== -->
121 <ul class="blockList">
122 <li class="blockList"><a name="method.summary">
125 <h3>Method Summary</h3>
126 <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
127 <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption>
129 <th class="colFirst" scope="col">Modifier and Type</th>
130 <th class="colLast" scope="col">Method and Description</th>
132 <tr id="i0" class="altColor">
133 <td class="colFirst"><code>static java.util.List<java.util.List<org.pcap4j.core.PcapPacket>></code></td>
134 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#deserializeClustersFromFile-java.lang.String-">deserializeClustersFromFile</a></span>(java.lang.String fileName)</code>
135 <div class="block">Read the list of list of packet pairs <code>List<List<PcapPacket>></code> from a file.</div>
138 <tr id="i1" class="rowColor">
139 <td class="colFirst"><code>static java.util.List<java.util.List<java.util.List<org.pcap4j.core.PcapPacket>>></code></td>
140 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#deserializeFromFile-java.lang.String-">deserializeFromFile</a></span>(java.lang.String fileName)</code>
141 <div class="block">Read the list of list of packet pairs <code>List<List<List<PcapPacket>>></code> from a file.</div>
144 <tr id="i2" class="altColor">
145 <td class="colFirst"><code>static void</code></td>
146 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#serializeClustersIntoFile-java.lang.String-java.util.List-">serializeClustersIntoFile</a></span>(java.lang.String fileName,
147 java.util.List<java.util.List<org.pcap4j.core.PcapPacket>> clusterPackets)</code>
148 <div class="block">Write the list of list of packet pairs <code>List<List<PcapPacket>></code> into a file.</div>
151 <tr id="i3" class="rowColor">
152 <td class="colFirst"><code>static void</code></td>
153 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#serializeIntoFile-java.lang.String-java.util.List-">serializeIntoFile</a></span>(java.lang.String fileName,
154 java.util.List<java.util.List<java.util.List<org.pcap4j.core.PcapPacket>>> signature)</code>
155 <div class="block">Write the signature and cluster analysis <code>List<List<List<PcapPacket>>></code> into a file.</div>
158 <tr id="i4" class="altColor">
159 <td class="colFirst"><code>static java.lang.String</code></td>
160 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#toCsv-edu.uci.iotproject.analysis.PcapPacketPair-">toCsv</a></span>(<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a> packetPair)</code>
161 <div class="block">Converts a <code>PcapPacketPair</code> into a CSV string containing the packet lengths of the two packets in the pair.</div>
164 <tr id="i5" class="rowColor">
165 <td class="colFirst"><code>static java.lang.String</code></td>
166 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#toCsv-edu.uci.iotproject.analysis.PcapPacketPair-edu.uci.iotproject.DnsMap-">toCsv</a></span>(<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a> packetPair,
167 <a href="../../../../edu/uci/iotproject/DnsMap.html" title="class in edu.uci.iotproject">DnsMap</a> ipHostnameMappings)</code>
168 <div class="block">Converts a <code>PcapPacketPair</code> into a CSV string containing the packet lengths of the two packets in the pair
169 followed by the source of each packet.</div>
172 <tr id="i6" class="altColor">
173 <td class="colFirst"><code>static java.lang.String</code></td>
174 <td class="colLast"><code><span class="memberNameLink"><a href="../../../../edu/uci/iotproject/util/PrintUtils.html#toSummaryString-org.apache.commons.math3.stat.clustering.Cluster-">toSummaryString</a></span>(org.apache.commons.math3.stat.clustering.Cluster<<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a>> cluster)</code>
175 <div class="block">Generate a string that summarizes/describes <code>cluster</code>.</div>
179 <ul class="blockList">
180 <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
183 <h3>Methods inherited from class java.lang.Object</h3>
184 <code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
191 <div class="details">
192 <ul class="blockList">
193 <li class="blockList">
194 <!-- ============ METHOD DETAIL ========== -->
195 <ul class="blockList">
196 <li class="blockList"><a name="method.detail">
199 <h3>Method Detail</h3>
200 <a name="serializeClustersIntoFile-java.lang.String-java.util.List-">
203 <ul class="blockList">
204 <li class="blockList">
205 <h4>serializeClustersIntoFile</h4>
206 <pre>public static void serializeClustersIntoFile(java.lang.String fileName,
207 java.util.List<java.util.List<org.pcap4j.core.PcapPacket>> clusterPackets)</pre>
208 <div class="block">Write the list of list of packet pairs <code>List<List<PcapPacket>></code> into a file.
210 After the DBSCAN algorithm derives the clusters from pairs, we save the signature in the form of list of
211 packet pairs. We harvest the pairs and transform them back into a list of PcapPacket objects.
212 We do not maintain the pairs in the form of <code>Cluster<PcapPacketPair></code> objects because there might be
213 a situation where we could combine multiple PcapPacketPair objects into a longer signature, i.e., a string of
214 PcapPacket objects and not just a pair.</div>
216 <dt><span class="paramLabel">Parameters:</span></dt>
217 <dd><code>fileName</code> - The path of the file in <code>String</code>. We could leave this one <code>null</code> if we wanted the
218 default file name <code>SERIALIZABLE_FILE_PATH</code>.</dd>
219 <dd><code>clusterPackets</code> - The <code>Cluster</code> objects in the form of list of <code>PcapPacket</code> objects.</dd>
223 <a name="serializeIntoFile-java.lang.String-java.util.List-">
226 <ul class="blockList">
227 <li class="blockList">
228 <h4>serializeIntoFile</h4>
229 <pre>public static void serializeIntoFile(java.lang.String fileName,
230 java.util.List<java.util.List<java.util.List<org.pcap4j.core.PcapPacket>>> signature)</pre>
231 <div class="block">Write the signature and cluster analysis <code>List<List<List<PcapPacket>>></code> into a file.
233 After the DBSCAN algorithm derives the clusters from pairs, we save the signature and cluster analysis
234 in the form of list of packet pairs. We harvest the pairs and transform them back into a list of PcapPacket
236 We do not maintain the pairs in the form of <code>Cluster<PcapPacketPair></code> objects because there might be
237 a situation where we could combine multiple PcapPacketPair objects into a longer signature, i.e., a string of
238 PcapPacket objects and not just a pair.</div>
240 <dt><span class="paramLabel">Parameters:</span></dt>
241 <dd><code>fileName</code> - The path of the file in <code>String</code>. We could leave this one <code>null</code> if we wanted the
242 default file name <code>SERIALIZABLE_FILE_PATH</code>.</dd>
243 <dd><code>signature</code> - The <code>Cluster</code> objects in the form of list of <code>PcapPacket</code> objects.</dd>
247 <a name="deserializeClustersFromFile-java.lang.String-">
250 <ul class="blockList">
251 <li class="blockList">
252 <h4>deserializeClustersFromFile</h4>
253 <pre>public static java.util.List<java.util.List<org.pcap4j.core.PcapPacket>> deserializeClustersFromFile(java.lang.String fileName)</pre>
254 <div class="block">Read the list of list of packet pairs <code>List<List<PcapPacket>></code> from a file.
256 After the DBSCAN algorithm derives the clusters from pairs, we save the signature in the form of list of
257 packet pairs. We harvest the pairs and transform them back into a list of PcapPacket objects.
258 We do not maintain the pairs in the form of <code>Cluster<PcapPacketPair></code> objects because there might be
259 a situation where we could combine multiple PcapPacketPair objects into a longer signature, i.e., a string of
260 PcapPacket objects and not just a pair.</div>
262 <dt><span class="paramLabel">Parameters:</span></dt>
263 <dd><code>fileName</code> - The path of the file in <code>String</code>. We could leave this one <code>null</code> if we wanted the
264 default file name <code>SERIALIZABLE_FILE_PATH</code>.</dd>
265 <dt><span class="returnLabel">Returns:</span></dt>
266 <dd>The list of list of <code>Cluster</code> objects (<code>List<List<PcapPacket>></code>) that is read from file.</dd>
270 <a name="deserializeFromFile-java.lang.String-">
273 <ul class="blockList">
274 <li class="blockList">
275 <h4>deserializeFromFile</h4>
276 <pre>public static java.util.List<java.util.List<java.util.List<org.pcap4j.core.PcapPacket>>> deserializeFromFile(java.lang.String fileName)</pre>
277 <div class="block">Read the list of list of packet pairs <code>List<List<List<PcapPacket>>></code> from a file.</div>
279 <dt><span class="paramLabel">Parameters:</span></dt>
280 <dd><code>fileName</code> - The path of the file in <code>String</code>. We could leave this one <code>null</code> if we wanted the
281 default file name <code>SERIALIZABLE_FILE_PATH</code>.</dd>
282 <dt><span class="returnLabel">Returns:</span></dt>
283 <dd>The list of list of list of <code>Cluster</code> objects (<code>List<List<List<PcapPacket>>></code>)
284 that is read from file.</dd>
288 <a name="toCsv-edu.uci.iotproject.analysis.PcapPacketPair-">
291 <ul class="blockList">
292 <li class="blockList">
294 <pre>public static java.lang.String toCsv(<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a> packetPair)</pre>
295 <div class="block">Converts a <code>PcapPacketPair</code> into a CSV string containing the packet lengths of the two packets in the pair.
297 For example, the resulting string will be "123, 456" if the first packet of the pair has a length of 123 and the
298 second packet of the pair has a length of 456.
300 <b>Note:</b> if the <a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis"><code>PcapPacketPair</code></a> has no second element, 0 is printed as the length of the second packet
303 <dt><span class="returnLabel">Returns:</span></dt>
304 <dd>a CSV string containing the packet lengths of the two packets of the given <code>PcapPacketPair</code>.</dd>
308 <a name="toCsv-edu.uci.iotproject.analysis.PcapPacketPair-edu.uci.iotproject.DnsMap-">
311 <ul class="blockList">
312 <li class="blockList">
314 <pre>public static java.lang.String toCsv(<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a> packetPair,
315 <a href="../../../../edu/uci/iotproject/DnsMap.html" title="class in edu.uci.iotproject">DnsMap</a> ipHostnameMappings)</pre>
316 <div class="block">Converts a <code>PcapPacketPair</code> into a CSV string containing the packet lengths of the two packets in the pair
317 followed by the source of each packet. The source will be a (set of) hostname(s) if the source IP can be resolved
318 to a (set of) hostname(s) using the provided <a href="../../../../edu/uci/iotproject/DnsMap.html" title="class in edu.uci.iotproject"><code>DnsMap</code></a>.
320 For example, the resulting string will be "123, 456, 192.168.1.42, domain.com" if the first packet of the pair
321 has a length of 123, the second packet of the pair has a length of 456, the first packet of the pair the pair has
322 a source IP of '192.168.1.42' that cannot be resolved to a hostname, and the second packet of the pair has an IP
323 that resolves to 'domain.com'.
325 <b>Note:</b> if the <a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis"><code>PcapPacketPair</code></a> has no second element, 0 is printed as the length of the second packet
326 in the pair, and null is printed for its source.</div>
328 <dt><span class="returnLabel">Returns:</span></dt>
329 <dd>a CSV string containing the packet lengths of the two packets of the given <code>PcapPacketPair</code> as well
330 as their respective sources.</dd>
334 <a name="toSummaryString-org.apache.commons.math3.stat.clustering.Cluster-">
337 <ul class="blockListLast">
338 <li class="blockList">
339 <h4>toSummaryString</h4>
340 <pre>public static java.lang.String toSummaryString(org.apache.commons.math3.stat.clustering.Cluster<<a href="../../../../edu/uci/iotproject/analysis/PcapPacketPair.html" title="class in edu.uci.iotproject.analysis">PcapPacketPair</a>> cluster)</pre>
341 <div class="block">Generate a string that summarizes/describes <code>cluster</code>.</div>
343 <dt><span class="paramLabel">Parameters:</span></dt>
344 <dd><code>cluster</code> - The <code>Cluster</code> to summarize/describe.</dd>
345 <dt><span class="returnLabel">Returns:</span></dt>
346 <dd>A string that summarizes/describes <code>cluster</code>.</dd>
356 <!-- ========= END OF CLASS DATA ========= -->
357 <!-- ======= START OF BOTTOM NAVBAR ====== -->
358 <div class="bottomNav"><a name="navbar.bottom">
361 <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
362 <a name="navbar.bottom.firstrow">
365 <ul class="navList" title="Navigation">
366 <li><a href="../../../../overview-summary.html">Overview</a></li>
367 <li><a href="package-summary.html">Package</a></li>
368 <li class="navBarCell1Rev">Class</li>
369 <li><a href="package-tree.html">Tree</a></li>
370 <li><a href="../../../../deprecated-list.html">Deprecated</a></li>
371 <li><a href="../../../../index-files/index-1.html">Index</a></li>
372 <li><a href="../../../../help-doc.html">Help</a></li>
377 <li><a href="../../../../edu/uci/iotproject/util/PcapPacketUtils.html" title="class in edu.uci.iotproject.util"><span class="typeNameLink">Prev Class</span></a></li>
378 <li>Next Class</li>
381 <li><a href="../../../../index.html?edu/uci/iotproject/util/PrintUtils.html" target="_top">Frames</a></li>
382 <li><a href="PrintUtils.html" target="_top">No Frames</a></li>
384 <ul class="navList" id="allclasses_navbar_bottom">
385 <li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
388 <script type="text/javascript"><!--
389 allClassesLink = document.getElementById("allclasses_navbar_bottom");
391 allClassesLink.style.display = "block";
394 allClassesLink.style.display = "none";
400 <ul class="subNavList">
401 <li>Summary: </li>
402 <li>Nested | </li>
403 <li>Field | </li>
404 <li>Constr | </li>
405 <li><a href="#method.summary">Method</a></li>
407 <ul class="subNavList">
408 <li>Detail: </li>
409 <li>Field | </li>
410 <li>Constr | </li>
411 <li><a href="#method.detail">Method</a></li>
414 <a name="skip.navbar.bottom">
417 <!-- ======== END OF BOTTOM NAVBAR ======= -->