中科大高网实验报告_第1页
中科大高网实验报告_第2页
中科大高网实验报告_第3页
中科大高网实验报告_第4页
中科大高网实验报告_第5页
已阅读5页,还剩12页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

运用ns-3模拟数据中心〔datacenter〕试验报告一.试验工具Ubuntu、Vmware虚拟机、ns-3仿真器、Wireshark抓包工具二.试验步骤1.编写程序模拟网络拓扑及网络消息传输状态〔多对一和多对多〕2.Wireshark抓包工具对输出的.pcap文件进展分析3.试验总结三.网络拓扑图〔1〕四.重要代码解释//备注:以下是实现主机间多对一通信的代码,其中多指的为主机h2—h8,一为主机//h1.//库函数调用#include“ns3/core-module.h“#include“ns3/network-module.h“#include“ns3/csma-module.h“#include“ns3/internet-module.h“#include“ns3/applications-module.h“#include“ns3/ipv4-global-routing-helper.h“usingnamespacens3;NS_LOG_COMPONENT_DEFINE(“SecondScriptExample“);intmain(intargc,char*argv[]){boolverbose=true;uint32_tnCsma=3;uint32_tnFlows=7;uint16_tport=5000;CommandLinecmd;//cmd.AddValue(“nCsma“,“Numberof\“extra\“CSMAnodes/devices“,nCsma);cmd.AddValue(“verbose“,“Tellechoapplicationstologiftrue“,verbose);cmd.Parse(argc,argv);if(verbose)//为真{////LOG模块,LOG消息LogComponentEnable(“PacketSink“,LOG_LEVEL_INFO);LogComponentEnable(“OnOffApplication“,LOG_LEVEL_INFO);}nCsma=nCsma==0?1:nCsma;4csma网络NodeContainercsmaNodes1;csmaNodes1.Create(3);NodeContainercsmaNodes2;csmaNodes2.Create(3);NodeContainercsmaNodes3;csmaNodes3.Create(3);NodeContainercsmaNodes4;csmaNodes4.Create(3);csma中左侧网络NodeContainercsmaNodes5;csmaNodes5.Create(1);csmaNodes5.Add(csmaNodes1.Get(0));csmaNodes5.Add(csmaNodes2.Get(0));csma中右侧网络NodeContainercsmaNodes6;csmaNodes6.Create(1);csmaNodes6.Add(csmaNodes3.Get(0));csmaNodes6.Add(csmaNodes4.Get(0));//csmacsma网络NodeContainercsmaNodes7;csmaNodes7.Create(1);csmaNodes7.Add(csmaNodes5.Get(0));csmaNodes7.Add(csmaNodes6.Get(0));//CMSA1网络拓扑CsmaHelpercsma1;csma1.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma1.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices1;csmaDevices1=csma1.Install(csmaNodes1);//CMSA2网络拓扑CsmaHelpercsma2;csma2.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma2.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices2;csmaDevices2=csma2.Install(csmaNodes2);//CMSA3网络拓扑CsmaHelpercsma3;csma3.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma3.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices3;csmaDevices3=csma3.Install(csmaNodes3);//CMSA4网络拓扑CsmaHelpercsma4;csma4.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma4.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices4;csmaDevices4=csma4.Install(csmaNodes4);//CMSA5网络拓扑CsmaHelpercsma5;csma5.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma5.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices5;csmaDevices5=csma5.Install(csmaNodes5);//CMSA6网络拓扑CsmaHelpercsma6;csma6.SetChannelAttribute(“DataRate“,StringValue(“1.0Mbps“));csma6.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices6;csmaDevices6=csma6.Install(csmaNodes6);//CMSA7网络拓扑CsmaHelpercsma7;csma7.SetChannelAttribute(“DataRate“,StringValue(“1.5Mbps“));csma7.SetChannelAttribute(“Delay“,TimeValue(NanoSeconds(500)));NetDeviceContainercsmaDevices7;csmaDevices7=csma7.Install(csmaNodes7);//安装协议栈〔node只有一个stack〕InternetStackHelperstack;stack.Install(csmaNodes1);stack.Install(csmaNodes2);stack.Install(csmaNodes3);stack.Install(csmaNodes4);stack.Install(csmaNodes5.Get(0));stack.Install(csmaNodes6.Get(0));stack.Install(csmaNodes7.Get(0));node0:10.1.1.1;node1:10.1.1.2Ipv4AddressHelperaddress;//CSMA1t1IP10.0.1.1n1IP为10.0.1.2IP10.0.1.3address.SetBase(“10.0.1.0“,“255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces1;csmaInterfaces1=address.Assign(csmaDevices1);//CSMA2CSMA1IP安排address.SetBase(“10.0.2.0““255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces2;csmaInterfaces2=address.Assign(csmaDevices2);//CSMA3CSMA1IP安排address.SetBase(“10.0.3.0““255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces3;csmaInterfaces3=address.Assign(csmaDevices3);//CSMA4CSMA1IP安排address.SetBase(“10.0.4.0““255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces4;csmaInterfaces4=address.Assign(csmaDevices4);//CSMA5a1IP10.1.1.1t1上端口IP10.1.1.2//t2IP10.1.1.3address.SetBase(“10.1.1.0“,“255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces5;csmaInterfaces5=address.Assign(csmaDevices5);//CSMA6CSMA5IP安排address.SetBase(“10.2.1.0““255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces6;csmaInterfaces6=address.Assign(csmaDevices6);//CSMA7c1IP192.168.1.1a1上端口IP192.168.1.2IP192.168.1.3address.SetBase(“192.168.1.0“,“255.255.255.0“);Ipv4InterfaceContainercsmaInterfaces7;csmaInterfaces7=address.Assign(csmaDevices7);//h27个不同的端口,5000-5006ApplicationContainersinkApp[nFlows];for(unsignedinti=0;i<nFlows;i++){PacketSinkHelperpacketSinkHelper(“ns3::TcpSocketFactory“,InetSocketAddress(csmaInterfaces1.GetAddress(1),port+i));sinkApp[nFlows]=packetSinkHelper1.Install(csmaNodes1.Get(1));sinkApp[nFlows].Start(Seconds(1.0));sinkApp[nFlows].Stop(Seconds(60.0));}h2作为clienth3-h8client的代码类似:ApplicationContainerclientApp2;OnOffHelperclient2(“ns3::TcpSocketFactory“,InetSocketAddress(csmaInterfaces1.GetAddress(1),5000));client2.SetAttribute(“OnTime“,StringValue(“ns3::ConstantRandomVariable[Constant=50]“));client2.SetAttribute(“OffTime“,StringValue(“ns3::ConstantRandomVariable[Constant=0]“));client2.SetAttribute(“DataRate“,DataRateValue(DataRate(“1.5Mbps“)));client2.SetAttribute(“PacketSize“,UintegerValue(2000));clientApp2=client2.Install(csmaNodes1.Get(2));clientApp2.Start(Seconds(2));clientApp2.Stop(Seconds(50));Ipv4GlobalRoutingHelper::PopulateRoutingTables;//tracing消息,执行仿真csma1.EnablePcap(“dc1“,csmaDevices1.Get(1),true);Simulator::Run;Simulator::Destroy;return0;}五.多对一试验仿真结果Wireshark对试验输出的.pcaph1的端口。上述程序输出的文件名为:dc1-1-0.pcap。TCP回话,如图〔2〕所示:图〔2〕图〔2〕1tcpflowFilter中输入字符串tcp.srcport==5000||tcp.dstport==5000,条件筛选如图〔3〕所示:图〔3〕5000throughputh2h1的通信。如图〔4〕所示:图〔图〔4〕5000rtth2h1的通信。如图〔5〕所示:5001throughputh3h1的通信。如图〔6〕所示:图〔5〕5001rtth3h1的通信。如图〔7〕所示:5002throughputh4h1的通信。如图〔8〕所示:50035003throughputh5h1的通信。如图〔10〕所示:图〔6〕第三个端口5002的rtt,即h4与h1的通信。如图〔9〕所示:5003rtth5h1的通信。如图〔10〕所示:5004throughputh6h1的通信。如图〔11〕所示:50055005throughputh7h1的通信。如图〔13〕所示:第五个端口5004的rtt,即h6与h1的通信。如图〔12〕所示:5005rtth7h1的通信。如图〔14〕所示:5006throughputh8h1的通信。如图〔15〕所示:5006rtth8h1的通信。如图〔16〕所示:试验结果分析:从图〔4〕—图〔10〕可以看出,当多个主机向一个主机发送数据包时〔在试验中是其h1发送数据包〕。CSMAh1h2rtt也趋于h2h1rtt有一个峰值,这是说明在t1rtt有峰值。h3h4h1的通信过程。由于h3h4t2进展数据包的转发,所以,h3吞吐量的峰值h4吞吐量的低谷,h3h4吞吐量的峰值。h5,h6,h7h8h1进展通信时,在时间<40s时,吞吐量很低。造成这一现象的缘由有两种:①这些主机需要多跳才能传给目的主机②通信前半时间,这些主机的数据包处于路由排队的对尾。六.多对多重点试验代码解释由于多数代码与多对一一样,在这里仅解释不同之处。//zhujih1--->h5ApplicationContainerclientApp1;OnOffHelperclient1(“ns3::TcpSocketFactory“,InetSocketAddress(csmaInterfaces3.GetAddress(1),5000));client1.SetAttribute(“OnTime“,StringValue(“ns3::ConstantRandomVariable[Constant=50]“));client1.SetAttribute(“OffTime“,StringValue(“ns3::ConstantRandomVariable[Constant=0]“));client1.SetAttribute(“DataRate“,DataRateValue(DataRate(“1.5Mbps“)));client1.SetAttribute(“PacketSize“,UintegerValue(2000));clientApp1=client1.Install(csmaNodes1.Get(1));clientApp1.Start(Seconds(2));clientApp1.Stop(Seconds(50));h1h5h6h

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论