To help you better troubleshoot slow accesses to Memecache, we offers ocs-sniffer to analyze and locate the problem. The tool is easier to get started and for viewing the results than Tcpdump.
Ocs-sniffer tool can be used to capture packets online for analysis (or to analyze the packets captured by Tcpdump offline). It currently supports Memcached protocol and HTTP protocol.
Ocs_sniffer tool requires the sudo permission to be executed.
Usage: ./ocs_sniffer -f conf_file [-i device] [-r pcap file] [-d debug_level] [-vh]
-i: interface to sniff
-f: configure file
-d: debug level; default is 8
-h: show help message
-r: read packets from tcpdump offline file
-v: verbose mode, show all debug messages and verbose log
A configuration file is required for using the tool (see the ocs_sniffer.conf.default in the appendix for the template).
In the configuration file:
ipnet: to configure the IP address of the server for capturing packets (because sometimes the analysis is performed offline on another server, an IP address is required here)
sniff_port: to configure the port for packet capturing, such as 11211 for Memcached
iface: NIC name
pktlog: the storage log of the captured packages. It can be stored to a file (file:log_path. Attention: automatic recursion is not supported for directory creation) or output to the terminal (console:)
errlog: the log of errors
log_buffer_size: the size of log cache (Unit: KB). Only when the cache is full or when the application is exited will the log be output. If it is set to 0, the cache will be closed.
Analyze the packet capturing results.
Results in the normal mode
[MEMCACHED] [Session Initiation Time] [Opposite IP Address.Opposite Port] [Packet Capturing IP Address.Packet Capturing Port] [Request] [Response] [Request Key] [Request Value] [Request Cas] [Response Key] [Response Value] [Response Cas] [RT] [Server Processing Time] [Round Trip Time]
If the field doesn’t exist in the packet, it will not be output;
The invisible characters in key and value will be replaced by period (.);
The unit of RT, Server Processing Time and Round Trip Time is ms.