-
Notifications
You must be signed in to change notification settings - Fork 106
/
pktgen.bess
78 lines (60 loc) · 3.97 KB
/
pktgen.bess
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
# SPDX-License-Identifier: Apache-2.0
# Copyright 2021 Intel Corporation
"""
docker run --name pktgen -td --restart unless-stopped \
--cpuset-cpus=2-5 --ulimit memlock=-1 --cap-add IPC_LOCK \
-v /dev/hugepages:/dev/hugepages -v "$PWD/conf":/opt/bess/bessctl/conf \
--device=/dev/vfio/vfio --device=/dev/vfio/176 \
upf-epc-bess:"$(<VERSION)" -grpc-url=0.0.0.0:10514
"""
import conf.sim as sim
pkt_size = 128
flows = 5000
workers=[2, 3, 4, 5]
gtppsc = False
qfi = 9
smac = "22:53:7a:15:58:50"
dmac_access = "9e:b2:d3:34:ab:27"
dmac_core = "c2:9c:55:d4:8a:f6"
if gtppsc:
# flow create 0 ingress pattern eth / ipv4 / udp / gtpu / gtp_psc / ipv4 / end actions rss types ipv4 l3-src-only end key_len 0 queues end / end
n39_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_access, "11.1.1.129", "198.18.0.1", "16.0.0.1", "9.9.9.9", 0x30000000, 1, qfi),]
n36_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_access, "11.1.1.129", "198.18.0.1", "16.0.0.1", "6.6.6.6", 0x30000000, 1, qfi),]
# flow create 1 ingress pattern eth / ipv4 / udp / gtpu / gtp_psc / ipv4 / end actions rss types ipv4 l3-dst-only end key_len 0 queues end / end
n9_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_core, "13.1.1.199", "198.19.0.1", "9.9.9.9", "16.0.0.1", 0x90000000, 0, qfi),]
n3seq_offset = 70
n9seq_offset = 74
else:
# flow create 0 ingress pattern eth / ipv4 / udp / gtpu / ipv4 / end actions rss types ipv4 l3-src-only end key_len 0 queues end / end
n39_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_access, "11.1.1.129", "198.18.0.1", "16.0.0.1", "9.9.9.9", 0x30000000),]
n36_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_access, "11.1.1.129", "198.18.0.1", "16.0.0.1", "6.6.6.6", 0x30000000),]
# flow create 1 ingress pattern eth / ipv4 / udp / gtpu / ipv4 / end actions rss types ipv4 l3-dst-only end key_len 0 queues end / end
n9_pkts = [sim.gen_gtpu_packet(pkt_size, smac, dmac_core, "13.1.1.199", "198.19.0.1", "9.9.9.9", "16.0.0.1", 0x90000000),]
n3seq_offset = 62
n9seq_offset = 66
#flow create 1 ingress pattern eth / ipv4 / end actions rss types ipv4 l3-dst-only end key_len 0 queues end / end
n6_pkts = [sim.gen_inet_packet(pkt_size, smac, dmac_core, "6.6.6.6", "16.0.0.1"),]
for wid in range(len(workers)):
bess.add_worker(wid=wid, core=int(workers[wid % len(workers)]))
num_q = len(workers)
kwargs = {'size_inc_q': 512,
'size_out_q': 512,
'num_inc_q': num_q,
'num_out_q': num_q}
p = PMDPort(port_id=0, **kwargs)
n3seq_kwargs = sim.gen_gtpu_sequpdate_args(flows, "16.0.0.1", n3seq_offset, 0x30000000)
n9seq_kwargs = sim.gen_gtpu_sequpdate_args(flows, "16.0.0.1", n9seq_offset, 0x90000000)
n6seq_kwargs = sim.gen_inet_sequpdate_args(flows, "16.0.0.1")
# 25 Gbps each to saturate 100 Gbps
bess.add_tc('39_limit', wid=0, policy='rate_limit', resource='bit', limit={'bit': 25000000000})
bess.add_tc('36_limit', wid=0, policy='rate_limit', resource='bit', limit={'bit': 25000000000})
bess.add_tc('6_limit', wid=1, policy='rate_limit', resource='bit', limit={'bit': 25000000000})
bess.add_tc('9_limit', wid=1, policy='rate_limit', resource='bit', limit={'bit': 25000000000})
src39::Source(pkt_size=pkt_size) -> Rewrite(templates=n39_pkts) -> n39update::SequentialUpdate(**n3seq_kwargs) -> L4Checksum() -> IPChecksum() -> QueueOut(port=p.name, qid=0)
src36::Source(pkt_size=pkt_size) -> Rewrite(templates=n36_pkts) -> n36update::SequentialUpdate(**n3seq_kwargs) -> L4Checksum() -> IPChecksum() -> QueueOut(port=p.name, qid=1)
src9::Source(pkt_size=pkt_size) -> Rewrite(templates=n9_pkts) -> n9update::SequentialUpdate(**n9seq_kwargs) -> L4Checksum() -> IPChecksum() -> QueueOut(port=p.name, qid=2)
src6::Source(pkt_size=pkt_size) -> Rewrite(templates=n6_pkts) -> n6update::SequentialUpdate(**n6seq_kwargs) -> L4Checksum() -> IPChecksum() -> QueueOut(port=p.name, qid=3)
src39.attach_task(parent='39_limit')
src36.attach_task(parent='36_limit')
src9.attach_task(parent='9_limit')
src6.attach_task(parent='6_limit')