中科大实验报告封面篇一:中科大地图导航(实验报告)中科大地图导航一,科大西区地图的构建与表示:(1)、物理地图的抽象表达地图选择:科大西区地图节点数:12边数:15地点信息:地点名,时间,简介,街道名,街道长度(权值)注释:该图为对科大地图抽象的结果。
1 / 11各顶点信息(地点信息和边信息严格按原地图制作,故直接见地图):1 :北门2:圆盘岔路口 3:东路岔路口 4:核科学院 5:生命科学院 6:西区学生活动中心 7:校车站 8:电三楼9:火灾重点实验室 10:南环路岔路口11:国家同步实验室。
(计算机中表示顶点号要减去1)(2)、地图信息的计算机信息表达图文件节点代码(采用邻接表方式存储):图信息定义于“节点定义.h”中,用于底层数据类型支持,其中重载了图的输入输出运算符,图中的节点和边的比较与赋值运算符等。
#define MAX_VERTEX_NUM 20typedef struct InfoType //边信息{int length; char* name;}InfoType;typedef struct VertexType//地点信息{char* name; char* time; char* scribe; VertexType& operator =(VertexType& b);}VertexType;typedef struct ArcNode //边{int adjvex; *nextarc; 2 / 11 ArcNode InfoType *info;ArcNode& operator =(ArcNode& b);}ArcNode;typedef struct VNode //图的邻接表{VertexType* data; ArcNode *firstarc; VNode& operator=(VNode& a);}VNode,AdjList[MAX_VERTEX_NUM];科大地图的初始化(宏处理方式):科大地图的初始化在“中科大地图.h”中完成,其中定义了ustc的namespace,在该namespace里有四个全区变量:VertexType VexInfo[11];//节点信息矩阵VNode node[MAX_VERTEX_NUM];//科大地图的邻接表int Ustcvexnum=0; //邻接表的顶点数int Ustcarcnum=0 ; //邻接表的边数有四个全局函数:void InititaVex(); //初始化顶点信息void InititaNode(); //初始化中科大地图邻接表int Findword(char *p);char* Findchar(char i); //根据顶点名找到相应的顶点号//根据顶点号找到相应的顶点名开始时,采用了很原始的复制粘贴的方式处理重复的数据,可是像这样有一定规模的数据,采用这样低级的方式处理,查询与修改时带来了很多的麻烦,于是设计了四个宏将处理简单化。
① DECLEARE_ VEREXTYPE 宏:使用于InititaVex()函数中,定义如下:#define DECLEARE_VEREXTYPE(dname,dtime,dscribe) \i = Findword(dname); \VexInfo[i].name =dname; \VexInfo[i].scribe =dtime;\3 / 11VexInfo[i].time =dscribe;于是有InititaVex()函数定义如下:Void InititaVex(){int i;DECLEARE_VEREXTYPE(“北门”,”无“,”无“)DECLEARE_VEREXTYPE("圆盘岔路口",”无“,”无“) DECLEARE_VEREXTYPE("东路岔路口",”无“,”无“) …}② BEGIN_ARCMAP,ADD_ARCMAP,END_ARCMAP三宏:这三宏使用于InititaNode()中,使用模式如下:BEGIN_ARCMAP(…,…,…,..)ADD_ARCMAP(…,…,…)END_ARCMAP()其定义如下:#defineBEGIN_ARCMAP(sname,dname,aname,alength)\ i = Findword(sname);\node[i].data = &VexInfo[i];\PArcpresent = (ArcNode *)malloc(sizeof(ArcNode));\PArcpresent ->adjvex = Findword(dname);\PArcpresent ->nextarc = NULL;\PInfoType = (InfoType*)malloc(sizeof(InfoType));\PArcpresent ->info = PInfoType;\PArcpresent ->info->length =a length;\PArcpresent ->info->name =aname;\node[i].firstarc = PArcpresent;\PArclast = PArcpresent;\Ustcarcnum++;4 / 11#define ADD_ARCMAP(dname,aname,alength)\PArcpresent = (ArcNode *) malloc(sizeof(ArcNode));\PArcpresent ->adjvex = Findword(dname);\PArcpresent ->nextarc = NULL;\PInfoType = (InfoType*)malloc(sizeof(InfoType));\PArcpresent ->info = PInfoType;\PArcpresent ->info->length = alength;\PArcpresent ->info->name =aname;\PArclast->nextarc = PArcpresent;\PArclast = PArcpresent;\Ustcarcnum++;#defineEND_ARCMAP()\Ustcvexnum++;\i = -1;由以上三宏,InititaVex()函数定义如下:void InititaNode(){InititaVex();int i;ArcNode *PArcpresent,*PArclast;InfoType *PInfoType;BEGIN_ARCMAP(“北门”,”圆盘岔路口”,”济慈路”,10) END_ARCMAP()BEGIN_ARCMAP(”圆盘岔路口”,”北门”,”济慈路”,10) PB1XX002 康海涛5 / 11篇二:中国科学技术大学-硕士-博士论文封面模板题****************************************************目单位姓名中国科学技术大学题目第一行题目第二行姓名位*** 教授 *** 副教授 O一五年五月单二篇三:实验报告Mininet仿真数据中心实验报告一.程序源代码及重要代码解释#!/usr/bin/python# 以下为函数引用from mininet.topo import Topofrom import Mininetfrom mininet.util import irange,dumpNodeConnectionsfrom mininet.log import setLogLevel# 用于具体实现网络拓扑功能class LinearTopo(Topo):"Linear topology of k switches, with one host per seitch" def __init__(self, k=2, **opts):"""Init.k: number of switches (and hosts)hconf: host configuration optionslconf: ling configuration options"""super(LinearTopo, self).__init__(**opts)self.k = k"""creates 7 switchs"""#创建7个switch,分别命名为s1,s2,s3,s4,s5,s5,s7switch1 = self.addSwitch('s1')switch2 = self.addSwitch('s2')switch3 = self.addSwitch('s3')switch4 = self.addSwitch('s4')switch5 = self.addSwitch('s5')switch6 = self.addSwitch('s6')switch7 = self.addSwitch('s7')"""creates h1,h2and addLink switch1"""# 创建主机 h1 和 h2 ,并将h1 和 h2 连接到switch1中for i in irange(1,k):host = self.addHost('h%s' %i)self.addLink( host, switch1)"""creates h3,h4 and addLink switch2"""# 创建主机 h3 和 h4 ,并将h3 和 h4 连接到switch2中for i in irange(k+1,k+2):host = self.addHost('h%s' %i)self.addLink( host, switch2)"""creates h5,h6 and addLink switch3"""# 创建主机 h5 和 h6 ,并将h5 和 h6 连接到switch3中for i in irange(k+3,k+4):host = self.addHost('h%s' %i)self.addLink( host, switch3)"""creates h7,h8 and addLink switch4"""# 创建主机 h7 和 h8 ,并将h7 和 h8 连接到switch4中for i in irange(k+5,k+6):host = self.addHost('h%s' %i)self.addLink( host, switch4)""" addLink switch1 and switch2 to switch5"""self.addLink( switch1, switch5)self.addLink( switch2, switch5)""" addLink switch3 and switch4 to switch6"""self.addLink( switch3, switch6)self.addLink( switch4, switch6)""" addLink switch5 and switch6 to switch7"""self.addLink( switch5, switch7)self.addLink( switch6, switch7)#网络测试部分def simpleTest():"Create and test a simple network"topo = LinearTopo(k=2)net = Mininet(topo)#start the networknet.start()print "Dumping host connections"dumpNodeConnections(net.hosts)print "Testing network connectivity"#test the connections of the networknet.pingAll()#Test the bandwidth of the h* and h*print "Testing bandwidth between h1 and h2" h1, h2 = net.get('h1', 'h2')net.iperf((h1, h2))print "Testing bandwidth between h1 and h3" h1, h3 = net.get('h1', 'h3')net.iperf((h1,h3))print "Testing bandwidth between h1 and h5" h1, h5 = net.get('h1', 'h5')net.iperf((h1,h5))#stop the networknet.stop()if __name__== '__main__':# Tell mininet to print useful information setLogLevel('info')simpleTest()二.实验运行结果及结果解释运行结果如下图(1):图(1)可以看出创建了如图(2)的网络图(2)测试网络连接:主要代码:net.start()print "Dumping host connections"dumpNodeConnections(net.hosts)print "Testing network connectivity"#test the connections of the networknet.pingAll()运行果如图(3):图(3)测试网络带宽:测试内容如下hosts in same rack; 程序中测试h1,h2hosts in different rack but under same aggregate switch;程序中测试h1,h3 hosts in different rack and under different aggregate switch;程序中测试h1,h5 主要代码:#Test the bandwidth of the h* and h*print "Testing bandwidth between h1 and h2"h1, h2 = net.get('h1', 'h2')net.iperf((h1, h2))print "Testing bandwidth between h1 and h3"h1, h3 = net.get('h1', 'h3')net.iperf((h1,h3))print "Testing bandwidth between h1 and h5"h1, h5 = net.get('h1', 'h5')net.iperf((h1,h5))实验结果如图(4)所示图(4)停止网络:主要代码:#stop the networknet.stop()运行结果如图(5)所示图(5)三.实验总结:从实验结果可以看出,在同一个小的子网内,带宽可达到1Gbits/s,当通信需要跨越aggregation层时,带宽有所下降,达到913Mbits/s,当通信需要跨越core层时,带宽再一次下降为289Mbits/s。