了解网络中真实的流量,国内很难找到巨人的肩膀。

WAND是新西兰waikato 大学计算机系的研究小组,主要做网络测量,大规模网络流量捕获,网络分析。还做专业的分析软件。

libtrace是其开源的分析软件项目。

它可以读写流量。这些流量也放在他们网站上提供下载。

libtrace 有大量的可执行程序,在linux下编译运行。 例如,流统计报告tracereport.

  • traceanon
  • traceconvert
  • tracediff
  • traceends
  • tracefilter
  • tracemerge
  • tracepktdump
  • tracereplay
  • tracereport
  • tracertstats
  • tracesplit
  • tracesplit_dir
  • tracestats
  • tracesummary
  • tracetop
  • tracetopends
  • ToolTricks

使用tracereport工具里的参数选项-F可以统计流数目。tracereport工具有如下子选项。

tracereport

    [ -f bpf | --filter=bpf ]
[ -e | --error ]
[ -F | --flow ]
[ -P | --protocol ]
[ -p | --port ]
[ -T | --tos ]
[ -t | --ttl ]
[ -O | --tcpoptions ]
[ -o | --synoptions ]
[ -n | --nlp ]
[ -d | --direction ]
[ -C | --ecn ]
[ -s | --tcpsegment ]

求trace1的流数量

linux# tracereport -F erf:trace1.erf.gz

.erf.gz是流的后缀名,进过.gz压缩,是erf的包数据格式。

主要算法由/libtrace/tools/tracereport/Flow_report.c/ flow_per_packet()函数完成

void flow_per_packet(struct libtrace_packet_t *packet)
{
struct libtrace_ip *ip = trace_get_ip(packet);
struct fivetuple_t ft;
if (!ip)
return;
ft.ipa=ip->ip_src.s_addr;
ft.ipb=ip->ip_dst.s_addr;
ft.porta=trace_get_source_port(packet);
ft.portb=trace_get_destination_port(packet);
ft.prot = 0; if (!SET_CONTAINS(flowset,ft)) {
SET_INSERT(flowset,ft);
flow_count++;
}
}

每读取一个包就会调用一次此函数。

结构体 libtrace_ip 表示数据包ip。

得到ip内容。

判断是否是已经出现过的流,否则flow_count++;

统计值就在flow_count里。

==========完=========

2015年12月10日

原文链接:http://www.pandaroll.cn/research/research1.html

最新文章

  1. parted在2T以上硬盘上分区操作
  2. 图像卷积、相关以及在MATLAB中的操作
  3. highcharts的简单使用
  4. Java中的异常
  5. PHP JAVA Bridge桥的最新使用
  6. POJ 2031 Building a Space Station (最小生成树)
  7. Python分析NGINX LOG版本二
  8. Android之自定义AlertDialog无法监听控件
  9. Internship
  10. spring-junit的标注总结
  11. 自制证书搭建https服务
  12. NLTK学习笔记(八):文法--词关系研究的工具
  13. C#进行CAD二次开发环境配置
  14. Mac 下 Chrome多个Tab之间切换
  15. ActiveMQ的使用
  16. iOS开发之获取文件的md5值
  17. RPA 介绍
  18. E - Elevator
  19. leetcode — path-sum-ii
  20. 从此web开发so easy!

热门文章

  1. c语言符号常量与常变量的区别?
  2. C++题目(论述类)
  3. Java [Leetcode 167]Two Sum II - Input array is sorted
  4. BZOJ3887 [Usaco2015 Jan] Grass Cownoisseur 【tarjan】【DP】*
  5. ubuntu下Python的安装和使用
  6. SmartSql 动态仓储
  7. 在iOS中使用ZBar扫描二维码
  8. Tree的两种存储形式
  9. 移动端base.css
  10. CSU1632Repeated Substrings(后缀数组/最长公共前缀)