收藏 分销(赏)

高级计算机网络实验报告ns3模拟数据中心.docx

上传人:快乐****生活 文档编号:3963040 上传时间:2024-07-24 格式:DOCX 页数:25 大小:1.81MB
下载 相关 举报
高级计算机网络实验报告ns3模拟数据中心.docx_第1页
第1页 / 共25页
高级计算机网络实验报告ns3模拟数据中心.docx_第2页
第2页 / 共25页
高级计算机网络实验报告ns3模拟数据中心.docx_第3页
第3页 / 共25页
高级计算机网络实验报告ns3模拟数据中心.docx_第4页
第4页 / 共25页
高级计算机网络实验报告ns3模拟数据中心.docx_第5页
第5页 / 共25页
点击查看更多>>
资源描述

1、Project1-ns3模拟数据中心实验要求根据上面的数据中心拓扑图,完成以下要求:1. 根据给定的数据中心的拓扑结构,利用ns3进行仿真2. 模拟两种通信模式(traffic pattern)o all-to-all:每个服务器都发送消息给其他服务器消息,由拓扑结构可知,超过50%的消息传送将跨越两个簇(cluster)o many-to-one:每个服务器都发送消息给其中一个服务器3. 测量两种模式下网络的仿真可以达到的吞吐量,找出网络瓶颈,并且说明如何改进注:拓扑中的网络都是Ethernet网实验内容数据中心模拟实现及主要代码解释a. 设置自定义的attribute为了做实验方便,设置如

2、下自定义attribute: pattern:通信模式,all-to-all或many-to-one,默认为1 defaultDst:多对一模式下,接收消息的默认服务器序号,默认为0 verbose:enable或者disable PacketSink和OnOffApplication的日志,默认为false DataRate1:定义数据中心拓扑第一层的数据传输速率(Mbps),默认为1.0 DataRate2:定义数据中心拓扑第二层的数据传输速率(Mbps),默认为1.0 DataRate3:定义数据中心拓扑第三层的数据传输速率(Mbps),默认为1.5实现代码如下: uint16_t pa

3、ttern = 1; uint16_t nodesNum = 8; uint16_t defaultDst = 0; float DataRate1 = 1.0; float DataRate2 = 1.0; float DataRate3 = 1.5; uint16_t port = 50000; bool verbose = false; CommandLine cmd; cmd.AddValue(pattern, number of traffic pattern, pattern);/pattern1:all-to-all pattern2:many-to-one cmd.AddVal

4、ue(defaultDst, default destination server node in pattern 2, defaultDst); cmd.AddValue(DataRate1, data rate of csma network at level 1, DataRate1); cmd.AddValue(DataRate2, data rate of csma network at level 2, DataRate2); cmd.AddValue(DataRate3, data rate of csma network at level 3, DataRate3); cmd.

5、AddValue (verbose, Tell sink and onoff applications to log if true, verbose); cmd.Parse(argc, argv); LogComponentEnable (DataCenterSimulation, LOG_LEVEL_INFO); if (verbose) LogComponentEnable (PacketSink, LOG_LEVEL_INFO); LogComponentEnable (OnOffApplication, LOG_LEVEL_INFO); b. 创建结点根据实验要求,总共需要创建15个

6、结点,包括: 8 servers 4 ToR switches 2 Aggregation switches 1 Core switch实现代码如下: /create nodes NodeContainer n1_8; n1_8.Create(8); NodeContainer t1_4; t1_4.Create(4); NodeContainer a12; a12.Create(2); NodeContainer c1; c1.Create(1);c. 创建CSMA网络节点整个数据中心网络拓扑从下往上可以分为三层,即 第一层:由服务器与ToR组成的ethernet网络,共有4个,编号为CSM

7、A11,CSMA12,CSMA13,CSMA14 第二层:由ToR与Aggregation组成的ethernet网络,共有2个,编号为CSMA21,CSMA22 第三层:由Aggregation与Core组成的ethernet网络,共有1个,编号为CSMA3将创建好的15个网络结点分配到这7个CSMA网络中,实现代码如下: /create csma nodes NodeContainer csmaNodes11 = NodeContainer(n1_8.Get(0),n1_8.Get(1),t1_4.Get(0); NodeContainer csmaNodes12 = NodeContain

8、er(n1_8.Get(2),n1_8.Get(3),t1_4.Get(1); NodeContainer csmaNodes13 = NodeContainer(n1_8.Get(4),n1_8.Get(5),t1_4.Get(2); NodeContainer csmaNodes14 = NodeContainer(n1_8.Get(6),n1_8.Get(7),t1_4.Get(3); NodeContainer csmaNodes21 = NodeContainer(t1_4.Get(0),t1_4.Get(1),a12.Get(0); NodeContainer csmaNodes2

9、2 = NodeContainer(t1_4.Get(2),t1_4.Get(3),a12.Get(1); NodeContainer csmaNodes3 = NodeContainer(a12.Get(0),a12.Get(1),c1.Get(0);d. 设置CSMA网络attribute,并将其安装到相应结点上根据实验要求中的网络拓扑,设置相应网络的属性 所有直接相连的两个结点之间的延迟都为500ns 第一层和第二层CSMA网络的数据传输速率都为1.0Mbps,第三层为1.5Mbps然后安装到相应的网络结点上,实现代码如下(DataRate可以通过命令行参数设置,默认值即为原实验要求):

10、 /create the channels first without any IP addressing information CsmaHelper csma1; sprintf(buf,%1.1fMbps,DataRate1); csma1.SetChannelAttribute (DataRate, StringValue (buf); csma1.SetChannelAttribute (Delay, StringValue (500ns); NetDeviceContainer csmaDevices11 = csma1.Install (csmaNodes11); NetDevi

11、ceContainer csmaDevices12 = csma1.Install (csmaNodes12); NetDeviceContainer csmaDevices13 = csma1.Install (csmaNodes13); NetDeviceContainer csmaDevices14 = csma1.Install (csmaNodes14); CsmaHelper csma2; sprintf(buf,%1.1fMbps,DataRate2); csma2.SetChannelAttribute (DataRate, StringValue (buf); csma2.S

12、etChannelAttribute (Delay, StringValue (500ns); NetDeviceContainer csmaDevices21 = csma2.Install (csmaNodes21); NetDeviceContainer csmaDevices22 = csma2.Install (csmaNodes22); CsmaHelper csma3; sprintf(buf,%1.1fMbps,DataRate3); csma3.SetChannelAttribute (DataRate, StringValue (buf); csma3.SetChannel

13、Attribute (Delay, StringValue (500ns); NetDeviceContainer csmaDevices3 = csma3.Install (csmaNodes3);e. 分配网络IP根据实验要求,为每个结点安装协议栈,并为7个CSMA网络分配IP,实现代码如下 /assign IP address NS_LOG_INFO (Assign IP address.); InternetStackHelper stack; stack.Install (n1_8); stack.Install (t1_4); stack.Install (a12); stack.

14、Install (c1); Ipv4AddressHelper address; address.SetBase (10.0.1.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces11 = address.Assign (csmaDevices11); address.SetBase (10.0.2.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces12 = address.Assign (csmaDevices12); address.SetBase (10.0.3.0

15、, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces13 = address.Assign (csmaDevices13); address.SetBase (10.0.4.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces14 = address.Assign (csmaDevices14); address.SetBase (10.1.1.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces21 = addres

16、s.Assign (csmaDevices21); address.SetBase (10.2.1.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces22 = address.Assign (csmaDevices22); address.SetBase (192.168.1.0, 255.255.255.0); Ipv4InterfaceContainer csmaInterfaces3 = address.Assign (csmaDevices3);f. 初始化路由表这里直接调用了ns3自带的路由实现,实现代码如下 / Crea

17、te router nodes, initialize routing database and set up the routing / tables in the nodes. Ipv4GlobalRoutingHelper:PopulateRoutingTables ();g. 创建和分配PacketSink和OnOffClient首先,创建sink和OnOff,实现代码如下 /Create sinkApp and OnOffClient ApplicationContainer clientAppnodesNum4; ApplicationContainer sinkAppnodesN

18、um;然后,分配sink到所有的server结点上,实现代码如下(其中nodesNum表示server个数): for(unsigned int i = 0;i nodesNum; i+) PacketSinkHelper packetSinkHelper (ns3:TcpSocketFactory, getAddress(i,port,csmaInterfaces11,csmaInterfaces12,csmaInterfaces13,csmaInterfaces14); sinkAppi = packetSinkHelper.Install (n1_8.Get (i); sinkAppi.

19、Start(Seconds (1.0); sinkAppi.Stop(Seconds (60.0); 再然后,分配OnOffClient到server结点上,并且根据pattern不同,进行不同的配置 pattern 1:每个服务器都发送消息给其他服务器消息,即发送消息给在另一个簇上面的4个服务器(每个服务器上建立4个OnOffClient) pattern 2:每个服务器都发送消息给同一个服务器,可以默认为n1(每个服务器(n1除外)上建立1个OnOffClient)实现代码如下 for(int i = 0; i nodesNum; i+) uint16_t dst = 0; if(patt

20、ern=1)/all-to-all pattern for(int j = 0 ;j 4; j+) if(iTCP Stream Graph-Throughput Graph来查看整个过程中该结点上的吞吐量变化情况 使用statistics-Summary来查看当前结点上网络平均吞吐量,以此估计相应CSMA网络的吞吐量server n1上的测量结果如下Throughput GraphSummaryToR t1上的测量结果如下Throughput GraphSummaryAggregation a1上的测量结果如下Throughput GraphSummaryb. pattern 1 实验结果分

21、析首先对实验结果进行简单汇总网络结点带宽(Mbps)网络平均吞吐量(Mbps)CSMA11server n11.00.255CSMA21ToR t11.00.541CSMA3Aggregation a11.50.993从上面的结果可以看出 第1层CSMA网络平均吞吐量是0.255Mbps,带宽利用率为25.5%; 第2层CSMA网络平均吞吐量是0.541Mbps,带宽利用率为54.1%; 第3层CSMA网络平均吞吐量是0.993Mbps,带宽利用率为66.2%。c. pattern 1 瓶颈及改进 瓶颈根据以上的实验结果可以看出来,从网络的平均吞吐量来看:第3层CSMA第2层CSMA第1层CS

22、MA2,从带宽利用率上看也是这样,所以作为core switch连接两个子网络但带宽过小的第三层网络成了整个网络的瓶颈。 改进可以加大第3层网络的带宽,防止数据流量过大出现拥塞的情况发生。因此最后确定的网络带宽如下所示:o CSMA11-14:1.0Mbpso CSMA21-22:1.0Mbpso CSMA3 :2.0Mbps 改进结果执行命令行./waf -run scratch/DC -DataRate1=1.0 -DataRate2=1.0 -DataRate3=2.0,以相同方式测量网络,得到的结果如下:网络结点带宽(Mbps)网络平均吞吐量(Mbps)CSMA11server n11

23、.00.306CSMA21ToR t11.00.523CSMA3Aggregation a12.00.990从上面的结果可以看出加大第三层网络的带宽,确实提高了整个网络的吞吐量,尤其是对最底层的server结点来说。d. pattern 2 实验结果执行命令./waf -run scratch/DC -pattern=2,实验运行结果如下所示从上面的结果可以看出,8个OnOffClient都将数据传输到n1,产生的pcap文件如下所示为了分析patten 2的网络吞吐量,根据网络拓扑的对称性,选取测量位置 CSMA11:通过server n1(node 0/device 0)来估计 CSMA1

24、2:通过server n3(node 2/device 0)来估计 CSMA13:通过server n5(node 4/device 0)来估计 CSMA21:通过ToR t1(node 8/device 1)来估计 CSMA22:通过ToR t3(node 10/device 1)来估计 CSMA3:通过Aggregation a1(node 12/device 1)来估计选取的测量标准为吞吐量,具体方法是 使用wireshark分析相应的pcap文件中的tcp包 使用statistics-TCP Stream Graph-Throughput Graph来查看整个过程中该结点上的吞吐量变化

25、情况 使用statistics-Summary来查看当前结点上网络平均吞吐量,以此估计相应CSMA网络的吞吐量server n1上的测量结果如下Throughput GraphSummaryserver n3上的测量结果如下Throughput GraphSummaryserver n5上的测量结果如下Throughput GraphSummaryToR t1上的测量结果如下Throughput GraphSummaryToR t3上的测量结果如下Throughput GraphSummaryAggregation a1上的测量结果如下Throughput GraphSummarye. pat

26、tern 2 实验结果分析首先对实验结果进行简单汇总网络结点带宽(Mbps)网络平均吞吐量(Mbps)CSMA11server n11.00.974CSMA12server n31.00.181CSMA13server n51.00.115CSMA21ToR t11.00.601CSMA22ToR t31.00.178CSMA3Aggregation a11.50.361从上面的结果可以看出 第1层CSMA11网络平均吞吐量是0.974Mbps,带宽利用率为97.4%; 第1层CSMA11网络平均吞吐量是0.181Mbps,带宽利用率为18.1%; 第1层CSMA11网络平均吞吐量是0.115

27、Mbps,带宽利用率为11.5%; 第2层CSMA21网络平均吞吐量是0.601Mbps,带宽利用率为60.1%; 第2层CSMA21网络平均吞吐量是0.178Mbps,带宽利用率为17.8%; 第3层CSMA3网络平均吞吐量是0.361Mbps,带宽利用率为36.1%。f. pattern 2 瓶颈及改进 瓶颈根据以上的实验结果可以看出来,整个网络拓扑中吞吐量最大的就是server n1所在的CSMA11网络,而其余部分的吞吐量都很小,带宽利用率不高,因此在pattern 2下,CSMA11网络就是整个网络的瓶颈。 改进可以加大第1层网络的带宽,防止数据流量过大出现拥塞的情况发生。因此最后确

28、定的网络带宽如下所示:o CSMA11-14:2.0Mbpso CSMA21-22:1.0Mbpso CSMA3 :1.5Mbps 改进结果执行命令行./waf -run scratch/DC -DataRate1=2.0 -DataRate2=1.0 -DataRate3=1.5,以相同方式测量网络,得到的结果如下:网络结点带宽(Mbps)网络平均吞吐量(Mbps)CSMA11server n12.01.930CSMA12server n32.00.403CSMA13server n52.00.217CSMA21ToR t11.00.960CSMA22ToR t31.00.272CSMA3Aggregation a11.50.496从上面的结果可以看出加大第一层网络的带宽,确实提高了整个网络的吞吐量。实验小结本次实验通过ns3模拟数据中心网络,基本熟悉了数据中心网络,对Edge(ToR)、Aggregation和Core三层switch的结构有了一个基础的认识,通过wireshark流量仿真发现了系统可能的瓶颈,并且思考了瓶颈产生的原因以及改善方案。

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服