- cmds = ["loopback create",
- "set int ip address loop0 192.168.1.1/24",
- "set int state loop0 up",
- "packet-generator new {\n"
- " name classifyme\n"
- " limit 100\n"
- " size 300-300\n"
- " interface loop0\n"
- " node ethernet-input\n"
- " data { \n"
- " IP4: 1.2.3 -> 4.5.6\n"
- " UDP: 192.168.1.10 - 192.168.1.20 -> 192.168.2.10\n"
- " UDP: 1234 -> 2345\n"
- " incrementing 286\n"
- " }\n"
- "}\n",
- "classify filter trace mask l3 ip4 src"
- " match l3 ip4 src 192.168.1.15",
- "trace add pg-input 100 filter",
- "pa en classifyme"]
-
- for cmd in cmds:
- self.cli(cmd)
-
- # Check for 9 classifier hits, which is the right answer
+ self.add_filter(
+ "l3 ip4 src",
+ "l3 ip4 src %s" %
+ self.pg0.remote_hosts[5].ip4)
+ self.add_filter(
+ "l3 ip4 proto l4 src_port",
+ "l3 ip4 proto 17 l4 src_port 2345")
+ # the packet we are trying to match
+ p = list()
+ for i in range(100):
+ src = self.pg0.remote_hosts[i % len(self.pg0.remote_hosts)].ip4
+ p.append((Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
+ IP(src=src, dst=self.pg1.remote_ip4) /
+ UDP(sport=1234, dport=2345) / Raw('\xa5' * 100)))
+ for i in range(17):
+ p.append((Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
+ IP(src=self.pg0.remote_hosts[0].ip4,
+ dst=self.pg1.remote_ip4) /
+ UDP(sport=2345, dport=1234) / Raw('\xa5' * 100)))
+
+ self.send_and_expect(self.pg0, p, self.pg1, trace=False)
+
+ # Check for 9 and 17 classifier hits, which is the right answer