中科大高网实验报告Word文档格式.docx
《中科大高网实验报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《中科大高网实验报告Word文档格式.docx(21页珍藏版)》请在冰点文库上搜索。
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);
OnOffApplication"
}
nCsma=nCsma==0?
1:
nCsma;
//创建底层的4个小csma网络
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));
//创建总的csma大csma网络
NodeContainercsmaNodes7;
csmaNodes7.Create
(1);
csmaNodes7.Add(csmaNodes5.Get(0));
csmaNodes7.Add(csmaNodes6.Get(0));
//CMSA1网络拓扑
CsmaHelpercsma1;
csma1.SetChannelAttribute("
DataRate"
StringValue("
1.0Mbps"
));
Delay"
TimeValue(NanoSeconds(500)));
NetDeviceContainercsmaDevices1;
csmaDevices1=csma1.Install(csmaNodes1);
//CMSA2网络拓扑
CsmaHelpercsma2;
csma2.SetChannelAttribute("
NetDeviceContainercsmaDevices2;
csmaDevices2=csma2.Install(csmaNodes2);
//CMSA3网络拓扑
CsmaHelpercsma3;
csma3.SetChannelAttribute("
NetDeviceContainercsmaDevices3;
csmaDevices3=csma3.Install(csmaNodes3);
//CMSA4网络拓扑
CsmaHelpercsma4;
csma4.SetChannelAttribute("
NetDeviceContainercsmaDevices4;
csmaDevices4=csma4.Install(csmaNodes4);
//CMSA5网络拓扑
CsmaHelpercsma5;
csma5.SetChannelAttribute("
NetDeviceContainercsmaDevices5;
csmaDevices5=csma5.Install(csmaNodes5);
//CMSA6网络拓扑
CsmaHelpercsma6;
csma6.SetChannelAttribute("
NetDeviceContainercsmaDevices6;
csmaDevices6=csma6.Install(csmaNodes6);
//CMSA7网络拓扑
CsmaHelpercsma7;
csma7.SetChannelAttribute("
1.5Mbps"
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));
//在p2p网络上分配地址node0:
10.1.1.1;
node1:
10.1.1.2
Ipv4AddressHelperaddress;
//在CSMA1网络上分配地址,相当于t1下端口IP为10.0.1.1,其余主机为n1IP为10.0.1.2
//n2主机IP为10.0.1.3
address.SetBase("
10.0.1.0"
255.255.255.0"
Ipv4InterfaceContainercsmaInterfaces1;
csmaInterfaces1=address.Assign(csmaDevices1);
//在CSMA2网络上分配地址,同CSMA1网络IP分配
10.0.2.0"
Ipv4InterfaceContainercsmaInterfaces2;
csmaInterfaces2=address.Assign(csmaDevices2);
//在CSMA3网络上分配地址,同CSMA1网络IP分配
10.0.3.0"
Ipv4InterfaceContainercsmaInterfaces3;
csmaInterfaces3=address.Assign(csmaDevices3);
//在CSMA4网络上分配地址,同CSMA1网络IP分配
10.0.4.0"
Ipv4InterfaceContainercsmaInterfaces4;
csmaInterfaces4=address.Assign(csmaDevices4);
//在CSMA5网络上分配地址,相当于a1下端口IP为10.1.1.1,其余交换机为t1上端口IP为10.1.1.2
//t2上端口IP为10.1.1.3
10.1.1.0"
Ipv4InterfaceContainercsmaInterfaces5;
csmaInterfaces5=address.Assign(csmaDevices5);
//在CSMA6网络上分配地址,同CSMA5中网络IP分配
10.2.1.0"
Ipv4InterfaceContainercsmaInterfaces6;
csmaInterfaces6=address.Assign(csmaDevices6);
//在CSMA7网络上分配地址,相当于c1端口IP为192.168.1.1,其余交换机为a1上端口IP为192.168.1.2
//t2上端口IP为192.168.1.3
192.168.1.0"
Ipv4InterfaceContainercsmaInterfaces7;
csmaInterfaces7=address.Assign(csmaDevices7);
//将h2作为服务器,打开7个不同的端口,5000-5006
ApplicationContainersinkApp[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作为client的代码,其余主机h3-h8作为client的代码类似:
ApplicationContainerclientApp2;
OnOffHelperclient2("
InetSocketAddress(csmaInterfaces1.GetAddress
(1),5000));
client2.SetAttribute("
OnTime"
StringValue("
ConstantRandomVariable[Constant=50]"
OffTime"
ConstantRandomVariable[Constant=0]"
DataRateValue(DataRate("
)));
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();
Destroy();
return0;
}
五.多对一实验仿真结果
1.采用Wireshark对实验输出的.pcap文件进行分析。
分析位置为主机h1的端口。
上述程序输出的文件名为:
dc1-1-0.pcap。
2.产看TCP回话,如图
(2)所示:
图
(2)
3.第1个tcpflow,在Filter中输入字符串tcp.srcport==5000||tcp.dstport==5000,条件筛选如图(3)所示:
图(3)
第一个端口5000的throughput,即h2与h1的通信。
如图(4)所示:
图(4)
第一个端口5000的rtt,即h2与h1的通信。
如图(5)所示:
第二个端口5001的throughput,即h3与h1的通信。
如图(6)所示:
图(5)
第二个端口5001的rtt,即h3与h1的通信。
如图(7)所示:
第三个端口5002的throughput,即h4与h1的通信。
如图(8)所示:
图(6)
第三个端口5002的rtt,即h4与h1的通信。
如图(9)所示:
第四个端口5003的throughput,即h5与h1的通信。
如图(10)所示:
第四个端口5003的rtt,即h5与h1的通信。
第五个端口5004的throughput,即h6与h1的通信。
如图(11)所示:
第五个端口5004的rtt,即h6与h1的通信。
如图(12)所示:
第六个端口5005的throughput,即h7与h1的通信。
如图(13)所示:
第六个端口5005的rtt,即h7与h1的通信。
如图(14)所示:
第七个端口5006的throughput,即h8与h1的通信。
如图(15)所示:
第七个端口5006的rtt,即h8与h1的通信。
如图(16)所示:
实验结果分析:
从图(4)—图(10)可以看出,当多个主机向一个主机发送数据包时(在实验中是其余主机向h1发送数据包)。
(1)位于同一个小的CSMA网络的主机h1和h2的通信频繁,二者之间的rtt也趋于稳定。
但是在h2与h1通信前部分所发的数据,二者之间rtt有一个峰值,这是说明在此时刻,为路由器t1的路由转发表的学习过程,因此rtt有峰值。
(2)当主机需要跨域小的子网进行通信时,即主机h3和h4与h1的通信过程。
由于主机h3和h4需要经由同一个路由器t2进行数据包的转发,所以,h3吞吐量的峰值正好对应h4吞吐量的低谷,h3吞吐量的低谷对应h4吞吐量的峰值。
(3)当主机需要跨越中心交换机时,即主机h5,h6,h7和h8与主机h1进行通信时,在时间<
40s时,吞吐量很低。
造成这一现象的原因有两种:
①这些主机需要多跳才能传给目的主机②通信前半时间,这些主机的数据包处于路由排队的对尾。
六.多对多重点实验代码解释
由于多数代码与多对一相同,在这里仅解释不同之处。
//zhujih1--->
h5
ApplicationContainerclientApp1;
OnOffHelperclient1("
InetSocketAddress(csmaInterfaces3.GetAddress
(1),5000));
client1.SetAttribute("
clientApp1=client1.Install(csmaNodes1.Get
(1));
clientApp1.Start(Seconds
(2));
clientApp1.Stop(Seconds(50));
以上代码片段为主机h1与h5之间的通信。
其余主机h6与h2,h3和h7,h8和h4通信代码类似。
Ipv4GlobalRoutingHelper:
dc2"
csmaNodes1.Get
(2)->
GetId(),0,false);
//csmaDevices1.Get
(2));
csma2.EnablePcap("
csmaNodes2.Get
(2)->
//csmaDevices2.Get
(2));
csma3.EnablePcap("
csmaNodes3.Get
(1)->
//csmaDevices3.Get
(1));
csma4.EnablePcap("
csmaNodes4.Get
(1)->
//csmaDevices4.Get
(1));
以上代码片段为设置输出文件。
通过运行代码,可输出四个文件,分别为:
dc2-2-0,dc2-5-0,dc2-7-0,dc2-10-0.
对以上四个文件通过Wireshark进行分析,各主机对的吞吐量如图所示:
图:
主机h1与h5通信
主机h3与h7通信
主机h6与h2通信
主机h8与h4通信
对以上的主机对h1与h5、h3与h7、h6与h2、h8与h4的吞吐量图可以看出:
每对主机的吞吐量大致相同。
七.系统的瓶颈分析
从以上两个实验可以看出,系统存在瓶颈问题,主要反映在当两个主机需要跨越两个大的子网进行通信时,网络吞吐量变得很小。
出现这一情况的主要原因是:
Core层的路由器本身的限制和底层的路由器进行路由的过程中出现的排队和转发能量不强。
我们可以对网络拓扑进行改进,增大路由表之间的链路,加快网络路由转发能力。
改进的拓扑如下所示:
实验改进结果如下:
可以看出,吞吐量显著增加。
八.实验总结
在本次实验中,学习使用ns-3仿真模拟软件,取得了较好的效果。
对于现有数据中心网络拓扑有了较深刻的体会。
在实验过程中,发现现有数据中心的缺陷,并加以改进,实现了较好的结果。