| 151 | self.proc = None |
| 152 | |
| 153 | def assert_constant_payload(self): |
| 154 | tshark_cmd = [ |
| 155 | "tshark", |
| 156 | "-r", str(self.pcap), |
| 157 | "-Y", "tcp.len > 0", |
| 158 | "-T", "fields", |
| 159 | "-e", "tcp.len", |
| 160 | ] |
| 161 | |
| 162 | out = subprocess.check_output(tshark_cmd, text=True) |
| 163 | lengths = [int(x) for x in out.splitlines() if x.strip()] |
| 164 | |
| 165 | assert lengths, f"No TCP payload packets captured on port {self.port}" |
| 166 | |
| 167 | uniq = set(lengths) |
| 168 | assert len(uniq) == 1, ( |
| 169 | f"Non-constant TCP payload sizes on port {self.port}: " |
| 170 | f"{sorted(uniq)}:" |
| 171 | + subprocess.check_output(["tshark", "-r", str(self.pcap)], text=True) |
| 172 | ) |
| 173 | |
| 174 | |
| 175 | @pytest.fixture |