File: Packet.html

package info (click to toggle)
python-libtrace 1.6%2Bgit20161027-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,124 kB
  • ctags: 1,357
  • sloc: ansic: 6,890; python: 3,228; makefile: 70; sh: 49
file content (295 lines) | stat: -rw-r--r-- 8,481 bytes parent folder | download | duplicates (5)
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html><head>





<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Handling Packets</title><meta name="generator" content="KompoZer" /><link rel="stylesheet" type="text/css" href="plt-doc.css" /></head><body>
<h2>Handling Packets</h2>
<h3>Class Packet</h3>
<p>Gives you access to fieds within (the captured part of) a packet. &nbsp;You will normally work on Packets returned from&nbsp; <span style="font-style: italic;">Trace.read_packet()&nbsp;</span> or a  <span style="font-style: italic;">Trace iterator</span> &nbsp;(see Trace Handling), but you can create a new packet instance with&nbsp; <span style="font-style: italic;">packet()</span>&nbsp; (see below).</p><p>Note
that the Layer and Decode methods return None if their requested object
was not present in the packet, or was not completely captured.</p>

<table class="indent1">
<tbody>
<tr><td class="heading" colspan="2">Class Methods</td></tr>
<tr>
<td class="name methodwidth"><strong>packet()</strong><br />
</td>
<td class="name descriptionwidth"><em>Packet() -&gt; aPacket</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description vspace1">Makes a new Python Packet.&nbsp; A
python-libtrace packet maintains a set of pointers into a libtrace
packet or a python-libtrace data object.&nbsp; In a newly-created
Packet, all such pointers are NULL.<br />
</td>
</tr>
</tbody></table>

<br /><br />
<table class="indent1">
<tbody>
<tr><td class="heading" colspan="2">Instance Methods</td></tr>


<tr>
<td class="name methodwidth"><strong>layer2</strong></td>
<td class="name descriptionwidth"><em>pkt.layer2 -</em><em><em>&gt; aLayer2</em></em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a Layer2 object from the packet; see Layers page</td>
</tr>
<tr>
<td class="name"><strong>layer3</strong></td>
<td class="name"><em>pkt.layer3 -&gt; aLayer3</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a Layer3 object from the packet; see Layers page<br />
</td>
</tr>
<tr>
<td class="name"><strong>transport</strong></td>
<td class="name"><em>pkt.transport -&gt; aTransport</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">
Gets a Transport object from the packet; see Layers page<br />
</td>
</tr>
<tr>
<td class="name"><strong>ip</strong></td>
<td class="name"><em>pkt.ip -&gt; anIP</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets an IPv4 header from the packet</td>
</tr>
<tr>
</tr><tr>
<td class="name"><strong>ip6</strong></td>
<td class="name"><em>pkt.ip6 -&gt; anIP6</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets an IPv6 header from the packet</td>
</tr>
<tr>
</tr><tr>
<td class="name"><strong>tcp</strong></td>
<td class="name"><em>pkt.tcp-&gt; aTCP</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a TCP header from the packet</td>
</tr>
<tr>
<td class="name"><strong>tcp_payload</strong></td>
<td class="name"><em>pkt.tcp_payload -&gt; aData</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a TCP payload&nbsp; from the packet, or None if it wasn't TCP.<br />
tcp_payload.data returns a ByteArray of the data<br />
</td>
</tr>
<tr>
</tr><tr>
<td class="name"><strong>udp</strong></td>
<td class="name"><em>pkt.udp -&gt; aUDP</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a UDP header from the packet</td>
</tr>
<tr>
<td class="name"><strong>udp_payload</strong></td>
<td class="name"><em>pkt.udp_payload -&gt; aData</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">
Gets a UDP payload&nbsp; from the packet, or None if it wasn't UDP.<br />
udp_payload.data returns a ByteArray of the data<br />
</td>
</tr>
<tr>
  <td class="name"><strong>icmp</strong></td>
  <td class="name"><em>pkt.icmp -&gt; anICMP</em></td>
</tr>
<tr>
  <td><br />
  </td>
  <td class="description">Gets an ICMP header from the packet</td>
</tr>
<tr>
  <td class="name"><strong>icmp6</strong></td>
  <td class="name"><em>pkt.icmp -&gt; anICMP</em></td>
</tr>
<tr>
  <td><br />
  </td>
  <td class="description">Gets an ICMP v6header from the packet</td>
</tr>
    <tr>
      <td style="vertical-align: top;"><br />
      </td>
      <td style="vertical-align: top;"><br />
      </td>
    </tr>
<tr>
<td class="name"><strong>apply_filter()</strong></td>
<td class="name"><em>pkt.apply_filter(aFilter) -&gt; result</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Tests whether the current contents of the packet
match <span style="font-style: italic;">aFilter.</span>
<br /> Result is <span style="font-style: italic;">True</span> if the filter matches, <span style="font-style: italic;">False</span> if it doesn't, or <span style="font-style: italic;">None</span> if the filter was invalid
</td>
</tr>
</tbody></table>

<br />
<table>
</table><table class="indent1">
<tbody>
<tr><td class="heading" colspan="2">Instance Variables</td></tr>
<tr>
<td class="name"><strong>data</strong></td>
<td class="name"><em>pkt.data -&gt; aByteArray </em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description vspace1">Byte array containing object's header and its following bytes.<br />
May be used for any python-libtrace object<br />

 </td>
</tr>
<tr><td class="name methodwidth"><strong>time</strong></td><td class="name descriptionwidth"><em>pkt.time -&gt; aTimeval</em></td></tr><tr><td><br />
</td><td class="description">Packet Arrival Time as a Python Time</td></tr><tr>
<td class="name"><strong>seconds</strong></td>
<td class="name descriptionwidth"><em>pkt.seconds -&gt; aFloat</em> </td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Packet Arrival Time in Unix seconds (double) </td>
</tr>
<tr>
<td class="name"><strong>ts_sec<br /></strong></td>
<td class="name"><em>pkt.ts_sec -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">
 Packet Arrival Time in Unix seconds (integer)</td>
</tr>
<tr>
<td class="name"><span style="font-weight: bold;">erf_time</span><strong /></td>
<td class="name"><em>pkt.erf_time -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description vspace1">Packet Arrival Time as a DAG ERF time (64-bit)
 </td>
</tr>
<tr>
<td class="name"><strong>wire_len</strong></td>
<td class="name"><em>pkt.wire_len</em><em> -&gt; anInteger</em> </td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Original size of packet on the wire
</td>
</tr>
<tr>
<td class="name"><strong>capture_len<em /></strong></td>
<td class="name"><em>pkt.capture_len -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Number of bytes captured; may be less than wire_len
 </td>
</tr>
<tr>
<td class="name methodwidth"><strong>ethertype</strong></td>
<td class="name descriptionwidth"><em>internet.ethertype -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Ethertype for the packet that contained this object
</td>
</tr>
<tr>
<td class="name"><strong>linktype<br /></strong></td>
<td class="name"><em>pkt.linktype -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Packet's link type; see Layer2 on Layers page for linktype values</td>
</tr>
<tr>
<td class="name"><strong>vlan_id<br /></strong></td>
<td class="name"><em>pkt.vlan_id -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">VLAN ID for packets with an 802.1Q VLAN tag, zero otherwise</td></tr>
<tr>
<td class="name"><strong>direction<br /></strong></td>
<td class="name"><em>pkt.direction -&gt; anInteger</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">'Direction' of packet, for traces from interfaces that support this, <br />e.g. ERF traces. &nbsp;Direction values are:<br />
<font size="-1">TRACE_DIR_INCOMING, TRACE_DIR_INCOMING and TRACE_DIR_OTHER</font>
</td></tr>
</tbody></table>

<p>
</p><table class="indent1">
<tbody>
<tr>
<td class="heading" colspan="2">Class <span style="font-style: italic;">Set</span> &nbsp;Method</td>
</tr>
<tr><td class="name methodwidth"><span style="font-weight: bold;">data=</span></td>
<td class="name descriptionwidth"><em>Packet.data = aByteArray</em></td>
</tr>
<tr>
<td><br />
</td><td class="vspace1">Overwrites the data bytes in a Data object
with bytes from a byte array.&nbsp; The byte array&nbsp; may not be longer than the
original data from the packet.</td></tr>
</tbody>
</table>

<br />
<p>Nevil Brownlee<br />Mon,&nbsp; 13 Apr 15 (NZST)</p>
</body></html>