中科大高網實驗報告_第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

提交評論