﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-勤加练习，必能得心应手！不期速成，日拱一卒 ！-随笔分类-网络</title><link>http://www.blogjava.net/ldwblog/category/53250.html</link><description>态度决定一切</description><language>zh-cn</language><lastBuildDate>Tue, 07 Jan 2020 10:48:11 GMT</lastBuildDate><pubDate>Tue, 07 Jan 2020 10:48:11 GMT</pubDate><ttl>60</ttl><item><title>个人公众号「Java爱好者社区」高质量原创文章持续输出，欢迎各位小主关注</title><link>http://www.blogjava.net/ldwblog/archive/2019/10/30/434887.html</link><dc:creator>David1228</dc:creator><author>David1228</author><pubDate>Wed, 30 Oct 2019 06:10:00 GMT</pubDate><guid>http://www.blogjava.net/ldwblog/archive/2019/10/30/434887.html</guid><wfw:comment>http://www.blogjava.net/ldwblog/comments/434887.html</wfw:comment><comments>http://www.blogjava.net/ldwblog/archive/2019/10/30/434887.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ldwblog/comments/commentRss/434887.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ldwblog/services/trackbacks/434887.html</trackback:ping><description><![CDATA[blogjava网站与博客园合并了，对blogjava还是有感情的。<br />并且blogjava网站发布的文章是在博客园首页看不到的。<br />blogjava网站首页能看到，你可以点击标题进入可以看到图片二维码信息。<br /><br /><strong style="color: red; font-size: 14pt;">Java爱好者社区</strong><br />公众号内容简介：<br /><p><span style="background-color: yellow; color: red;">专注于分享Java后端相关技术、老司机实战干货，不限于JVM、并发、设计模式、性能优化、分布式&amp;微服务、云原生、大数据相关主题。</span><br style="color: red;" /><span style="background-color: yellow; color: red;">希望关注的你停下脚步，定有所收获。</span><br style="color: red;" /><br />以前的个人博客内容不好迁移，所以我打算根据自己的多年经验，不断整理输出有价值的内容。<br />目前公众号内容有关于<span style="background-color: yellow; color: red;">SpringCloud（微服务框架）、Skywalking（APM监控调用链）、JVM（GC分析、内存泄漏分析）、并发编程</span>相关原创实战文章已出炉。<br /><br />最近刚开始已经有不少小伙伴关注了，期待能有幸搜索到本博客的同学，可以扫码关注一下，不胜感激。<br />大家有任何技术、职场、面试上的问题都可以与我交流。<br /><br /><span style="background-color: yellow;"><strong>方式一：</strong></span><span style="color: red; background-color: yellow;"><strong>扫码以下公众号二维码：</strong></span><br /><img src="http://www.blogjava.net/images/blogjava_net/ldwblog/Java%E7%88%B1%E5%A5%BD%E8%80%85%E7%A4%BE%E5%8C%BA%E4%BA%8C%E7%BB%B4%E7%A0%81.png" border="0" alt="" /><br /><br />方式二：<span style="color: red;">在微信上直接搜索：&nbsp;</span><span style="color: red; background-color: yellow;">javatech_cbo</span><br /><br />感谢各位小伙伴的支持，后续会在该公众号上输出大量的有价值的实战干货 ，期待与你一同进步与成长。<br /></p><img src ="http://www.blogjava.net/ldwblog/aggbug/434887.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ldwblog/" target="_blank">David1228</a> 2019-10-30 14:10 <a href="http://www.blogjava.net/ldwblog/archive/2019/10/30/434887.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Netperf与网络性能测量的五项指标以及使用方式</title><link>http://www.blogjava.net/ldwblog/archive/2013/01/21/394497.html</link><dc:creator>David1228</dc:creator><author>David1228</author><pubDate>Mon, 21 Jan 2013 04:31:00 GMT</pubDate><guid>http://www.blogjava.net/ldwblog/archive/2013/01/21/394497.html</guid><wfw:comment>http://www.blogjava.net/ldwblog/comments/394497.html</wfw:comment><comments>http://www.blogjava.net/ldwblog/archive/2013/01/21/394497.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/ldwblog/comments/commentRss/394497.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/ldwblog/services/trackbacks/394497.html</trackback:ping><description><![CDATA[<a title="Netperf使用" href="/Files/ldwblog/Netperf使用.doc">Netperf使用</a><br />转载自:<a href="http://os.chinaunix.net/a2004/0708/1042/000001042354.shtml">http://os.chinaunix.net/a2004/0708/1042/000001042354.shtml</a>&nbsp;<br /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　本文首先介绍网络性能测量的一些基本概念和方法，然后结合 netperf 工具的使用，具体的讨论如何测试不同情况下的网络性能。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在构建或管理一个网络系统时，我们更多的是关心网络的可用性，即网络是否连通，而对于其整体的性能往往考虑不多，或者即使考虑到性能的问题，但是却发现没有合适的手段去测试网络的性能。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　当开发出一个网络应用程序后，我们会发现，在实际的网络环境使用中，网络应用程序的使用效果不是很理想，问题可能出现在程序的开发上面，也有可能由于实际的网络环境中存在着瓶颈。面对这种问题，程序员一般会一筹莫展，原因就在于不掌握一些网络性能测量的工具。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在本文中，首先介绍网络性能测量的一些基本概念和方法，然后结合 netperf 工具的使用，具体的讨论如何测试不同情况下的网络性能。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">网络性能测试概述</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络性能测量的五项指标</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　测量网络性能的五项指标是：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　可用性（availability）&nbsp;</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　响应时间（response time）&nbsp;</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络利用率（network utilization）&nbsp;</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络吞吐量（network throughput）&nbsp;</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络带宽容量（network bandwidth capacity）&nbsp;</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1． 可用性</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　测试网络性能的第一步是确定网络是否正常工作，最简单的方法是使用 ping 命令。通过向远端的机器发送 icmp echo request，并等待接收 icmp echo reply 来判断远端的机器是否连通，网络是否正常工作。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Ping 命令有非常丰富的命令选项，比如 -c 可以指定发送 echo request 的个数，-s 可以指定每次发送的 ping 包大小。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络设备内部一般有多个缓冲池，不同的缓冲池使用不同的缓冲区大小，分别用来处理不同大小的分组（packet）。例如交换机中通常具有三种类型的包缓冲：一类针对小的分组，一类针对中等大小的分组，还有一类针对大的分组。为了测试这样的网络设备，测试工具必须要具有发送不同大小分组的能力。Ping 命令的 -s 就可以使用在这种场合。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　2． 响应时间</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Ping 命令的 echo request/reply 一次往返所花费时间就是响应时间。有很多因素会影响到响应时间，如网段的负荷，网络主机的负荷，广播风暴，工作不正常的网络设备等等。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在网络工作正常时，记录下正常的响应时间。当用户抱怨网络的反应时间慢时，就可以将现在的响应时间与正常的响应时间对比，如果两者差值的波动很大，就能说明网络设备存在故障。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　3． 网络利用率</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络利用率是指网络被使用的时间占总时间（即被使用的时间+空闲的时间）的比例。比如，Ethernet 虽然是共享的，但同时却只能有一个报文在传输。因此在任一时刻，Ethernet 或者是 100% 的利用率，或者是 0% 的利用率。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　计算一个网段的网络利用率相对比较容易，但是确定一个网络的利用率就比较复杂。因此，网络测试工具一般使用网络吞吐量和网络带宽容量来确定网络中两个节点之间的性能。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　4． 网络吞吐量</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络吞吐量是指在某个时刻，在网络中的两个节点之间，提供给网络应用的剩余带宽。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络吞吐量可以帮组寻找网络路径中的瓶颈。比如，即使 client 和 server 都被分别连接到各自的 100M Ethernet 上，但是如果这两个 100M 的Ethernet 被 10M 的 Ethernet 连接起来，那么 10M 的 Ethernet 就是网络的瓶颈。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　网络吞吐量非常依赖于当前的网络负载情况。因此，为了得到正确的网络吞吐量，最好在不同时间（一天中的不同时刻，或者一周中不同的天）分别进行测试，只有这样才能得到对网络吞吐量的全面认识。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　有些网络应用程序在开发过程的测试中能够正常运行，但是到实际的网络环境中却无法正常工作（由于没有足够的网络吞吐量）。这是因为测试只是在空闲的网络环境中，没有考虑到实际的网络环境中还存在着其它的各种网络流量。所以，网络吞吐量定义为剩余带宽是有实际意义的。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　5． 网络带宽容量</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　与网络吞吐量不同，网络带宽容量指的是在网络的两个节点之间的最大可用带宽。这是由组成网络的设备的能力所决定的。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　测试网络带宽容量有两个困难之处：在网络存在其它网络流量的时候，如何得知网络的最大可用带宽；在测试过程中，如何对现有的网络流量不造成影响。网络测试工具一般采用 packet pairs 和 packet trains 技术来克服这样的困难。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">收集网络性能数据的方式</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　当确定了网络性能的测试指标以后，就需要使用网络测试工具收集相应的性能数据，分别有三种从网络获取数据的方式：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1． 通过snmp协议直接到网络设备中获取，如net-snmp工具</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　2． 侦听相关的网络性能数据，典型的工具是tcpdump</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　3． 自行产生相应的测试数据，如本文中使用的netperf工具</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">Netperf</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Netperf是一种网络性能的测量工具，主要针对基于TCP或UDP的传输。Netperf根据应用的不同，可以进行不同模式的网络性能测试，即批量数据传输（bulk data transfer）模式和请求/应答（request/reponse）模式。Netperf测试结果所反映的是一个系统能够以多快的速度向另外一个系统发送数据，以及另外一个系统能够以多块的速度接收数据。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Netperf工具以client/server方式工作。server端是netserver，用来侦听来自client端的连接，client端是netperf，用来向server发起网络测试。在client与server之间，首先建立一个控制连接，传递有关测试配置的信息，以及测试的结果；在控制连接建立并传递了测试配置信息以后，client与server之间会再建立一个测试连接，用来来回传递着特殊的流量模式，以测试网络的性能。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">TCP网络性能</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　由于TCP协议能够提供端到端的可靠传输，因此被大量的网络应用程序使用。但是，可靠性的建立是要付出代价的。TCP协议保证可靠性的措施，如建立并维护连接、控制数据有序的传递等都会消耗一定的网络带宽。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Netperf可以模拟三种不同的TCP流量模式：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1） 单个TCP连接，批量（bulk）传输大量数据</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　2） 单个TCP连接，client请求/server应答的交易（transaction）方式</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　3） 多个TCP连接，每个连接中一对请求/应答的交易方式</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">UDP网络性能</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　UDP没有建立连接的负担，但是UDP不能保证传输的可靠性，所以使用UDP的应用程序需要自行跟踪每个发出的分组，并重发丢失的分组。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Netperf可以模拟两种UDP的流量模式：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1） 从client到server的单向批量传输</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　2） 请求/应答的交易方式</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　由于UDP传输的不可靠性，在使用netperf时要确保发送的缓冲区大小不大于接收缓冲区大小，否则数据会丢失，netperf将给出错误的结果。因此，对于接收到分组的统计不一定准确，需要结合发送分组的统计综合得出结论。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">Netperf的命令行参数</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在unix系统中，可以直接运行可执行程序来启动netserver，也可以让inetd或xinetd来自动启动netserver。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　当netserver在server端启动以后，就可以在client端运行netperf来测试网络的性能。netperf通过命令行参数来控制测试的类型和具体的测试选项。根据作用范围的不同，netperf的命令行参数可以分为两大类：全局命令行参数、测试相关的局部参数，两者之间使用--分隔：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　netperf [global options]-- [test-specific options]</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　这里我们只解释那些常用的命令行参数，其它的参数读者可以查询netperf的man手册。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　-H host ：指定远端运行netserver的server IP地址。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　-l testlen：指定测试的时间长度（秒）</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　-t testname：指定进行的测试类型，包括TCP_STREAM，UDP_STREAM，TCP_RR，TCP_CRR，UDP_RR，在下文中分别对它们说明。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在后面的测试中，netserver运行在192.168.0.28，server与client通过局域网连接（100M Hub）。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><strong style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">Netperf测试网络性能</strong><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　测试批量（bulk）网络流量的性能</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　批量数据传输典型的例子有ftp和其它类似的网络应用（即一次传输整个文件）。根据使用传输协议的不同，批量数据传输又分为TCP批量传输和UDP批量传输。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1． TCP_STREAM</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Netperf缺省情况下进行TCP批量传输，即-t TCP_STREAM。测试过程中，netperf向netserver发送批量的TCP数据分组，以确定数据传输过程中的吞吐量：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　 ./netperf -H 192.168.0.28 -l 60</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　TCP STREAM TEST to 192.168.0.28</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Recv　 Send　　Send</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Socket Socket　Message　Elapsed</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　Size　 Size　　Size　　 Time　　 Throughput</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　bytes　bytes　 bytes　　secs.　　10^6bits/sec</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " />&nbsp;<br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　 87380　16384　16384　　60.00　　　88.00</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " />&nbsp;<br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　从netperf的结果输出中，我们可以知道以下的一些信息：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　1） 远端系统（即server）使用大小为87380字节的socket接收缓冲</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　2） 本地系统（即client）使用大小为16384字节的socket发送缓冲</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　3） 向远端系统发送的测试分组大小为16384字节</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　4） 测试经历的时间为60秒</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　5） 吞吐量的测试结果为88Mbits/秒</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　在缺省情况下，netperf向发送的测试分组大小设置为本地系统所使用的socket发送缓冲大小。</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　TCP_STREAM方式下与测试相关的局部参数如下表所示：</span><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　</span><center style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　<img src="http://pub.chinaunix.net/uploadfile/200912/20091216083023162.jpg" style="border: 0px; "  alt="" /></center><br style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; " /><span style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; ">　　通过修改以上的参数，并观察结果的</span>&nbsp;。<br /><br /><br /><br /><br /><br /><br /><img src ="http://www.blogjava.net/ldwblog/aggbug/394497.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/ldwblog/" target="_blank">David1228</a> 2013-01-21 12:31 <a href="http://www.blogjava.net/ldwblog/archive/2013/01/21/394497.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>