MCPcopy Create free account
hub / github.com/FDio/vpp / create_stream

Method create_stream

test/test_acl_plugin.py:269–341  ·  view source on GitHub ↗

Create input packet stream for defined interface using hosts or deleted_hosts list. :param object src_if: Interface to create packet stream for. :param list packet_sizes: List of required packet sizes. :param traffic_type: 1: ICMP packet, 2: IPv6 with EH, 0:

(
        self,
        src_if,
        packet_sizes,
        traffic_type=0,
        ipv6=0,
        proto=-1,
        ports=0,
        fragments=False,
        pkt_raw=True,
        etype=-1,
    )

Source from the content-addressed store, hash-verified

267 return ""
268
269 def create_stream(
270 self,
271 src_if,
272 packet_sizes,
273 traffic_type=0,
274 ipv6=0,
275 proto=-1,
276 ports=0,
277 fragments=False,
278 pkt_raw=True,
279 etype=-1,
280 ):
281 """
282 Create input packet stream for defined interface using hosts or
283 deleted_hosts list.
284
285 :param object src_if: Interface to create packet stream for.
286 :param list packet_sizes: List of required packet sizes.
287 :param traffic_type: 1: ICMP packet, 2: IPv6 with EH, 0: otherwise.
288 :return: Stream of packets.
289 """
290 pkts = []
291 if self.flows.__contains__(src_if):
292 src_hosts = self.hosts_by_pg_idx[src_if.sw_if_index]
293 for dst_if in self.flows[src_if]:
294 dst_hosts = self.hosts_by_pg_idx[dst_if.sw_if_index]
295 n_int = len(dst_hosts) * len(src_hosts)
296 for i in range(0, n_int):
297 dst_host = dst_hosts[int(i / len(src_hosts))]
298 src_host = src_hosts[i % len(src_hosts)]
299 pkt_info = self.create_packet_info(src_if, dst_if)
300 if ipv6 == 1:
301 pkt_info.ip = 1
302 elif ipv6 == 0:
303 pkt_info.ip = 0
304 else:
305 pkt_info.ip = random.choice([0, 1])
306 if proto == -1:
307 pkt_info.proto = random.choice(self.proto[self.IP])
308 else:
309 pkt_info.proto = proto
310 payload = self.info_to_payload(pkt_info)
311 p = Ether(dst=dst_host.mac, src=src_host.mac)
312 if etype > 0:
313 p = Ether(dst=dst_host.mac, src=src_host.mac, type=etype)
314 if pkt_info.ip:
315 p /= IPv6(dst=dst_host.ip6, src=src_host.ip6)
316 if fragments:
317 p /= IPv6ExtHdrFragment(offset=64, m=1)
318 else:
319 if fragments:
320 p /= IP(
321 src=src_host.ip4, dst=dst_host.ip4, flags=1, frag=64
322 )
323 else:
324 p /= IP(src=src_host.ip4, dst=dst_host.ip4)
325 if traffic_type == self.ICMP:
326 if pkt_info.ip:

Callers 5

run_traffic_no_checkMethod · 0.95
run_verify_testMethod · 0.95
run_verify_negat_testMethod · 0.95

Calls 7

create_upper_layerMethod · 0.95
__contains__Method · 0.80
create_packet_infoMethod · 0.80
info_to_payloadMethod · 0.80
copyMethod · 0.80
extend_packetMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected