In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "how to analyze network performance in Linux". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to analyze network performance in Linux".
Broadly speaking, the performance analysis of the network direction includes not only the network configuration inspection and monitoring of the host test, but also the analysis of packet forwarding delay, throughput, bandwidth and other indicators on the network link. Includes, but is not limited to, the following analytical tools:
Ping: testing network connectivity
Ifconfig: interface configuration
Ip: network interface statistics
Netsat: multiple network stack and interface statistics
Ifstat: interface network traffic monitoring tool
Netcat: quickly build a network connection
Tcpdump: bag grabbing tool
Sar: statistics History
Traceroute: testing network routin
Pathchar: determine the characteristics of the network path
Dtrace:TCP/IP stack trace
Iperf / netperf / netserver: a network performance testing tool
Perf performance analysis artifact
In this article, let's take a look at the first seven.
Ping
By sending ICMP echo packets to detect network connectivity, ping can not only visually see the connectivity of the network, but also obtain the round-trip time (RTT time), packet loss, and the IP address of the accessed domain name (using DNS domain name resolution), such as:
Our ping baidu.com,-c parameter specifies the number of packets sent. As you can see, the IP address of a server that resolved to baidu is 220.181.112.244. The mean and arithmetic mean differences of RTT time are 40.732ms, 40.762ms, 40.791ms and 0.248, respectively.
Ifconfig
The ifconfig command is used to configure and display statistics for network interfaces in the Linux kernel. Through these statistics, we can also make some network performance tuning.
1) ifconfig displays network interface configuration information
Among them, RX/TX packets is the statistics of receiving / sending data packets, including the wrong packets, how many packets are lost, and so on. RX/TX bytes is a statistics on the number of bytes of data received / sent. You can focus on MTU and txqueuelen (send queue length) when tuning performance. For example, you can fine-tune these two parameters with the following command:
Ifconfig eth0 txqueuelen 2000 ifconfig eth0 mtu 1500
2) Network interface address configuration
Ifconfig is also commonly used to configure the address of a network port, such as:
Configure and delete IPv6 addresses for the network card:
Ifconfig eth0 add 33ffe:3240:800:1005::2/64 # configure IPv6 address for Nic eth0 ifconfig eth0 del 33ffe:3240:800:1005::2/64 # Delete IPv6 address for Nic eth0
Modify the MAC address:
Ifconfig eth0 hw ether 00:AA:BB:CC:dd:EE
Configure the IP address:
Ifconfig eth0 192.168.2.10 ifconfig eth0 192.168.2.10 netmask 255.255.255.0 ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255
IP
The ip command is used to display or set the network interface, routing, network equipment, policy routing and tunnel information of the Linux host. It is a powerful network configuration tool under Linux. It aims to replace the ifconfig command. The following shows the power of the IP command, covering ifconfig, netstat, and route commands.
Netstat
Netstat can view the network situation of the entire Linux system. It is a combination of multi-clock network tools.
Common options include the following:
Default: lists connected sockets
-a: list information for all sockets
-s: statistics of various network protocol stacks
-I: network interface information
-r: list the routing table
-l: only the service status in Listen is listed.
-p: displays PID and process name
Examples of the combination of parameters are as follows:
Netstat-at lists all TCP ports
Netstat-au lists all UDP ports
Netstat-lt lists all socket listening to TCP ports
Netstat-lu lists all socket listening to UDP ports
Netstat-lx lists all socket listening to UNIX ports
Netstat-ap | grep ssh finds the port on which the program is running
Netstat-an | grep': 80' find the process running on the specified port
1) netstat displays connected socket data by default
Overall, the output consists of two parts:
Active Internet connections: active TCP connection, where Recv-Q and Send-Q refer to the receiving queue and sending queue. These numbers are usually 0. If not, the request packets and reply packets are piling up in the queue.
Active UNIX domain sockets: active UNIX domain socket, where proto displays the protocol used for the connection, RefCnt indicates the process number connected to this socket, Types is the type of socket, State is the current status of the socket, and Path is the path name used by the process connected to the socket.
2) netstat-I displays network interface information
The interface information includes the network interface name (Iface), MTU, and a series of metrics for reception (RX-) and transmission (TX-). Where OK refers to the packet successfully transmitted, ERR is the error packet, DRP is the packet loss, and OVR is the out-of-limit packet.
These parameters help us to analyze the packet receiving situation of the network, so as to determine the bottleneck.
3) netstat-s displays the information of all network protocol stacks
As you can see, this command displays detailed information about each protocol, which helps us to do a more fine-grained analysis of the protocol stack.
4) netstat-r displays routing table information
This command can see a situation in the host routing table. Of course, we can also use the ip route and route commands to check routing, which displays more detailed information.
Ifstat
Ifstat is mainly used to monitor the network traffic of host network ports. Common options include:
-a: monitor all network ports of the host
-I: specify the network port to monitor
-t: add a timestamp before each line of output
-b: displays traffic data in Kbit/s instead of the default KB/s
-delay: sampling interval (in s), that is, statistics are output at intervals of delay
-count: the number of samples, that is, the total output of count statistics
For example, use the following command to count the traffic data of all network ports of the host within a certain period of time:
It can be seen that the statistics of the traffic data of the three network ports and the time stamp of the previous output are helpful for us to count the total input and output traffic of each network port over a period of time.
Netcat
Netcat, abbreviated as nc, is very useful in troubleshooting network because of its simple command but powerful function.
It is mainly used to build network connections. Can be run as a client and server, when running as a server, it is responsible for listening to a port and accepting client connections, so it can be used to debug client programs; when running in client mode, it is responsible for initiating connections to the server and sending and receiving data, so it can also be used to debug server programs, which is a bit like Telnet programs.
Common options include the following:
-l: runs as a server and listens to the specified port. The default is to run as a client.
-k: repeatedly accept and process all connections on a port and must be used with-l.
-n: use an IP address for the host, not the host name, and a number for the port number, not the service name.
-p: when running as a client, specify the port number.
-s: sets the IP address of packets sent by the local host.
-C: use the characters CR and LF as the Terminator.
-U: use UNIX local domain sockets to communicate.
-u: uses UDP protocol to communicate, and TCP protocol is used by default.
-w: if the nc client does not detect any input within the specified time, it exits.
-X: this option specifies the communication protocol between nc clients and proxy servers when they communicate. Currently supported proxy protocols include "4" (SOCKS v.4), "5" (SOCKS v.5) and "connect" (HTTPs Proxy). SOCKS v.5 is used by default.
-x: specify the IP address and port number of the destination proxy server.
To give a simple example, use the nc command to send a message:
First, start the server and use nc-l 0.0.0.0 12345 to listen for all connections on port 12345.
Then, start the client and use nc-p 1234 127.0.0.1 12345 to connect to the server 127.0.0.1 Freund 12345 using port 1234.
Then you can send data to each other at both ends. Here is just throwing a brick to attract jade, we can practice more examples.
Tcpdump
Tcpdump is a powerful tool for grabbing packets on the Internet. Although there are easier to use graphical packet grabbing tools such as wireshark, tcpdump is still a necessary tool for network troubleshooting.
There are many options for tcpdump, so I won't list them one by one. You can read the quotation at the end of the article to learn more. Here are several common uses of tcpdump.
1) capture the packet of a host
For example, to capture all packets received and sent on host 200.200.200.100, use:
Tcpdump host 200.200.200.100
2) capture packets from multiple hosts
For example, to capture communication between host 200.200.200.1 and host 200.200.200.2 or 200.200.200.3, use:
Tcpdump host 200.200.200.1 and (200.200.200.2 or)
Also capture the IP packets of host 200.200.200.1 for communication with all hosts except host 200.200.200.2. Use:
Tcpdump ip host 200.200.200.1 and! 200.200.200.2
3) capture packets of a certain protocol type received or sent by a host
For example, to capture Telnet packets received or sent by the host 200.200.200.1, use:
Tcpdump tcp port 23 host 200.200.200.1
4) capture packets related to a port
For example, to capture packets passing on port 6666, use:
Tcpdump port 6666
5) capture the packet of a network port
For example, to capture packets passed on the network port eth0, use:
Tcpdump-I eth0 above is all the content of this article "how to analyze Network performance in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.