Packet Capture
This section describes the configuration model of packet capture and provides examples of XML packets.
Data Model
The configuration model file matching packet capture is huawei-capture.yang.
Object |
Description |
Value |
Remarks |
---|---|---|---|
/huawei-capture:capture-pkt/cpu |
Captures packets sent to the CPU. |
This object does not need any data configuration. |
cpu and ifNameType cannot be configured simultaneously. |
/huawei-capture:capture-pkt/ifNameType |
Captures packets on a specified interface. |
The value is a string in the format of interface-typeinterface-number.
The interface must exist on the switch. |
|
/huawei-capture:capture-pkt/vlan-id |
Captures packets from the specified outer VLAN. |
The value is an integer that ranges from 1 to 4094. The VLAN must exist on the switch. |
N/A |
/huawei-capture:capture-pkt/cvlan-id |
Captures packets from the specified inner VLAN. |
The value is an integer that ranges from 1 to 4094. The VLAN must exist on the switch. |
N/A |
/huawei-capture:capture-pkt/acl-id |
Captures packets matching the specified ACL. |
The value is an integer in the range from 2000 to 5999. The ACL must exist on the switch. |
N/A |
/huawei-capture:capture-pkt/car-cir |
Indicates the rate of capturing packets. |
The value is an integer that ranges from 8 to 256, in kbit/s. The default value is 64. |
N/A |
/huawei-capture:capture-pkt/packetnumber |
Indicates the number of packets to be captured. The system stops capturing packets after the specified number of packets are captured. |
The value is an integer that ranges from 1 to 1000. The default value is 100. |
N/A |
/huawei-capture:capture-pkt/packetlenth |
Indicates the length of a single captured packet, which means the first several bytes of the captured packet. |
The value is an integer that ranges from 20 to 64, in bytes. The default value is 64. |
N/A |
/huawei-capture:capture-pkt/timeout |
Indicates the timeout interval of packet capture. The system stops capturing packets after the specified timeout interval. |
The value is an integer that ranges from 1 to 300, in seconds. The default value is 60. |
N/A |
/huawei-capture:capture-pkt/filename |
Saves captured packets to the specified file. |
The file name is a string in *.cap format. The default value is capture.cap. | N/A |
Item | Description |
---|---|
esn | Indicates the device ESN. |
filename | Indicates the name of the file that stores the captured packets. |
type | Indicates the type of the file that stores the captured packets. |
status | Indicates the result of packet capture. |
errorcode | Indicates the error code. |
Capturing Packets Sent to the CPU
This section describes how to capture packets sent to the CPU using the rpc method.
Operation |
XPATH |
---|---|
rpc |
|
Data Requirements
Item |
Data |
Description |
---|---|---|
Capturing packets sent to the CPU |
- |
- |
Capturing packets from the specified outer VLAN |
10 |
Capture packets from VLAN 10. |
Capturing packets matching the specified ACL |
2003 |
Capture packets matching the ACL 2003. |
Number of packets to be captured |
120 |
Capture 120 packets. |
Length of a single captured packet |
55 |
Set the length of a single captured packet to 55 bytes. |
Timeout interval of packet capture |
10 |
Set the timeout interval of packet capture to 10 seconds. |
Name of the file to which packets are saved |
captureTest1.cap |
Save the captured packets to the captureTest1.cap file. |
Request Example
The specified VLAN and ACL must already exist, and the ACL must have the rules configured. For details about how to configure VLAN and ACL, see VLAN Management and ACL Rule Management separately.
Name of the file to which packets are saved cannot already exist.
<?xml version='1.0' encoding='UTF-8'?> <rpc message-id="14" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <huawei-capture:capture-pkt xmlns:huawei-capture="urn:huawei:params:xml:ns:yang:huawei-capture"> <huawei-capture:cpu></huawei-capture:cpu> <huawei-capture:vlan-id>10</huawei-capture:vlan-id> <huawei-capture:acl-id>2003</huawei-capture:acl-id> <huawei-capture:packetnumber>120</huawei-capture:packetnumber> <huawei-capture:packetlenth>55</huawei-capture:packetlenth> <huawei-capture:timeout>10</huawei-capture:timeout> <huawei-capture:filename>captureTest1.cap</huawei-capture:filename> </huawei-capture:capture-pkt> </rpc>
Response Example
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="14"> <ok/> </rpc-reply>
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="14"> <rpc-error xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-app-tag>1</error-app-tag> <error-message>Error: The saved file already exists. Error: Failed to configure packet getting. </error-message> </rpc-error> </rpc-reply>
Capturing Packets on a Specified Interface
This section describes how to capture packets on a specified interface using the rpc method.
Operation |
XPATH |
---|---|
rpc |
|
Data Requirements
Item |
Data |
Description |
---|---|---|
Capturing packets on a specified interface |
GigabitEthernet1/0/1 |
Capture packets on the interface GigabitEthernet1/0/1. |
Capturing packets from the specified outer VLAN |
10 |
Capture packets from VLAN 10. |
Capturing packets matching the specified ACL |
2003 |
Capture packets matching the ACL 2003. |
Number of packets to be captured |
120 |
Capture 120 packets. |
Length of a single captured packet |
55 |
Set the length of a single captured packet to 55 bytes. |
Timeout interval of packet capture |
10 |
Set the timeout interval of packet capture to 10 seconds. |
Name of the file to which packets are saved |
captureTest1.cap |
Save the captured packets to the captureTest1.cap file. |
Request Example
The specified VLAN and ACL must already exist, and the ACL must have the rules configured. For details about how to configure VLAN and ACL, see VLAN Management and ACL Rule Management separately.
Name of the file to which packets are saved cannot already exist.
<?xml version='1.0' encoding='UTF-8'?>
<rpc message-id="14" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<huawei-capture:capture-pkt xmlns:huawei-capture="urn:huawei:params:xml:ns:yang:huawei-capture">
<huawei-capture:ifNameType>GigabitEthernet1/0/1</huawei-capture:ifNameType>
<huawei-capture:vlan-id>10</huawei-capture:vlan-id>
<huawei-capture:acl-id>2003</huawei-capture:acl-id>
<huawei-capture:packetnumber>120</huawei-capture:packetnumber>
<huawei-capture:packetlenth>55</huawei-capture:packetlenth>
<huawei-capture:timeout>10</huawei-capture:timeout>
<huawei-capture:filename>captureTest1.cap</huawei-capture:filename>
</huawei-capture:capture-pkt>
</rpc>
Response Example
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="14"> <ok/> </rpc-reply>
<?xml version='1.0' encoding='UTF-8'?> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="14"> <rpc-error xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <error-type>application</error-type> <error-tag>operation-failed</error-tag> <error-severity>error</error-severity> <error-app-tag>1</error-app-tag> <error-message>Error: The saved file already exists. Error: Failed to configure packet getting. </error-message> </rpc-error> </rpc-reply>