[SDFAB-540] Add UP4 test with attached UE and GTP routed traffic
Ensure that when UEs are attached, traffic to the BESS UPF is not
terminated in the fabric, but forwarded to the BESS host
Change-Id: I5dbd95fda9e51d63cdc09a204b4a28fca8cfe098
diff --git a/TestON/tests/USECASE/SegmentRouting/QOS/QOS.py b/TestON/tests/USECASE/SegmentRouting/QOS/QOS.py
index 6aed867..df535c5 100644
--- a/TestON/tests/USECASE/SegmentRouting/QOS/QOS.py
+++ b/TestON/tests/USECASE/SegmentRouting/QOS/QOS.py
@@ -25,15 +25,20 @@
run.installOnos(main, skipPackage=True, cliSleep=5)
main.step("Start P4rt client and setup TRex")
+ # Use the first available ONOS instance CLI
+ onos_cli = main.Cluster.active(0).CLI
up4 = UP4()
trex = Trex()
# Get the P4RT client connected to UP4 in the first available ONOS instance
up4.setup(main.Cluster.active(0).p4rtUp4)
trex.setup(main.TRexClient)
- main.step("Attach UEs")
+ main.step("Program PDRs and FARs via UP4")
up4.attachUes()
+ main.step("Verify PDRs and FARs in ONOS")
+ up4.verifyUp4Flow(onos_cli)
+
# Load traffic config for the current test case
main.step("Load test JSON config")
cfgFile = main.configPath + "/tests/" + "leaf_edge_mobile.json"
@@ -60,9 +65,12 @@
main.step("{}: Assert 99.9 Percentile Latency".format(flow))
trex.assert99_9PercentileLatency(flow)
- main.step("Detach UEs")
+ main.step("Remove PDRs and FARs via UP4")
up4.detachUes()
+ main.step("Verify removed PDRs and FARs from ONOS")
+ up4.verifyNoUesFlow(onos_cli)
+
main.step("Teardown")
trex.teardown()
up4.teardown()
diff --git a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.params b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.params
index 113d33d..98dc41e 100644
--- a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.params
+++ b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.params
@@ -1,5 +1,5 @@
<PARAMS>
- <testcases>1</testcases>
+ <testcases>1,2</testcases>
<GRAPH>
<nodeCluster>pairedleaves</nodeCluster>
diff --git a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.py b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.py
index 0dcbbd8..14b845f 100644
--- a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.py
+++ b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.py
@@ -5,13 +5,16 @@
# TODO: add test case that checks entries are being inserted and deleted from ONOS correclty
def CASE1(self, main):
+ main.case("Fabric UPF traffic terminated in the fabric")
"""
- Attach UE
+ Program PDRs and FARs for UEs
+ Verify PDRs and FARs
Generate traffic from UE to PDN
Verify traffic received from PDN
Generate traffic from PDN to UE
Verify traffic received from UE
- Detach UE
+ Remove PDRs and FARs for UEs
+ Verify removed PDRs and FARs
"""
try:
from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
@@ -28,13 +31,18 @@
run.installOnos(main, skipPackage=True, cliSleep=5)
main.step("Start scapy and p4rt client")
+ # Use the first available ONOS instance CLI
+ onos_cli = main.Cluster.active(0).CLI
up4 = UP4()
# Get the P4RT client connected to UP4 in the first available ONOS instance
up4.setup(main.Cluster.active(0).p4rtUp4)
- main.step("Attach UEs")
+ main.step("Program PDRs and FARs via UP4")
up4.attachUes()
+ main.step("Verify PDRs and FARs in ONOS")
+ up4.verifyUp4Flow(onos_cli)
+
# ------- Test Upstream traffic (enb->pdn)
main.step("Test upstream traffic")
up4.testUpstreamTraffic()
@@ -43,9 +51,202 @@
main.step("Test downstream traffic")
up4.testDownstreamTraffic()
- main.step("Detach UEs")
+ main.step("Remove PDRs and FARs via UP4")
up4.detachUes()
+ main.step("Verify removed PDRs and FARs from ONOS")
+ up4.verifyNoUesFlow(onos_cli)
+
main.step("Stop scapy and p4rt client")
up4.teardown()
run.cleanup(main)
+
+ def CASE2(self):
+ main.case("BESS traffic routed")
+ """
+ Program PDRs and FARs for UEs managed via UP4
+ Verify PDRs and FARs
+ Verify Upstream Traffic: eNB -> Fabric -> BESS (encapped)
+ Verify Upstream Traffic: BESS -> Fabric -> PDN (not encapped)
+ Verify Downstream Traffic: PDN -> Fabric -> BESS (not encapped)
+ Verify Downstream Traffic: BESS -> Fabric -> eNB (encapped)
+ Remove PDRs and FARs for UEs managed via UP4
+ Verify removed PDRs and FARs
+ """
+ BESS_TEID = 300
+ BESS_UE_ADDR = "10.241.0.1"
+ GPDU_PORT = 2152
+ UE_PORT = 400
+ PDN_PORT = 800
+ try:
+ from tests.USECASE.SegmentRouting.dependencies.up4 import UP4
+ from tests.USECASE.SegmentRouting.dependencies.Testcaselib import \
+ Testcaselib as run
+ except ImportError as e:
+ main.log.error("Import not found. Exiting the test")
+ main.log.error(e)
+ main.cleanAndExit()
+
+ run.initTest(main)
+ main.log.info(main.Cluster.numCtrls)
+ main.Cluster.setRunningNode(3)
+ run.installOnos(main, skipPackage=True, cliSleep=5)
+
+ main.step("Start scapy and p4rt client + Scapy on BESS Host")
+ # Use the first available ONOS instance CLI
+ onos_cli = main.Cluster.active(0).CLI
+ up4 = UP4()
+ # Get the P4RT client connected to UP4 in the first available ONOS instance
+ up4.setup(main.Cluster.active(0).p4rtUp4)
+
+ # Setup the emulated BESS host and required parameters
+ bess_host = main.Compute2 # FIXME: Parametrize?
+ bess_interface = bess_host.interfaces[0]
+ bess_s1u_address = bess_interface["ips"][0]
+ bess_host.startScapy(ifaceName=bess_interface["name"], enableGtp=True)
+ enodeb_host = up4.enodeb_host
+ enodeb_interface = up4.enodeb_interface
+ pdn_host = up4.pdn_host
+ pdn_interface = up4.pdn_interface
+
+ main.step("Program PDRs and FARs for UEs via UP4")
+ up4.attachUes()
+
+ main.step("Verify PDRs and FARs in ONOS")
+ up4.verifyUp4Flow(onos_cli)
+
+ # ------------------- UPSTREAM -------------------
+ # ------- eNB -> fabric -> BESS (encapped)
+ main.step("Test upstream eNB -> fabric -> BESS")
+ # Start filter before sending packets, BESS should receive GTP encapped
+ # packets
+ pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
+ GPDU_PORT, GPDU_PORT, up4.enb_address, bess_s1u_address)
+ main.log.info("Start listening on %s intf %s" % (
+ bess_host.name, bess_interface["name"]))
+ main.log.debug("BPF Filter BESS Upstream: \n %s" % pkt_filter_upstream)
+ bess_host.startFilter(ifaceName=bess_interface["name"],
+ sniffCount=1,
+ pktFilter=pkt_filter_upstream)
+ # Send GTP Packet
+ UP4.buildGtpPacket(enodeb_host,
+ src_ip_outer=up4.enb_address,
+ dst_ip_outer=bess_s1u_address,
+ src_ip_inner=BESS_UE_ADDR,
+ dst_ip_inner=pdn_interface["ips"][0],
+ src_udp_inner=UE_PORT,
+ dst_udp_inner=PDN_PORT,
+ teid=BESS_TEID)
+ enodeb_host.sendPacket()
+
+ packets = UP4.checkFilterAndGetPackets(bess_host)
+ # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
+ n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
+ tot_packets = packets.count('Ether')
+ utilities.assert_equal(expect=True,
+ actual=n_packets == 1 and tot_packets == 1,
+ onpass="BESS correctly received 1 GTP encapped packet",
+ onfail="ERROR: BESS received %d GTP encapped packets and filter captured %d packets" % (
+ n_packets, tot_packets))
+
+ # ------- BESS -> fabric -> PDN (not-encapped)
+ main.step("Test upstream BESS -> fabric -> PDN")
+ # Start filter before sending packets, PDN should receive non-GTP packet
+ pkt_filter_upstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
+ UE_PORT, PDN_PORT, BESS_UE_ADDR, pdn_interface["ips"][0])
+ main.log.info("Start listening on %s intf %s" % (
+ pdn_host.name, pdn_interface["name"]))
+ main.log.debug("BPF Filter PDN Upstream: \n %s" % pkt_filter_upstream)
+ pdn_host.startFilter(ifaceName=pdn_interface["name"],
+ sniffCount=1,
+ pktFilter=pkt_filter_upstream)
+ # Send UDP Packet
+ UP4.buildUdpPacket(bess_host,
+ src_ip=BESS_UE_ADDR,
+ dst_ip=pdn_interface["ips"][0],
+ src_udp=UE_PORT,
+ dst_udp=PDN_PORT)
+ bess_host.sendPacket()
+
+ packets = UP4.checkFilterAndGetPackets(pdn_host)
+ tot_packets = packets.count('Ether')
+ utilities.assert_equal(expect=True,
+ actual=tot_packets == 1,
+ onpass="PDN correctly received 1 packet",
+ onfail="ERROR: PDN received %d packets" % (
+ tot_packets))
+ # ------------------------------------------------
+
+ # ------------------ DOWNSTREAM ------------------
+ # ------- PDN -> fabric -> BESS (not-encapped)
+ main.step("Test downstream PDN -> fabric -> BESS")
+ pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
+ PDN_PORT, UE_PORT, pdn_interface["ips"][0], BESS_UE_ADDR)
+ main.log.info("Start listening on %s intf %s" % (
+ bess_host.name, bess_interface["name"]))
+ main.log.debug(
+ "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
+ bess_host.startFilter(ifaceName=bess_interface["name"],
+ sniffCount=1,
+ pktFilter=pkt_filter_downstream)
+ UP4.buildUdpPacket(pdn_host,
+ dst_eth=up4.router_mac,
+ src_ip=pdn_interface["ips"][0],
+ dst_ip=BESS_UE_ADDR,
+ src_udp=PDN_PORT,
+ dst_udp=UE_PORT)
+ pdn_host.sendPacket()
+
+ packets = UP4.checkFilterAndGetPackets(bess_host)
+
+ tot_packets = packets.count('Ether')
+ utilities.assert_equal(expect=True,
+ actual=tot_packets == 1,
+ onpass="BESS correctly received 1 packet",
+ onfail="ERROR: BESS received %d packets" % (
+ tot_packets))
+
+ # ------- BESS -> fabric -> eNB (encapped)
+ main.step("Test downstream BESS -> fabric -> eNB")
+ pkt_filter_downstream = "ip and udp src port %d and udp dst port %d and src host %s and dst host %s" % (
+ GPDU_PORT, GPDU_PORT, bess_s1u_address, up4.enb_address)
+ main.log.info("Start listening on %s intf %s" % (
+ enodeb_host.name, enodeb_interface["name"]))
+ main.log.debug(
+ "BPF Filter BESS Downstream: \n %s" % pkt_filter_downstream)
+ enodeb_host.startFilter(ifaceName=enodeb_interface["name"],
+ sniffCount=1,
+ pktFilter=pkt_filter_downstream)
+ # Build GTP packet from BESS host
+ UP4.buildGtpPacket(bess_host,
+ src_ip_outer=bess_s1u_address,
+ dst_ip_outer=up4.enb_address,
+ src_ip_inner=pdn_interface["ips"][0],
+ dst_ip_inner=BESS_UE_ADDR,
+ src_udp_inner=PDN_PORT,
+ dst_udp_inner=UE_PORT,
+ teid=BESS_TEID)
+ bess_host.sendPacket()
+
+ packets = UP4.checkFilterAndGetPackets(enodeb_host)
+
+ # FIXME: with newer scapy TEID becomes teid (required for Scapy 2.4.5)
+ n_packets = packets.count("TEID=" + hex(BESS_TEID) + "L ")
+ tot_packets = packets.count('Ether')
+ utilities.assert_equal(expect=True,
+ actual=n_packets == 1 and tot_packets == 1,
+ onpass="eNodeB correctly received 1 GTP encapped packet",
+ onfail="ERROR: eNodeb received %d GTP encapped packets and filter captured %d packets" % (
+ n_packets, tot_packets))
+ # ------------------------------------------------
+
+ main.step("Remove PDRs and FARs for UEs via UP4")
+ up4.detachUes()
+
+ main.step("Verify removed PDRs and FARs from ONOS")
+ up4.verifyNoUesFlow(onos_cli)
+
+ main.step("Stop scapy and p4rt client")
+ up4.teardown()
+ bess_host.stopScapy()
+ run.cleanup(main)
diff --git a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.topo b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.topo
index 5dac34a..8605cad 100644
--- a/TestON/tests/USECASE/SegmentRouting/UP4/UP4.topo
+++ b/TestON/tests/USECASE/SegmentRouting/UP4/UP4.topo
@@ -56,6 +56,35 @@
</COMPONENTS>
</Compute1>
+ <Compute2>
+ <host>10.76.28.72</host>
+ <user>jenkins</user>
+ <password></password>
+ <type>HostDriver</type>
+ <connect_order>7</connect_order>
+ <jump_host></jump_host>
+ <COMPONENTS>
+ <mac></mac>
+ <inband>false</inband>
+ <dhcp>True</dhcp>
+ <ip>10.32.11.3</ip>
+ <shortName>h2</shortName>
+ <port1></port1>
+ <link1></link1>
+ <ifaceName>pairbond</ifaceName>
+ <scapy_path>/usr/bin/scapy</scapy_path>
+ <routes>
+ <route1>
+ <network></network>
+ <netmask></netmask>
+ <gw></gw>
+ <interface></interface>
+ </route1>
+ </routes>
+ <sudo_required>true</sudo_required>
+ </COMPONENTS>
+ </Compute2>
+
<Compute3>
<host>10.76.28.68</host>
<user>jenkins</user>
diff --git a/TestON/tests/USECASE/SegmentRouting/dependencies/up4.py b/TestON/tests/USECASE/SegmentRouting/dependencies/up4.py
index dd1c72a..344d0cf 100644
--- a/TestON/tests/USECASE/SegmentRouting/dependencies/up4.py
+++ b/TestON/tests/USECASE/SegmentRouting/dependencies/up4.py
@@ -119,29 +119,18 @@
main.log.info(
"Sending %d packets from eNodeB host" % len(self.emulated_ues))
for ue in self.emulated_ues.values():
- self.enodeb_host.buildEther()
- self.enodeb_host.buildIP(src=self.enb_address, dst=self.s1u_address)
- self.enodeb_host.buildUDP(ipVersion=4, dport=GPDU_PORT)
- # FIXME: With newer scapy TEID becomes teid (required for Scapy 2.4.5)
- self.enodeb_host.buildGTP(gtp_type=0xFF, TEID=int(ue["teid"]))
- self.enodeb_host.buildIP(overGtp=True, src=ue["ue_address"],
- dst=self.pdn_interface["ips"][0])
- self.enodeb_host.buildUDP(ipVersion=4, overGtp=True, sport=UE_PORT,
- dport=PDN_PORT)
+ UP4.buildGtpPacket(self.enodeb_host,
+ src_ip_outer=self.enb_address,
+ dst_ip_outer=self.s1u_address,
+ src_ip_inner=ue["ue_address"],
+ dst_ip_inner=self.pdn_interface["ips"][0],
+ src_udp_inner=UE_PORT,
+ dst_udp_inner=PDN_PORT,
+ teid=int(ue["teid"]))
self.enodeb_host.sendPacket(iface=self.enodeb_interface["name"])
- finished = self.pdn_host.checkFilter()
- packets = ""
- if finished:
- packets = self.pdn_host.readPackets(detailed=True)
- for p in packets.splitlines():
- main.log.debug(p)
- # We care only of the last line from readPackets
- packets = packets.splitlines()[-1]
- else:
- kill = self.pdn_host.killFilter()
- main.log.debug(kill)
+ packets = UP4.checkFilterAndGetPackets(self.pdn_host)
fail = False
if len(self.emulated_ues) != packets.count('Ether'):
fail = True
@@ -179,23 +168,15 @@
for ue in self.emulated_ues.values():
# From PDN we have to set dest MAC, otherwise scapy will do ARP
# request for the UE IP address.
- self.pdn_host.buildEther(dst=self.router_mac)
- self.pdn_host.buildIP(src=self.pdn_interface["ips"][0],
- dst=ue["ue_address"])
- self.pdn_host.buildUDP(ipVersion=4, sport=PDN_PORT, dport=UE_PORT)
+ UP4.buildUdpPacket(self.pdn_host,
+ dst_eth=self.router_mac,
+ src_ip=self.pdn_interface["ips"][0],
+ dst_ip=ue["ue_address"],
+ src_udp=PDN_PORT,
+ dst_udp=UE_PORT)
self.pdn_host.sendPacket(iface=self.pdn_interface["name"])
- finished = self.enodeb_host.checkFilter()
- packets = ""
- if finished:
- packets = self.enodeb_host.readPackets(detailed=True)
- for p in packets.splitlines():
- main.log.debug(p)
- # We care only of the last line from readPackets
- packets = packets.splitlines()[-1]
- else:
- kill = self.enodeb_host.killFilter()
- main.log.debug(kill)
+ packets = UP4.checkFilterAndGetPackets(self.enodeb_host)
# The BPF filter might capture non-GTP packets because we can't filter
# GTP header in BPF. For this reason, check that the captured packets
@@ -221,6 +202,111 @@
utilities.assert_equal(
expect=False, actual=fail, onpass=msg, onfail=msg)
+ def verifyNoUesFlow(self, onosCli, retries=3):
+ """
+ Verify that no PDRs and FARs are installed in ONOS.
+
+ :param onosCli: An instance of a OnosCliDriver
+ :param retries: number of retries
+ :return:
+ """
+ retValue = utilities.retry(f=UP4.__verifyNoPdrsFarsOnos,
+ retValue=False,
+ args=[onosCli],
+ sleep=1,
+ attempts=retries)
+ utilities.assert_equal(expect=True,
+ actual=retValue,
+ onpass="No PDRs and FARs in ONOS",
+ onfail="Stale PDRs or FARs")
+
+ @staticmethod
+ def __verifyNoPdrsFarsOnos(onosCli):
+ """
+ Verify that no PDRs and FARs are installed in ONOS
+
+ :param onosCli: An instance of a OnosCliDriver
+ """
+ pdrs = onosCli.sendline(cmdStr="up4:read-pdrs", showResponse=True,
+ noExit=True, expectJson=False)
+ fars = onosCli.sendline(cmdStr="up4:read-fars", showResponse=True,
+ noExit=True, expectJson=False)
+ return pdrs == "" and fars == ""
+
+ def verifyUp4Flow(self, onosCli):
+ """
+ Verify PDRs and FARs installed via UP4 using the ONOS CLI.
+
+ :param onosCli: An instance of a OnosCliDriver
+ """
+ pdrs = onosCli.sendline(cmdStr="up4:read-pdrs", showResponse=True,
+ noExit=True, expectJson=False)
+ fars = onosCli.sendline(cmdStr="up4:read-fars", showResponse=True,
+ noExit=True, expectJson=False)
+ fail = False
+ failMsg = ""
+ for ue in self.emulated_ues.values():
+ if pdrs.count(self.upPdrOnosString(**ue)) != 1:
+ failMsg += self.upPdrOnosString(**ue) + "\n"
+ fail = True
+ if pdrs.count(self.downPdrOnosString(**ue)) != 1:
+ failMsg += self.downPdrOnosString(**ue) + "\n"
+ fail = True
+ if fars.count(self.upFarOnosString(**ue)) != 1:
+ failMsg += self.upFarOnosString(**ue) + "\n"
+ fail = True
+ if fars.count(self.downFarOnosString(**ue)) != 1:
+ failMsg += self.downFarOnosString(**ue) + "\n"
+ fail = True
+ utilities.assert_equal(expect=False, actual=fail,
+ onpass="Correct PDRs and FARs in ONOS",
+ onfail="Wrong PDRs and FARs in ONOS. Missing PDR/FAR:\n" + failMsg)
+
+ def upPdrOnosString(self, pfcp_session_id, teid=None, up_id=None,
+ teid_up=None, far_id_up=None, ctr_id_up=None, qfi=None,
+ **kwargs):
+ # TODO: consider that with five_g the output might be different
+ if up_id is not None:
+ far_id_up = up_id
+ ctr_id_up = up_id
+ if teid is not None:
+ teid_up = teid
+ if qfi is not None:
+ return "PDR{{Match(Dst={}, TEID={}) -> LoadParams(SEID={}, FAR={}, CtrIdx={}, QFI={})}}".format(
+ self.s1u_address, hex(int(teid_up)), hex(int(pfcp_session_id)),
+ far_id_up,
+ ctr_id_up, qfi)
+ return "PDR{{Match(Dst={}, TEID={}) -> LoadParams(SEID={}, FAR={}, CtrIdx={})}}".format(
+ self.s1u_address, hex(int(teid_up)), hex(int(pfcp_session_id)),
+ far_id_up, ctr_id_up)
+
+ def downPdrOnosString(self, pfcp_session_id, ue_address, down_id=None,
+ far_id_down=None, ctr_id_down=None, **kwargs):
+ # TODO: consider that with five_g the output might be different
+ if down_id is not None:
+ far_id_down = down_id
+ ctr_id_down = down_id
+ return "PDR{{Match(Dst={}, !GTP) -> LoadParams(SEID={}, FAR={}, CtrIdx={})}}".format(
+ ue_address, hex(int(pfcp_session_id)), far_id_down, ctr_id_down)
+
+ def downFarOnosString(self, pfcp_session_id, teid=None, down_id=None,
+ teid_down=None, far_id_down=None, **kwargs):
+ if down_id is not None:
+ far_id_down = down_id
+ if teid is not None:
+ teid_down = teid
+ return "FAR{{Match(ID={}, SEID={}) -> Encap(Src={}, SPort={}, TEID={}, Dst={})}}".format(
+ far_id_down, hex(int(pfcp_session_id)), self.s1u_address, GPDU_PORT,
+ hex(int(teid_down)),
+ self.enb_address)
+
+ def upFarOnosString(self, pfcp_session_id, up_id=None, far_id_up=None,
+ **kwargs):
+ if up_id is not None:
+ far_id_up = up_id
+ return "FAR{{Match(ID={}, SEID={}) -> Forward()}}".format(
+ far_id_up, hex(int(pfcp_session_id)))
+
@staticmethod
def __sanitizeUeData(ue):
if "five_g" in ue:
@@ -406,3 +492,36 @@
"*** Entry %d of %d deleted." % (i + 1, len(entries)))
else:
main.log.error("Error during table delete")
+
+ @staticmethod
+ def buildGtpPacket(host, src_ip_outer, dst_ip_outer, src_ip_inner,
+ dst_ip_inner, src_udp_inner, dst_udp_inner, teid):
+ host.buildEther()
+ host.buildIP(src=src_ip_outer, dst=dst_ip_outer)
+ host.buildUDP(ipVersion=4, dport=GPDU_PORT)
+ # FIXME: With newer scapy TEID becomes teid (required for Scapy 2.4.5)
+ host.buildGTP(gtp_type=0xFF, TEID=teid)
+ host.buildIP(overGtp=True, src=src_ip_inner, dst=dst_ip_inner)
+ host.buildUDP(ipVersion=4, overGtp=True, sport=src_udp_inner,
+ dport=dst_udp_inner)
+
+ @staticmethod
+ def buildUdpPacket(host, src_ip, dst_ip, src_udp, dst_udp, src_eth=None,
+ dst_eth=None):
+ host.buildEther(src=src_eth, dst=dst_eth)
+ host.buildIP(src=src_ip, dst=dst_ip)
+ host.buildUDP(ipVersion=4, sport=src_udp, dport=dst_udp)
+
+ @staticmethod
+ def checkFilterAndGetPackets(host):
+ finished = host.checkFilter()
+ if finished:
+ packets = host.readPackets(detailed=True)
+ for p in packets.splitlines():
+ main.log.debug(p)
+ # We care only of the last line from readPackets
+ return packets.splitlines()[-1]
+ else:
+ kill = host.killFilter()
+ main.log.debug(kill)
+ return ""