BreadcrumbHomeResourcesBlog How To Use IOS Packet Trace and Packet Sniffing On IPhone May 17, 2017 How to Use iOS Packet Trace and Packet Sniffing on iPhoneMobile Application TestingBy Roy NurielUsing a packet trace or packet sniffer on iOS can be helpful during testing. Here we cover what packet trace and packet sniffing are — and how to use them in Perfecto. Table of ContentsWhat Is a Packet Trace?What Is iOS Packet Sniffing?How to Capture a Packet Trace on iOSHow to Use iPhone Packet SniffingGo Beyond Packet Capture on iOS Table of Contents1 - What Is a Packet Trace?2 - What Is iOS Packet Sniffing?3 - How to Capture a Packet Trace on iOS4 - How to Use iPhone Packet Sniffing5 - Go Beyond Packet Capture on iOS6 - Back to topWhat Is a Packet Trace?A packet trace is a record of traffic traveling across your network. Using a packet trace is helpful when you're debugging an application. It's also helpful while a test is running.iOS has built-in support for packet traces. (So does Mac.) Packet trace is also related to packet sniffing. Back to topWhat Is iOS Packet Sniffing?Packet sniffing is used to monitor traffic on an iPhone. Dumped network traffic contains important information regarding your device’s network connection – from DNS request and response times to overall network latency and errors, and even full HTTP/HTTPS* conversations (without the need to set a proxy!).*Encrypted, unless you have access to the web server’s SSL key.Keep reading to learn about iOS packet trace and iPhone packet sniffing.Related Reading: 3 Steps to Debug and Test Your iOS App in the Cloud >>Back to topHow to Capture a Packet Trace on iOSHere's how to enable packet capture on iOS. 1. Establish a DevTunnel SessionFirst, you need to establish a DevTunnel session on the device. Once you have an iOS device opened…Next, click on the “DevTunnel” widget on your left, and wait for the progress to reach 100%.2. Determine the UDIDNow determine the UDID of the device. The easiest way is to look in the “Information” window of the device. Click on the “Information” button:And then copy the UDID of the device by clicking on the “Copy to Clipboard” icon: 3. Create the Remote Virtual InterfaceNow that we have the device’s UDID, we can create the remote virtual interface. You can do this by using a tool called rvictl*. rvictl is a remote virtual interface tool which can be used to start a packet capture on iOS devices.rvictl is part of the XCode command line utilities. Install them if you haven't yet!4. Determine the UsageLet's go over the usage:So, when you would like to start a remote capture, assuming our UDID is (for example) 002daa400df726c38aac1,the usage would be: rvictl -s 002daa400df726c38aac1Once executed, rvictl will inform us of the new interface it has createdRunning the ‘ifconfig’ command reveals the new interface. 📲 Try Debugging With PerfectoBack to topHow to Use iPhone Packet Sniffing1. Start iPhone Packet SniffingNow you can start iPhone packet sniffing to see network traffic over the device. We can view the traffic by executing the following command: tcpdump -n -t -i rvi0 -q -A tcpAs soon as the command is executed, we start seeing the iPhone's packet sniffing data printed to our console. Packet trace magic!2. Record the TrafficRecording the traffic to a PCAP file can also be easily achieved with tcpdump by using the -w flag. This can be very useful when recording the traffic while running your daily tests.The following command would start a network sniff on the device and record the traffic to a pcap file: tcpdump -n -t -i rvi0 -q -A tcp -w out.pcap3. Use Wireshark iOS App to Analyze TrafficAnother tool that can help developers analyze the traffic is the Wireshark iOS app. Simply open Wireshark and select the rvi0 interface:4. Look at the Sniffed PacketsOnce the capture has been started, we can immediately see the sniffed packets from the device:And even reconstruct HTTP conversations on the fly: There are many other tools that can help you read packet trace data from this remote virtual interface. A full list can be found in Apple Technical Q&A.Back to topGo Beyond Packet Capture on iOSAnd that's how you can conduct an iOS packet trace. Now that you're an expert in iPhone packet sniffing, learn some other tips, tricks, and hacks for mobile apps with Perfecto's Remote Device Access.Or, try debugging yourself with Perfecto. Perfecto can also help you:Automate more tests.Apply real user conditions to your tests.Accelerate your testing.To streamline your overall testing experience, try a free 14-day trial of Perfecto today. StART TRIAL Related Content3 Steps to Debug and Test Your iOS App in the CloudHow To Use a HAR File to Find The Hidden Performance Bottlenecks in Your AppDebugging From Your IDE is Much Easier Now – It’s On the CloudBack to top
Roy Nuriel Director of Product Management, Perfecto Roy has over 15 years of experience in the quality assurance domain, specializing in enterprise software. Over the course of his career, Roy's roles have spanned engineering, product delivery and product management. He is an expert in software quality, application lifecycle management (ALM) and end-to-end IT management. Prior to joining Perfecto, Roy held a number of senior positions at HP Software and Mercury. He holds a B.Sc. in Computer Science from the Hebrew University in Israel.