{"id":13799729,"url":"https://github.com/801room/upf_p4_poc","last_synced_at":"2025-05-13T08:31:54.608Z","repository":{"id":144665778,"uuid":"302862908","full_name":"801room/upf_p4_poc","owner":"801room","description":"This project is a proof of concept for 5g upf based on p4.","archived":false,"fork":false,"pushed_at":"2020-10-10T23:07:00.000Z","size":416,"stargazers_count":32,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-18T14:59:15.086Z","etag":null,"topics":["5g","p4","pfcp","upf"],"latest_commit_sha":null,"homepage":"","language":"P4","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/801room.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-10T09:16:37.000Z","updated_at":"2024-06-27T09:35:45.000Z","dependencies_parsed_at":"2024-01-07T08:10:41.047Z","dependency_job_id":"975f0846-0bef-4619-bca3-f7ef150b1757","html_url":"https://github.com/801room/upf_p4_poc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/801room%2Fupf_p4_poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/801room%2Fupf_p4_poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/801room%2Fupf_p4_poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/801room%2Fupf_p4_poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/801room","download_url":"https://codeload.github.com/801room/upf_p4_poc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253903837,"owners_count":21981758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["5g","p4","pfcp","upf"],"created_at":"2024-08-04T00:01:05.490Z","updated_at":"2025-05-13T08:31:54.257Z","avatar_url":"https://github.com/801room.png","language":"P4","funding_links":[],"categories":["Core Network","NFs"],"sub_categories":["5G"],"readme":"# upf_p4_poc\r\nThis project is a proof of concept for 5g upf based on p4.\r\nThe project uses open source project to verify key technologies, such as pfcp, p4runtime RPC and programmable dataplane pipeline.\r\n\r\n## Related open source projects\r\n1) **go-pfcp** https://github.com/wmnsk/go-pfcp  \u003cbr\u003e\r\nPFCP implementation in Golang.This project use go-pfcp to decode/code pfcp message.\r\n2) **p4runtime-go-client** https://github.com/antoninbas/p4runtime-go-client \u003cbr\u003e\r\nGo client for P4Runtime.This project use  p4runtime-go-client to connect stratum_bmv2(as swithos and pipeline instance),config pipeline and insert table entry.\r\n3) **scapy** https://github.com/secdev/scapy \u003cbr\u003e\r\nScapy is a powerful Python-based interactive packet manipulation program and library.\r\nThis project use it to construct and send PFCP request messages.I also use it to send user plane uplink and downlink data packets for function test.\r\n4) **ngsdn-tutorial** https://github.com/opennetworkinglab/ngsdn-tutorial \u003cbr\u003e\r\nTutorial for Next-generation SDN (NG-SDN).It contains a set of containers, such as p4c, mininet(include stratum-bmv2), onos. Use it as a p4 compilation and test runtime environment.\r\n\r\n## What is UPF?\r\nThe User Plane Function (UPF) is a fundamental component of a 3GPP 5G core infrastructure system architecture.\r\nIt acts as a gateway between the base station and the data network.The UPF identifies user plane traffic flow and action based on information received from control plane network function(as SMF in 5g).\r\n![5g_arch](./doc/5g_arch.jpg)\r\n\u003cbr\u003e\r\nPFCP(Packet Forwarding Control Protocol) used in CP NF to control UPF,it defined in 3GPP TS29.244.\r\nIt is similar to OpenFlow. Maybe consider it  as the southbound interface of the dataplane in the mobile networks.\r\n![n4_pfcp](./doc/n4_pfcp.jpg)\r\nPacket processing flow in the UP function(ps:I think this processing flow is just an ideal definition, and there are multiple implementations ^_^)\r\n![process_flow](./doc/process_flow.jpg)\r\n\u003cbr\u003e\r\nThe GTP (GPRS Tunnelling Protocol) protocol provides protocol channels between mobile access network and  core network. All UE access DN should be encapsulated by the GTP protocol.\u003cbr\u003e\r\nGTP-U header.\r\n![gtpu_header](./doc/gtpu_header.jpg)\r\nUser plane protocol stack for a PDU session\r\n![gtpu_pdu_session](./doc/gtpu_pdu_session.jpg)\r\n\r\n## Requirements\r\nOS:Ubuntu 18.04 \u003cbr\u003e\r\nGo (\u003e= 1.14) \u003cbr\u003e\r\nps:maybe need to set proxy  getting package,like me \r\n```\r\nexport GO111MODULE=on\r\nexport GOPROXY=https://goproxy.cn\r\n```\r\ndocker docker-compose git python2.7 make ...\r\n\r\n## Getting Started\r\n1.Download and Prepare the environment.(one time)\r\nNote：It will take some time to download docker images.\r\n```\r\ngit clone \r\nmake deps-env\r\n```\r\n2.Build\r\nThe result in \"build\" folder.\r\n```\r\nmake build\r\n```\r\n3.Runing\r\nThe components of poc\r\n![components](./doc/components.jpg)\r\nStart stratum environment,include mininet.see aslo  [ngsdn-tutorial](https://github.com/opennetworkinglab/ngsdn-tutorial) .\r\n```\r\ncd ./ngsdn-tutorial\r\nmake start\r\n```\r\n\u003cbr\u003eStart cp-upf\r\n\u003cbr\u003eNote：replace param as your environment.\r\n```\r\ncd ./build\r\n./cp-upf --addr ${STRATUMIP}:${STRATUMPORT} -bin bmv2.json -p4info p4info.txt -device-id 1 -n4addr {N4IP}:{N4PORT}\r\n```\r\n\r\n4.Test\r\nMininet config ip and downlink route by hands.\r\n```\r\ncd ./ngsdn-tutorial\r\nmake mn-cli\r\nmininet\u003e h1a ip addr add 193.168.1.2/24 dev h1a-eth0\r\nmininet\u003e h1b ip addr add 193.168.1.3/24 dev h1b-eth0\r\nmininet\u003e h1b ip route add  10.10.10.2/32 via 193.168.1.2\r\n```\r\nSend PFCP request to create pdu session.The cp-upf receive pfcp messages will translate to some p4table operations.\r\nNote:need to modify ip in the scripts based on run environment.\r\n```\r\n./test_script/pfcp_request.py\r\n```\r\nSend gtpu uplink\r\n```\r\ncd ./ngsdn-tutorial\r\nutil/mn-cmd h1a python /mininet/send_gtp_uplink.py\r\nutil/mn-cmd h1a tcpdump -i h1a-eth0 -w /tmp/uplink-ue.pcap\r\nutil/mn-cmd h1b tcpdump -i h1b-eth0 -w /tmp/uplink-dn.pcap\r\n```\r\nSend gtpu downlink \r\n```\r\nutil/mn-cmd h1b python /mininet/send_udp_downlink.py\r\nutil/mn-cmd h1a tcpdump -i h1a-eth0 -w /tmp/downlink-ue.pcap\r\nutil/mn-cmd h1b tcpdump -i h1b-eth0 -w /tmp/downlink-dn.pcap\r\n```\r\n## Planning\r\nAdd more counter and connect to onos.\r\n\u003cbr\u003eAdd packout to cpu and dpi.\r\n\u003cbr\u003eAlso I have a plan to coding upf poc based on ebpf(xdp).that will be another story,but all of them will be one story.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F801room%2Fupf_p4_poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F801room%2Fupf_p4_poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F801room%2Fupf_p4_poc/lists"}