📄 ramp
字号:
#! /bin/sh#!/usr/bin/tclsh## Copyright (C) 2002 by USC/ISI# All rights reserved.## Redistribution and use in source and binary forms are permitted# provided that the above copyright notice and this paragraph are# duplicated in all such forms and that any documentation, advertising# materials, and other materials related to such distribution and use# acknowledge that the software was developed by the University of# Southern California, Information Sciences Institute. The name of the# University may not be used to endorse or promote products derived from# this software without specific prior written permission.## THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.## RAMP is a set of scripts that take tcpdump trace as input and# output a set of CDF files that model Web traffic, FTP traffic# and the underlying topology information including RTT and# bottleneck bandwidth. It also outputs a time series of # traffic size (in 1ms block) for further wavelet scaling analysis# for detailed explanation of RAMP, please see # http://www.isi.edu/~kclan/paper/ramp.pdf ## usage:# ./RAMP [-c] <tcpdump) trace> <threshold> <network prefix>## [-f] : generate multiple traffic models# based on filter specified in model.conf# [-c] : convert trace file from CoralReef to# tcpdump format# <tcpdump trace> : tcpdump trace file generated using# tcpdump -w option# <threshold> : the threshold time value (in millisecond)# that distinguishes idle periods in order # to infer user "think" times between # requests for new top-level pages.# <network prefix>: network prefix used to distinguish# inbound vs. outbound traffic## example: ./RAMP tracefile 1000 128.9.0.0/255.255.0.0## Currently it's only tested on Linux system## Here is the version of tcpdump we used for testing# tcpdump version 3.6.3# libpcap version 0.6## We assume the output of tcpdump with the following format for# TCP packets## timestamp src > dst: flags data鈥恠eqno ack window urgent options## Note that some version of tcpdump might output with an extra "<"# i.e.# timestamp < src > dst: flags data鈥恠eqno ack window urgent options# # which is not compatible with our codes# One simple workaround is to use the provided remove.pl script# to remove the extra "<" in the tcpdump output## This work is supported by DARPA through SAMAN Project# (http://www.isi.edu/saman/), administered by the Space and Naval# Warfare System Center San Diego under Contract No. N66001-00-C-8066###echo -ecrl=noif test $1 = -cthen if [ -x ./crl_to_pcap ] ; then mv $2 $2.crl ./crl_to_pcap -o $2 $2.crl f=$2 t=$3 p=$4 else echo "CoralReef to Tcpdump converter does not exist!!" exit 0 fielif test $1 = -fthen if [ -e ./model.conf ] ; then f=$2 t=$3 p=$4 filter=yes else echo "model.conf does not exist!!" exit 0 fielse f=$1 t=$2 p=$3fiTCPDUMP=/usr/sbin/tcpdump#preprocessing the trace filedateecho "*** parsing $tcpdump file ***"echo "*** parsing .all ***"$TCPDUMP -nn -tt -q -r $f > $f.all$TCPDUMP -nn -tt tcp -r $f > $f.tcpdateecho "*** parsing .www ***"$TCPDUMP -nn -tt -r $f tcp port 80 > $f.www#extrace FTP data connections from the tracedateecho "*** parsing .ftp ***"$TCPDUMP -nn -tt -r $f port ftp > $f.ftp1cat $f.ftp1 | getftpnode.pl#find the IP address of FTP clientscat $f.ftp1 | getFTPclient.pl > $f.ftp2cat $f.tcp | getFTP.pl -r $f.ftp2 > $f.ftp#extract tcp flows from Web serverdateecho "*** parsing .http-srv ***"$TCPDUMP -nn -tt -r $f tcp src port 80 > $f.http-srv#date#echo "*** analyze traffic mix ***"#cat $f.all | io.pl -s $p -w $f.all#cat $f.all.inbound | traffic-classify > $f.traffic.cnt.inbound#cat $f.all.outbound | traffic-classify > $f.traffic.cnt.outbound#date#echo "*** analyze flow statistics ***"#awk -f flow.awk < $f.all.outbound > $f.all.outbound.flow#awk -f flow.awk < $f.all.inbound > $f.all.inbound.flow#sort -s -o $f.all.outbound.flow.sort -T /tmp $f.all.outbound.flow#sort -s -o $f.all.inbound.flow.sort -T /tmp $f.all.inbound.flow#cat $f.all.outbound.flow.sort | flow.pl -w $f.outbound.flow#cat $f.all.inbound.flow.sort | flow.pl -w $f.inbound.flow#sort -s -o $f.inbound.flow.start.sort $f.inbound.flow.start#sort -s -o $f.outbound.flow.start.sort $f.outbound.flow.start#awk -f arrive2inter.awk < $f.outbound.flow.start.sort > $f.outbound.flow.arrival#awk -f arrive2inter.awk < $f.inbound.flow.start.sort > $f.inbound.flow.arrival#dat2cdf -e 1024 -i 1024 -d 1024 -t $f.outbound.flow.size#dat2cdf -e 1024 -i 1024 -d 1024 -t $f.inbound.flow.size#dat2cdf -e 0 -i 1 -d 1 -t $f.outbound.flow.dur#dat2cdf -e 0 -i 1 -d 1 -t $f.inbound.flow.dur#dat2cdf -e 0 -i 0.001 -d 1 -t $f.outbound.flow.arrival#dat2cdf -e 0 -i 0.001 -d 1 -t $f.inbound.flow.arrival#seperate inbound and outbound flows in web trafficdateecho "WWW"cat $f.www | io.www.pl -s $p -w $f.wwwcat $f.http-srv | io.www.pl -s $p -w $f.http-srv#seperate inbound and outbound flows in FTP trafficdateecho "FTP"cat $f.ftp | io.pl -s $p -w $f.ftpif test "$filter" = yes; then cat model.conf | wmodel.pl -r $f.http-srv.inbound -t $t cat model.conf | fmodel.pl -r $f.ftp getftpserver.pl exit 0fi#################################################################please read output_format.pdf and trace_processing.pdf included in# this package for detailed explanation of the follwing commands/bin/rm -rf *.time-series/bin/rm -rf *connect.time*dateecho "*** Analyze Inbound traffic ***"#output the summary of http connectionsecho "run http_connect"sort -s -o $f.in.http-srv-sort +1 -2 +3 -4 +0 -1 -T /tmp $f.http-srv.inboundhttp_connect -r $f.in.http-srv-sort -w $f.in.http-srv.connectgrep "ACT" $f.in.http-srv.connect > $f.in.http-srv.connect.timesort $f.in.http-srv.connect.time > $f.in.http-srv.connect.time.sort#output the summary of http client request and server response dateecho "run http_active"sort -s -o $f.in.http-srv.connect.sort +1 -2 +0 -1 -T /tmp $f.in.http-srv.connecthttp_active -r $f.in.http-srv.connect.sort -w $f.in.http-srv.active -I $t#output statistical distribution of web traffic#in particular the distributions of the following parameters#(a) session inter-arrival#(b) number of pages per session#(c) page inter-arrival#(d) page size#(e) object inter-arrival#(f) object size#(g) request size#(h) ratio between persistent and non-persistent connection#(i) server popularity dateecho "compute CDF statistics"cat $f.in.http-srv.active.activity | outputCDF -e inbound#output the time series of web traffic usage in 1ms block #for later use of wavelet scaling analysisdateecho "compute time series (1ms block)"bw.tcl $f.http-srv.inboundcat $f.http-srv.inbound.bw | time-series.pl > $f.in.time-seriesdateecho "*** Analyze Outbound traffic ***"#output the summary of http connectionsecho "run http_connect"sort -s -o $f.out.http-srv-sort +1 -2 +3 -4 +0 -1 -T /tmp $f.http-srv.outboundhttp_connect -r $f.out.http-srv-sort -w $f.out.http-srv.connectgrep "ACT" $f.out.http-srv.connect > $f.out.http-srv.connect.timesort $f.out.http-srv.connect.time > $f.out.http-srv.connect.time.sort#output the summary of http client request and server response dateecho "run http_active"sort -s -o $f.out.http-srv.connect.sort +1 -2 +0 -1 -T /tmp $f.out.http-srv.connecthttp_active -r $f.out.http-srv.connect.sort -w $f.out.http-srv.active -I $tdateecho "compute CDF statistics of web traffic"cat $f.out.http-srv.active.activity | outputCDF -e outbound#output the time series of web traffic usage in 1ms block #for later use of wavelet scaling analysisdateecho "compute time series (1ms block)"bw.tcl $f.http-srv.outboundcat $f.http-srv.outbound.bw | time-series.pl > $f.out.time-series#################################################################echo "*** Delay and Bandwidth estimation ***"echo "Estimate delay and bottleneck bandwidth for WWW traffic"dateecho "pre-processing: output traffic between web servers and clients"cat $f.www | BW-seq.pl -s $p -p 80 sort inbound.seq -o inbound.seq.sortedsort outbound.seq -o outbound.seq.sorteddateecho "search for DATA/ACK packets which have the same seqence number for outbound traffic"cat outbound.seq.sorted | BW-pair.pl > $f.outbound.pairdateecho "estimate the bandwidth for inbound/outbound traffic"cat $f.outbound.pair | BW.out.pl -w $f.wwwcat inbound.seq.sorted | BW.in.pl -w $f.wwwdat2cdf -e 0 -i 0.001 -d 1 -t $f.www.outbound.BWdat2cdf -e 0 -i 0.001 -d 1 -t $f.www.inbound.BWdat2cdf -e 0 -i 0.001 -d 1 -t $f.www.outbound.delaydateecho "compute packet size distribution"sort -o inbound.pkt.size.sort inbound.pkt.sizesort -o outbound.pkt.size.sort outbound.pkt.sizeawk -f pkt.awk < inbound.pkt.size.sort > $f.www.inbound.pktsizeawk -f pkt.awk < outbound.pkt.size.sort > $f.www.outbound.pktsizedat2cdf -e 0 -i 1 -d 1 -t $f.www.inbound.pktsizedat2cdf -e 0 -i 1 -d 1 -t $f.www.outbound.pktsizedateecho "Locate SYN connection"cat $f.www | delay.pl -p 80 > $f.www.syncsort -s -o $f.www.sync.sorted -T /tmp $f.www.syncdateecho "compute delay for each SYN connection pair between servers and clients"pair.tcl $f.www.sync.sorted $p > $f.www.sync.delaysort -s -o $f.www.sync.delay.sorted -T /tmp $f.www.sync.delayawk -f delay.awk < $f.www.sync.delay.sorted > $f.www.inbound.delaydat2cdf -e 0 -i 0.001 -d 1 -t $f.www.inbound.delay##########################################################echo "Estimate delay and bottleneck bandwidth for FTP traffic"dateecho "pre-processing: output traffic between ftp servers and clients"cat $f.ftp | BW-seq-ftp.pl -r $f.ftp2 -s $psort inbound.seq -o inbound.seq.sortedsort outbound.seq -o outbound.seq.sorteddateecho "search for DATA/ACK packets which have the same seqence number for outbound traffic"cat outbound.seq.sorted | BW-pair.pl > $f.outbound.pairdateecho "estimate the bandwidth for inbound/outbound traffic"cat $f.outbound.pair | BW.out.pl -w $f.ftpcat inbound.seq.sorted | BW.in.pl -w $f.ftpdat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.outbound.BWdat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.inbound.BWdat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.outbound.delaydateecho "Locate SYN connection"cat $f.ftp | delay.pl -p 21 > $f.syncsort -s -o $f.sync.sorted -T /tmp $f.syncdateecho "compute delay for each SYN connection pair between servers and clients"pair.tcl $f.sync.sorted $p > $f.sync.delaysort -s -o $f.sync.delay.sorted -T /tmp $f.sync.delayawk -f delay.awk < $f.sync.delay.sorted > $f.ftp.inbound.delaydat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.inbound.delay############################################################compuate statistical distribution of FTP trafic#specifically the follwoing parameters in FTP model# (1) ftp file arrival# (2) number of files per ftp session# (3) flie sizeecho "Output flow statistics for FTP traffic"dateecho "estimate file distribution of outbound FTP traffic"cat $f.ftp.outbound | awk -f ftp.awk | sort > $f.ftp.outbound.flow.sortcat $f.ftp.outbound.flow.sort | ftp.pl -w $f.ftp.outboundsort -o $f.ftp.outbound.arrive.sort $f.ftp.outbound.arriveawk -f ftp.arrive.awk < $f.ftp.outbound.arrive.sort > $f.ftp.outbound.file.interecho "estimate file distribution of inbound FTP traffic"cat $f.ftp.inbound | awk -f ftp.awk | sort > $f.ftp.inbound.flow.sortcat $f.ftp.inbound.flow.sort | ftp.pl -w $f.ftp.inboundsort -o $f.ftp.inbound.arrive.sort $f.ftp.inbound.arriveawk -f ftp.arrive.awk < $f.ftp.inbound.arrive.sort > $f.ftp.inbound.file.interdat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.outbound.file.inter dat2cdf -e 0 -i 1000 -d 1000 -t $f.ftp.outbound.sizedat2cdf -e 0 -i 1 -d 1 -t $f.ftp.outbound.filenodat2cdf -e 0 -i 0.001 -d 1 -t $f.ftp.inbound.file.interdat2cdf -e 0 -i 1000 -d 1000 -t $f.ftp.inbound.sizedat2cdf -e 0 -i 1 -d 1 -t $f.ftp.inbound.fileno ######################################echo "Output TCP window size"dateecho "WWW"grep " S " $f.www.outbound | grep ".80 >" > $f.www.outbound.svr.wingrep " S " $f.www.inbound | grep ".80 >" > $f.www.inbound.svr.wingrep " S " $f.www.outbound | grep ".80:" > $f.www.outbound.clnt.wingrep " S " $f.www.inbound | grep ".80:" > $f.www.inbound.clnt.winawk -f win.awk < $f.www.outbound.svr.win > $f.www.outbound.winsawk -f win.awk < $f.www.inbound.svr.win > $f.www.inbound.winsawk -f win.awk < $f.www.outbound.clnt.win > $f.www.outbound.wincawk -f win.awk < $f.www.inbound.clnt.win > $f.www.inbound.wincdat2cdf -e 1024 -i 1024 -d 1024 -t $f.www.outbound.winsdat2cdf -e 1024 -i 1024 -d 1024 -t $f.www.outbound.wincdat2cdf -e 1024 -i 1024 -d 1024 -t $f.www.inbound.winsdat2cdf -e 1024 -i 1024 -d 1024 -t $f.www.inbound.wincecho "FTP"grep " S " $f.ftp.outbound | grep ".20 >" > $f.ftp.outbound.svr.wingrep " S " $f.ftp.inbound | grep ".20 >" > $f.ftp.inbound.svr.wingrep " S " $f.ftp.outbound | grep ".20:" > $f.ftp.outbound.clnt.wingrep " S " $f.ftp.inbound | grep ".20:" > $f.ftp.inbound.clnt.winawk -f win.awk < $f.ftp.outbound.svr.win > $f.ftp.outbound.winsawk -f win.awk < $f.ftp.inbound.svr.win > $f.ftp.inbound.winsawk -f win.awk < $f.ftp.outbound.clnt.win > $f.ftp.outbound.wincawk -f win.awk < $f.ftp.inbound.clnt.win > $f.ftp.inbound.wincdat2cdf -e 1024 -i 1024 -d 1024 -t $f.ftp.outbound.winsdat2cdf -e 1024 -i 1024 -d 1024 -t $f.ftp.outbound.wincdat2cdf -e 1024 -i 1024 -d 1024 -t $f.ftp.inbound.winsdat2cdf -e 1024 -i 1024 -d 1024 -t $f.ftp.inbound.wincdateecho "execution complete"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -