How to create a GTPU tunnel
w910820618 opened this issue · comments
吴洲洋 commented
In this project, I want to test the unpacking function of gtpu. How should I create a tunnel?
Is it through the command line or the message of PFCP create session?
The command line way I use is as follows:
cls.vapi.gtpu_add_del_tunnel(is_add=True,mcast_sw_if_index=0xFFFFFFFF, decap_next_index=3, src_address=cls.if_access_2.remote_ip4,dst_address=cls.if_access_2.local_ip4, teid=2)
The PFCP way I use is as follows:
vpp/src/plugins/upf/test/test_upf.py
Lines 154 to 250 in fd7c7da
def establish_session(self): | |
cp_ip = self.if_cp.remote_ip4 | |
ue_ip = self.if_access.remote_ip4 | |
self.cur_seid = seid() | |
resp = self.chat(PFCPSessionEstablishmentRequest(IE_list=[ | |
IE_CreateFAR(IE_list=[ | |
IE_ApplyAction(FORW=1), | |
IE_FAR_Id(id=1), | |
IE_ForwardingParameters(IE_list=[ | |
IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), | |
IE_NetworkInstance(instance="sgi") | |
]) | |
]), | |
IE_CreateFAR(IE_list=[ | |
IE_ApplyAction(FORW=1), | |
IE_FAR_Id(id=2), | |
IE_ForwardingParameters(IE_list=[ | |
IE_DestinationInterface(interface="Access"), | |
IE_NetworkInstance(instance="access") | |
]) | |
]), | |
# FIXME: this is not handled properly :( | |
IE_CreateFAR(IE_list=[ | |
IE_ApplyAction(FORW=1), | |
IE_FAR_Id(id=3), | |
IE_ForwardingParameters(IE_list=[ | |
IE_DestinationInterface(interface="SGi-LAN/N6-LAN"), | |
IE_NetworkInstance(instance="sgi"), | |
IE_RedirectInformation( | |
type="IPv4 address", | |
address=REDIR_TARGET_IP) | |
]) | |
]), | |
IE_CreateFAR(IE_list=[ | |
IE_ApplyAction(DROP=1), | |
IE_FAR_Id(id=4), | |
]), | |
IE_CreatePDR(IE_list=[ | |
IE_FAR_Id(id=1), | |
IE_PDI(IE_list=[ | |
IE_NetworkInstance(instance="access"), | |
IE_SDF_Filter( | |
FD=1, | |
flow_description="permit out ip from any to assigned"), | |
IE_SourceInterface(interface="Access"), | |
IE_UE_IP_Address(ipv4=ue_ip, V4=1) | |
]), | |
IE_PDR_Id(id=1), | |
IE_Precedence(precedence=200), | |
]), | |
IE_CreatePDR(IE_list=[ | |
IE_FAR_Id(id=2), | |
IE_PDI(IE_list=[ | |
IE_NetworkInstance(instance="sgi"), | |
IE_SDF_Filter( | |
FD=1, | |
flow_description="permit out ip from any to assigned"), | |
IE_SourceInterface(interface="SGi-LAN/N6-LAN"), | |
IE_UE_IP_Address(ipv4=ue_ip, SD=1, V4=1) | |
]), | |
IE_PDR_Id(id=2), | |
IE_Precedence(precedence=200), | |
]), | |
IE_CreatePDR(IE_list=[ | |
IE_FAR_Id(id=3), | |
IE_PDI(IE_list=[ | |
IE_NetworkInstance(instance="access"), | |
IE_SDF_Filter( | |
FD=1, | |
flow_description="permit out ip from %s to assigned" % | |
REDIR_IP), | |
IE_SourceInterface(interface="Access"), | |
IE_UE_IP_Address(ipv4=ue_ip, V4=1) | |
]), | |
IE_PDR_Id(id=3), | |
IE_Precedence(precedence=100), | |
]), | |
IE_CreatePDR(IE_list=[ | |
IE_FAR_Id(id=4), | |
IE_PDI(IE_list=[ | |
IE_NetworkInstance(instance="access"), | |
IE_SDF_Filter( | |
FD=1, | |
flow_description="permit out ip from %s to assigned" % | |
DROP_IP), | |
IE_SourceInterface(interface="Access"), | |
IE_UE_IP_Address(ipv4=ue_ip, V4=1) | |
]), | |
IE_PDR_Id(id=4), | |
IE_Precedence(precedence=100), | |
]), | |
IE_FSEID(ipv4=cp_ip, v4=1, seid=self.cur_seid), | |
IE_NodeId(id_type=2, id="ergw") | |
]), PFCPSessionEstablishmentResponse, seid=self.cur_seid) | |
self.assertEqual(CauseValues[resp[IE_Cause].cause], "Request accepted") | |
self.assertEqual(resp[IE_FSEID].ipv4, self.if_cp.local_ip4) | |
self.assertEqual(resp[IE_FSEID].seid, self.cur_seid) |