|
| 1 | +--- |
| 2 | +title: Perform data plane packet capture for a packet core instance |
| 3 | +titleSuffix: Azure Private 5G Core Preview |
| 4 | +description: In this how-to guide, you'll learn how to perform data plane packet capture for a packet core instance. |
| 5 | +author: James-Green-Microsoft |
| 6 | +ms.author: jamesgreen |
| 7 | +ms.service: private-5g-core |
| 8 | +ms.topic: conceptual |
| 9 | +ms.date: 12/13/2022 |
| 10 | +ms.custom: template-how-to |
| 11 | +--- |
| 12 | + |
| 13 | +# Perform data plane packet capture for a packet core instance |
| 14 | + |
| 15 | +Packet capture for data plane packets is performed using the **UPF Trace (UPFT)** tool. UPFT is similar to **tcpdump**, a data-network packet analyzer computer program that runs on a command line interface. You can use this tool to monitor and record packets on any user plane interface on the access network or data network on your device. |
| 16 | + |
| 17 | +Data plane packet capture works by mirroring packets to a Linux kernel interface, which can then be monitored using tcpdump. In this how-to guide, you'll learn how to perform data plane packet capture for a packet core instance. |
| 18 | + |
| 19 | +> [!IMPORTANT] |
| 20 | +> Performing packet capture will reduce the performance of your system and the throughput of your data plane. It is therefore only recommended to use this tool at low scale during initial testing. |
| 21 | +
|
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +- Identify the **Kubernetes - Azure Arc** resource representing the Azure Arc-enabled Kubernetes cluster on which your packet core instance is running. |
| 25 | +- Ensure you have [Contributor](../role-based-access-control/built-in-roles.md#contributor) role assignment on the Azure subscription containing the **Kubernetes - Azure Arc** resource. |
| 26 | +- Ensure your local machine has core kubectl access to the Azure Arc-enabled Kubernetes cluster. This requires a core kubeconfig file. <!-- TODO: See <link> for instructions on how to obtain this. --> |
| 27 | + |
| 28 | +## Performing packet capture |
| 29 | + |
| 30 | +1. In a command line with kubectl access to the Azure Arc-enabled Kubernetes cluster, enter the UPF-PP troubleshooter pod: |
| 31 | + |
| 32 | + `kubectl exec -it -n core core-upf-pp-0 -c troubleshooter -- bash`. |
| 33 | + |
| 34 | +1. View the list of interfaces that can be monitored: |
| 35 | + |
| 36 | + `upft list`. |
| 37 | + |
| 38 | +1. Either: |
| 39 | + - Run `upftdump` with any parameters that you would usually pass to tcpdump. In particular, `-i` to specify the interface, and `-w` to specify where to write to. Close the UPFT tool when done by pressing <kbd>Ctrl + C</kbd>. |
| 40 | + - Or if you wish to enable packet capture and run tcpdump separately: |
| 41 | + 1. Enable packet capture by running `upft start <interface> <duration>`, where |
| 42 | + - \<interface\> specifies the interface or interfaces to enable capture on. You can specify `any` to enable packet capture on all possible interfaces. |
| 43 | + - \<duration\> specifies the time in seconds before packet capture automatically disables. |
| 44 | + 1. Type *yes* when prompted and then press <kbd>Enter</kbd> to continue. |
| 45 | + 1. Run `tcpdump` on the interface. |
| 46 | + 1. Once complete, run `upft stop <interface>` to disable packet capture if the timer has not expired. |
| 47 | +1. Leave the container: |
| 48 | + |
| 49 | + `exit` |
| 50 | + |
| 51 | +1. Copy the output files: |
| 52 | + |
| 53 | + `kubectl cp -n core core-upf-pp-0: <path to output file> <location to copy to> -c troubleshooter`. |
| 54 | + |
| 55 | + The `tcpdump` may have been stopped in the middle of writing a packet, which can cause this step to produce an error stating `unexpected EOF`. However, your file should have copied successfully, but you can check your target output file to confirm. |
| 56 | + |
| 57 | +1. Remove the output files: |
| 58 | + |
| 59 | + `kubectl exec -it -n core core-upf-pp-0 -c troubleshooter – bash rm` |
| 60 | + |
| 61 | +## Next steps |
| 62 | + |
| 63 | +For more options to monitor your deployment and view analytics: |
| 64 | + |
| 65 | +- [Learn more about enabling log analytics Azure Private 5G Core](enable-log-analytics-for-private-5g-core.md) |
| 66 | +- [Learn more about monitoring Azure Private 5G Core using Log Analytics](monitor-private-5g-core-with-log-analytics.md) |
0 commit comments