Table of Contents
TCPCOPY 1.0 安装使用
Home php教程 php手册 TCPCOPY 1.0 安装使用

TCPCOPY 1.0 安装使用

Jun 13, 2016 am 08:49 AM
android

TCPCOPY 1.0 安装使用

TCPCOPY 1.0 安装使用


简介
TCPCOPY 是一个 tcp 流量的实时复制工具,其1.0版本由网易工程师 @tcpcopy 开发和维护。一般用来将生产环境的线上流量实时复制到测试环境进行测试。例如新系统上线前,如果我们希望进行一些基本的压力测试,那么我们可以直接利用 tcpcopy 来复制线上的流量过来对系统进行测试,这样的好处是测试数据接近真实水平,且实施起来相对简单。


一,架构



二,安装
测试中用到的3台服务器信息如下:
线上服务器 online server 内网IP地址 192.168.0.8/24 外网IP 214.167.0.8/28
测试服务器 test server 内网IP地址 192.168.0.230/24 外网IP 214.167.0.13/28
辅助服务器 assistant server 内网IP地址 192.168.0.219/24 外网IP 214.167.1.76/24
192.168.0.8是线上服务器,192.168.0.230和192.168.0.219是测试环境。我们在192.168.0.8上运行tcpcopy把线上流量拷贝到192.168.0.230,在192.168.0.230上我们通过路由将应答转向
192.168.0.219,在192.168.0.219上把应答丢弃。




第一步,在 online server 192.168.0.8上安装并运行 tcpcopy daemon :
我们从github上下载1.0版本的源码包;
wget https://github.com/session-replay-tools/tcpcopy/archive/1.0.0.tar.gz -O tcpcopy-1.0.0.tar.gz
安装依赖包;
yum -y install libpcap-devel
解压编译和安装;
tar zxvf tcpcopy-1.0.0.tar.gz
cd tcpcopy-1.0.0
./configure (默认raw socket方式抓包)
make
make install
最后运行 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


指令说明:
-x 80-192.168.0.230:80将本机上80端口的流量复制到192.168.0.230(测试服务器)的80端口
-s指定intercept进程所在的服务器192.168.0.219。(丢包服务器)
-c修改请求的host地址为10.10.10.x,以便在230测试服务器上设置路由(设置路由是为了将应答转向丢219包服务器)
-C 开启4个进程
-d 以daemon形式运行
-l 记录日志
-P 记录pid
其他参数可以通过/usr/local/tcpcopy/sbin/tcpcopy -h查看


成功运行后可以观察到的网路连接状态:
#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




第二步,在 auxiliary server 192.168.0.219上安装并运行 intercept daemon :
从github上下载1.0版本的源码包;
wget https://github.com/session-replay-tools/intercept/archive/1.0.0.tar.gz -O intercept-1.0.0.tar.gz
安装依赖包;
yum -y install libpcap-devel(CentOS6系统直接yum安装即可1.4版本)
注意CentOS5系统libpcap-devel版本是libpcap-devel-0.9.4-15.el5,intercept-1.0需要libcap-devel1.4以上版本此时需要源码包安装
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




解压编译和安装;
tar zxvf intercept-1.0.0.tar.gz
cd intercept-1.0.0
./configure (默认raw socket方式抓包)
make && make install
最后运行 intercept;
/usr/local/intercept/sbin/intercept -i eth1 -l intercept.log -P /var/run/intercept.pid -F 'tcp and src port 80' -d


指令说明:
-i 监控网卡接口
-l 记录日志
-F 监控的协议和端口
-P 记录pid
-d 以daemon形式运行
其他参数可以通过/usr/local/intercept/sbin/intercept -h查看




成功运行后可以观察到的网路连接状态:
# 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


第三步,在 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
成功运行测试时可以观察到的网络连接状态:
# 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 192.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








参考链接:
http://blog.csdn.net/wangbin579/article/details/8949315
http://blog.csdn.net/wangbin579/article/details/8950282






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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:23 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Samsung Galaxy S25 Ultra leaks in first render images with rumoured design changes revealed Sep 11, 2024 am 06:37 AM

OnLeaks has now partnered with Android Headlines to provide a first look at the Galaxy S25 Ultra, a few days after a failed attempt to generate upwards of $4,000 from his X (formerly Twitter) followers. For context, the render images embedded below h

IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size IFA 2024 | TCL\'s NXTPAPER 14 won\'t match the Galaxy Tab S10 Ultra in performance, but it nearly matches it in size Sep 07, 2024 am 06:35 AM

Alongside announcing two new smartphones, TCL has also announced a new Android tablet called the NXTPAPER 14, and its massive screen size is one of its selling points. The NXTPAPER 14 features version 3.0 of TCL's signature brand of matte LCD panels

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades New report delivers damning assessment of rumoured Samsung Galaxy S25, Galaxy S25 Plus and Galaxy S25 Ultra camera upgrades Sep 12, 2024 pm 12:22 PM

In recent days, Ice Universe has been steadily revealing details about the Galaxy S25 Ultra, which is widely believed to be Samsung's next flagship smartphone. Among other things, the leaker claimed that Samsung only plans to bring one camera upgrade

Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Samsung Galaxy S24 FE billed to launch for less than expected in four colours and two memory options Sep 12, 2024 pm 09:21 PM

Samsung has not offered any hints yet about when it will update its Fan Edition (FE) smartphone series. As it stands, the Galaxy S23 FE remains the company's most recent edition, having been presented at the start of October 2023. However, plenty of

Motorola Razr 50s shows itself as possible new budget foldable in early leak Motorola Razr 50s shows itself as possible new budget foldable in early leak Sep 07, 2024 am 09:35 AM

Motorola has released countless devices this year, although only two of them are foldables. For context, while most of the world has received the pair as the Razr 50 and Razr 50 Ultra, Motorola offers them in North America as the Razr 2024 and Razr 2

Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Xiaomi Redmi Note 14 Pro Plus arrives as first Qualcomm Snapdragon 7s Gen 3 smartphone with Light Hunter 800 camera Sep 27, 2024 am 06:23 AM

The Redmi Note 14 Pro Plus is now official as a direct successor to last year'sRedmi Note 13 Pro Plus(curr. $375 on Amazon). As expected, the Redmi Note 14 Pro Plus heads up the Redmi Note 14 series alongside theRedmi Note 14and Redmi Note 14 Pro. Li

See all articles