(
algo: RSSAlgo,
traffic_template: TrafficTemplate,
check_reverse_traffic: bool = False,
all_flows: bool = False,
)
| 117 | |
| 118 | |
| 119 | def balanced_traffic( |
| 120 | algo: RSSAlgo, |
| 121 | traffic_template: TrafficTemplate, |
| 122 | check_reverse_traffic: bool = False, |
| 123 | all_flows: bool = False, |
| 124 | ) -> typing.Iterator[typing.Tuple[int, int, Packet]]: |
| 125 | queues = set() |
| 126 | if check_reverse_traffic: |
| 127 | queues_reverse = set() |
| 128 | |
| 129 | for pkt in traffic_template: |
| 130 | q = algo.get_queue_index(pkt) |
| 131 | |
| 132 | # check if q is already filled |
| 133 | if not all_flows and q in queues: |
| 134 | continue |
| 135 | |
| 136 | qr = algo.get_queue_index(pkt.reverse()) |
| 137 | |
| 138 | if check_reverse_traffic: |
| 139 | # check if q is already filled |
| 140 | if not all_flows and qr in queues_reverse: |
| 141 | continue |
| 142 | # mark this queue as matched |
| 143 | queues_reverse.add(qr) |
| 144 | |
| 145 | # mark this queue as filled |
| 146 | queues.add(q) |
| 147 | |
| 148 | yield q, qr, pkt |
| 149 | |
| 150 | # stop when all queues have been filled |
| 151 | if not all_flows and len(queues) == algo.queues_count: |
| 152 | break |
| 153 | |
| 154 | |
| 155 | NO_PORT = (0,) |
no test coverage detected