Home > Backend Development > PHP Tutorial > TCPCOPY 1.0 installation and use_PHP tutorial

TCPCOPY 1.0 installation and use_PHP tutorial

WBOY
Release: 2016-07-12 09:03:19
Original
1001 people have browsed it

TCPCOPY 1.0 Installation and use

TCPCOPY 1.0 Installation and use


Introduction
TCPCOPY is a real-time copying tool for tcp traffic. Its 1.0 version was developed by NetEase engineer @ Developed and maintained by tcpcopy. It is generally used to copy online traffic from the production environment to the test environment in real time for testing. For example, before a new system goes online, if we want to conduct some basic stress tests, we can directly use tcpcopy to copy the online traffic and test the system. The advantage of this is that the test data is close to the real level, and the implementation is relatively simple.


1. Architecture



2. Installation
The information of the 3 servers used in the test is as follows:
Online server online server Intranet IP address 192.168.0.8/24 External IP address 214.167.0.8/28
Test server test server Intranet IP address 192.168.0.230/24 External IP address 214.167.0.13/28
Assistant server The internal IP address is 192.168.0.219/24 and the external IP address is 214.167.1.76/24
192.168.0.8 is the online server, and 192.168.0.230 and 192.168.0.219 are the test environment. We run tcpcopy on 192.168.0.8 to copy the online traffic to 192.168.0.230. On 192.168.0.230, we redirect the response to
192.168.0.219 through routing, and discard the response on 192.168.0.219.




The first step is to install and run the tcpcopy daemon on the online server 192.168.0.8:
We download the source code package of version 1.0 from github;
wget https://github.com/session-replay-tools/tcpcopy/archive/1.0.0.tar.gz -O tcpcopy-1.0.0.tar.gz
Install dependency packages;
yum -y install libpcap-devel
Decompress, compile and install;
tar zxvf tcpcopy-1.0.0.tar.gz
cd tcpcopy-1.0.0
./configure (default raw socket mode to capture packets)
make
make install
Finally run tcpcopy;
/usr/local/tcpcopy/sbin/tcpcopy -x 80-192.168.0.230:80 -s 192.168.0.219 -c 10.10.10.x -d -C 4 -l tcpcopy.log -P /var/run/tcpcopy.pid


Command description:
-x 80-192.168.0.230:80 will transfer the traffic of port 80 on this machine Copy to port 80 of 192.168.0.230 (test server)
-s specifies the server 192.168.0.219 where the intercept process is located. (Packet loss server)
-c Modify the requested host address to 10.10.10.x in order to set routing on the 230 test server (the routing is set up to redirect the response to the 219 packet loss server)
-C Open 4 Process
-d Run as daemon
-l Record log
-P Record pid
Other parameters can be viewed through /usr/local/tcpcopy/sbin/tcpcopy -h


The network connection status that can be observed after successful operation:
#ss -an|grep 192.168.0.219
ESTAB 0 0 192.168.0.8:49034 192.168.0.219:36524
ESTAB 0 0 192.168.0.8:49035 192.168.0.219:36524
ESTAB 0 0 192.168.0.8:49032 192.168.0.219:36524
ESTAB 0 0 192.168.0.8:49033 192. 168.0.219:36524




The second step is to install and run intercept daemon on auxiliary server 192.168.0.219:
Download the source code package of version 1.0 from github;
wget https://github.com/session -replay-tools/intercept/archive/1.0.0.tar.gz -O intercept-1.0.0.tar.gz
Install dependent packages;
yum -y install libpcap-devel (CentOS6 system installs directly with yum (i.e. version 1.4)
Note that the CentOS5 system libpcap-devel version is libpcap-devel-0.9.4-15.el5, intercept-1.0 requires libcap-devel1.4 or above. At this time, the source package installation is required
yum remove libpcap
wget http://www.tcpdump.org/release/libpcap-1.4.0.tar.gz
tar zxvf libpcap-1.4.0.tar.gz
cd libpcap-1.4.0
./configure
make
make install




Decompress, compile and install;
tar zxvf intercept-1.0.0.tar.gz
cd intercept-1.0.0
./configure (default raw socket mode to capture packets)
make && make install
Finally run intercept;
/usr/local/intercept/sbin/intercept -i eth1 -l intercept.log -P /var/run/intercept.pid -F 'tcp and src port 80' -d


Command description:
-i monitor network card interface
-l Record log
-F Monitored protocol and port
-P Record pid
-d Run as daemon
Other parameters can be viewed through /usr/local/intercept/sbin/intercept -h




The network connection status that can be observed after successful operation:
# ss -an |grep 36524
LISTEN 0 5 *:36524 *:*
ESTAB 0 66 192.168.0.219:36524 192.168.0.8:49034
ESTAB 0 0 192.168.0.219:36524 192.168.0.8:49035
ESTAB 0 66 192.168. 0.219:36524 192.168.0.8:49032
ESTAB 0 0 192.168.0.219:36524 192.168.0.8:49033


The third step is to set a route on test server 192.168.0.230:
[root@bogon ~]# route add - net 10.10.10.0 netmask 255.255.255.0 gw 192.168.0.219
The network connection status that can be observed when running the test successfully:
# ss -an |head
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 0 127.0.0.1:199 *:*
LISTEN 512 0 *:80 *:*
ESTAB 0 0 192.168.0.230:80 10.10.10.1:62602
ESTAB 0 0 192.168.0.230:80 10.10.10.4:54595
ESTAB 0 0 192.168.0.230:80 10.10.10.3:53566
ESTAB 0 0 192.168.0.230:80 10.10.10.6:49260
ESTAB 0 0 1 92.168.0.230:80 10.10. 10.8:57598
ESTAB 0 0 192.168.0.230:80 10.10.10.7:64454
ESTAB 0 0 192.168.0.230:80 10.10.10.1:63081








Reference link:
http://blog.csdn.net/wangbin579/article/details/8949315
http://blog.csdn.net/wangbin579/ article/details/8950282






www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1081461.htmlTechArticleTCPCOPY 1.0 Installation and use of TCPCOPY 1.0 Introduction to installation and use TCPCOPY is a real-time copying tool for tcp traffic. Its 1.0 version is developed by NetEase Developed and maintained by engineers @tcpcopy. Generally used to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template