Iterates the blobs (or messages) contained in this tcp connection This is dynamically generated on-demand based on the current set of packets in the connection.
(self)
| 1226 | |
| 1227 | @property |
| 1228 | def blobs(self) -> Iterable["Blob"]: |
| 1229 | """ |
| 1230 | Iterates the blobs (or messages) contained in this tcp connection |
| 1231 | |
| 1232 | This is dynamically generated on-demand based on the current set of packets in the connection. |
| 1233 | """ |
| 1234 | if self._blob_cache: |
| 1235 | yield from self._blob_cache |
| 1236 | |
| 1237 | else: |
| 1238 | blobs = [] |
| 1239 | |
| 1240 | for packet in self.packets: |
| 1241 | # TODO: skipping packets without data greatly improves speed, but we may want to |
| 1242 | # allow them if we support using ack numbers. |
| 1243 | if not packet.data: |
| 1244 | continue |
| 1245 | |
| 1246 | # If we see a sequence for an old blob, this is a retransmission. |
| 1247 | # Find the blob and add this packet. |
| 1248 | # NOTE: There is probably more to it than this, but this seems to work for now. |
| 1249 | seq = packet.sequence_number |
| 1250 | if seq is not None: |
| 1251 | found = False |
| 1252 | for blob in blobs: |
| 1253 | if blob.sip == packet.sip and seq in blob.sequence_range: |
| 1254 | blob.add_packet(packet) |
| 1255 | found = True |
| 1256 | break |
| 1257 | if found: |
| 1258 | continue |
| 1259 | |
| 1260 | # Create a new message if the first or the other direction has started sending data. |
| 1261 | if not blobs or (packet.sip != blobs[-1].sip and packet.data): |
| 1262 | blobs.append(Blob(self, packet)) |
| 1263 | |
| 1264 | # Otherwise add packet to last blob. |
| 1265 | else: |
| 1266 | blobs[-1].add_packet(packet) |
| 1267 | |
| 1268 | self._blob_cache = blobs |
| 1269 | yield from blobs |
| 1270 | |
| 1271 | def add_packet(self, packet: Packet): |
| 1272 | """ |
nothing calls this directly
no test coverage detected