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. You will normally work on Packets returned from <span style="font-style: italic;">Trace.read_packet() </span> or a <span style="font-style: italic;">Trace iterator</span> (see Trace Handling), but you can create a new packet instance with <span style="font-style: italic;">packet()</span> (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() -> aPacket</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description vspace1">Makes a new Python Packet. A
python-libtrace packet maintains a set of pointers into a libtrace
packet or a python-libtrace data object. 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>> 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 -> 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 -> 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 -> 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 -> 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-> 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 -> aData</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">Gets a TCP payload 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 -> 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 -> aData</em></td>
</tr>
<tr>
<td><br />
</td>
<td class="description">
Gets a UDP payload 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 -> 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 -> 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) -> 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 -> 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 -> 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 -> 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 -> 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 -> 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> -> 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 -> 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 -> 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 -> 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 -> 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 -> 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. 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> 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. The byte array may not be longer than the
original data from the packet.</td></tr>
</tbody>
</table>
<br />
<p>Nevil Brownlee<br />Mon, 13 Apr 15 (NZST)</p>
</body></html>
|