This article provides information on using the pktcap-uw tool for packet capture and analysis.
VMware vSphere ESXi
As a starting point, refer to ESXi Network Troubleshooting Tools, specifically to the section titled "Pktcap-uw".
Under that title, look for the following graphic:
Packet captures are done by entering commands at the command line of a session via SSH (or Server Console access via KVM -- “Keyboard, Video (monitor), Mouse.”) with root access privileges.
There are a variety of points at which a traffic can be captured, depending on the type of switch in use. For example, standard vSwitch or a Distributed Virtual Switch (DVS).
Capture output can be directed to the user's screen and displayed (by parsing the output with the tcpdump-uw tool), or it can be directed to a datastore which can then be downloaded and analyzed with a tool such as Wireshark.
Plan on directing the output to a datastore, NEVER use the /tmp directory as a place to put the data.
cd /vmfs/volumes/FULL_PATH_TO_DATASTORE cd "/vmfs/volumes/FULL_PATH_TO_DATASTORE"cd "/vmfs/volumes/FULL_PATH_TO_DATASTORE"mkdir Case_12345678In vSwitch, i.e. switchport and uplink.
Switchports connect to all the vNIC, vmk adapters and uplinks (which are the actual physical NIC (vmnic)).
First identify the capture point based on the issue and apply the command syntax accordingly.
In the below diagram note the architecture and how VMs, kernel and physical adapters are connected.
net-stats -l" and this will list the switchports (listed under the PortNum column) that are mapped to vm/vmk.esxtop" and press "n". This will show the mapping between switchport (listed under the PORT-ID column) and uplink (under the column TEAM-PNIC).vsish" and press enter. "cat /net/portsets/vSwitch_name/ports/switchport_number/teamUplink". Note: For vSwitch name and switchport number, refer to "net-stats -l" output above.
netdbg vswitch instance list" and press enter.As an example, trace a particular vSwitch port and its associated uplink at the same time:
net-stats -lIdentify and make a note of these parameters:
Port ID returned by the esxtop command — --switchport <switchport-id>
vmnic# physical port to trace — --uplink vmnic2 -
Location of the output pcap file — /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/
pktcap-uw --switchport ######## -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_#/esxi01.switchport.########.pcapng & pktcap-uw --uplink vmnic# -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.uplink.vmnic#.pcapng &
Note: The command shell we assume here is the Bash shell. Therefore, if there is more than one uplink on the vSwitch, just add the command after the ending & and add a & at the end. kill $(lsof |grep pktcap-uw |awk '{print $1}'| sort -u)lsof |grep pktcap-uw |awk '{print $1}'| sort -uPer the diagram, there are different capture points.
pktcap-uw --uplink vmnic# --capture UplinkSndKernel,UplinkRcvKernel -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_#/esxi.uplink.vmnic#.UplinkSndRcvKernel.pcapng &
Example for directing the output to the screen, traffic gathered with this command is also capturing both sent and received traffic:pktcap-uw --uplink vmnic# --capture UplinkSndKernel,UplinkRcvKernel -o - | tcpdump-uw -r - -ennkill $(lsof |grep pktcap-uw |awk '{print $1}'| sort -u)pktcap-uw --switchport ######## --capture VnicTx,VnicRx -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.switchport.########.VnicTxRx.pcapng &
pktcap-uw --switchport ######## --capture VnicTx,VnicRx -o - | tcpdump-uw -r - -ennPlease note the packet capture data is not stored in ESXi logs and that it is not recommended to run multiple instances of packet captures for long periods of time unless directed to do so by VMware by Broadcom support.
If additional assistance is needed with troubleshooting, we recommend reaching out to Broadcom support by creating a support case using the instructions at Creating and managing Broadcom support cases.
pktcap-uw --switchport ######## --capture VnicTx,VnicRx -s 256 -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.switchport.########.VnicTxRx.pcapng &pktcap-uw --switchport ######## --capture VnicTx,VnicRx -s 256 --ip ###.###.###.### -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.switchport.########.VnicTxRx.pcapng &
In the above example, substitute the problem IP address that being investigated, in place of ###.###.###.###. For example, enter the default gateway IP address configured for the virtual machine. pktcap-uw --switchport ######## --capture VnicTx,VnicRx -s 256 --rcf "geneve and host ###.###.###.###" -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.switchport.########.VnicTxRx.pcapng &
WHERE: substitute the problem IP address that being investigated, in place of ###.###.###.###.
Additional filters can be used, such as ICMP for ping requests and replies, however it is only recommended to use filters in specific instances to avoid over filtering. Please note the --proto 0x01 is only used as an example in the command below:
pktcap-uw --switchport ######## --capture VnicTx,VnicRx -s 256 --ip ###.###.###.### --proto 0x01 -o /vmfs/volumes/FULL_PATH_TO_DATASTORE/Case_12345678/esxi.switchport.########.VnicTxRx.pcapng &
RELATED LINKS :
To provide advice and best practices when using the pktcap-uw tool when the ESXi hosts are heavily loaded, see Considerations to run pktcap-uw under heavy network load.