OPNET做仿真是比较牛的,但是opnet似乎没有特别好的方法来读场景,特别是无线仿真中如果节点坐标是别人给定好的,这个时候我觉得比较方便的方法是自己用python写个script来生成xml文件,然后在opnet中的topology来import这个xml文件。下面是我写的函数,很简单原始,也没用xml的工具库,就把xml当文本文件来处理了。
'''
Created on Dec 22, 2010
@author: hankgong
'''
def writeHeader():
outstr= \
'''<?xml version="1.0"?>
<!DOCTYPE network SYSTEM "network.dtd">
<network locale="C" version="1.7" reference_time="13:28:25.000 Dec 18 2010" attribute_processing="explicit">
<subnet name="Campus Network">
'''
return outstr
def writeFeeter():
outstr= \
''' <attr name="priority" value="0"/>
<attr name="user id" value="0"/>
<attr name="x position" value="0.0"/>
<attr name="y position" value="0.0"/>
<attr name="icon name" value="subnet"/>
<attr name="outline color" value="blue"/>
<attr name="doc file" value="nt_fixed_subnet"/>
<attr name="creation source" value="Object Palette"/>
<attr name="creation timestamp" value="13:21:18 Dec 18 2010"/>
<attr name="creation data" value=""/>
<characteristic name="units" value="Kilometers"/>
</subnet>
</network>
'''
return outstr
def writeRXGroup(x, y, commrange):
outstr=\
''' <node name="RXGroup" model="MWSReceiverGroup" ignore_questions="true" min_match_score="strict matching">
<attr name="x position" value="'''+str(x)+'''"/>
<attr name="y position" value="'''+str(y)+'''"/>
<attr name="threshold" value="0.0"/>
<attr name="icon name" value="util_rxgroup"/>
<attr name="doc file" value="nt_fixed_node"/>
<attr name="tooltip" value="Receiver Group Configuration"/>
<attr name="creation source" value="Object copy"/>
<attr name="creation timestamp" value="13:24:05 Dec 18 2010"/>
<attr name="creation data" value=""/>
<attr name="label color" value="black"/>
<attr name="drgm.Use Connection File" value="enabled"/>
<attr name="Distance Threshold (meters)" value="'''+str(commrange)+'''" symbolic="true"/>
</node>
'''
return outstr
def writeSeverNode(x, y):
outstr=\
''' <node name="Scheduler Sever" model="CentralSever" ignore_questions="true" min_match_score="strict matching">
<attr name="x position" value="'''+str(x)+'''"/>
<attr name="y position" value="'''+str(y)+'''"/>
<attr name="icon name" value="server"/>
<attr name="doc file" value=""/>
<attr name="tooltip" value=""/>
<attr name="creation source" value="Object Palette"/>
<attr name="creation timestamp" value="13:45:17 Dec 18 2010"/>
<attr name="creation data" value=""/>
</node>
'''
return outstr
def writeMNNode(x, y, node_ip, flow_dst_ip, startTime, stopTime, pktSize, intervalStr='constant (0.015)'):
outstr=\
''' <node name="node_'''+str(node_ip)+'''" model="MWSCentralMN" ignore_questions="true" min_match_score="strict matching">
<attr name="x position" value="'''+str(x)+'''"/>
<attr name="y position" value="'''+str(y)+'''"/>
<attr name="threshold" value="0.0"/>
<attr name="icon name" value="armoured_jeep.chassis"/>
<attr name="doc file" value=""/>
<attr name="tooltip" value=""/>
<attr name="creation source" value="Object Palette"/>
<attr name="creation timestamp" value="13:42:43 Dec 18 2010"/>
<attr name="creation data" value=""/>
<attr name="label color" value="black"/>
<attr name="flow_dst_ip" value="'''+str(flow_dst_ip)+'''"/>
<attr name="node_ip" value="'''+str(node_ip)+'''"/>
<attr name="traffic_gen.Packet Interarrival Time" value="'''+intervalStr+'''"/>
<attr name="traffic_gen.Packet Size" value="constant ('''+str(pktSize)+''')"/>
<attr name="traffic_gen.Start Time" value="'''+str(startTime)+'''"/>
<attr name="traffic_gen.Stop Time" value="'''+str(stopTime)+'''"/>
</node>
'''
return outstr
#print writeHeader()
#print writeRXGroup(0,0,1000)
#print writeSeverNode(1,1)
#print writeMNNode(5.02, 6.03, 3, 0, 10.1, 20)
#print writeFeeter()
分享到:
相关推荐
opnet
OPNET仿真案例 OPNET仿真案例OPNET仿真案例OPNET仿真案例
可生成Opnet14.5的注册文件,Opnet安装完成后运行该文件即可
运用该技术,独立于OPNET平台开发的第三方程序,首先导出数据库中的网络场景数据生成XML文档,然后通过解析XML文档,自动生成能够由OPNET进行仿真的标准网络模型。该技术既实现了OPNET资源的多用户共享
opnet包交换仿真报告opnet.pdf
opnet中进行TDMA仿真,物联网仿真实例源码
本资源包括OPNET常见问题总结、OPNET调试心得、常用核心函数库、OPNET使用指南等资源,希望可以为OPNET学习者提高帮助。
opnet14.5 本人刚安装并且运行成功,附带win7 + vs2008 + opnet14.5的安装说明 本分卷由好压(Haozip)生成 分卷文件共有以下12个: dtczhl.haozip01.zip dtczhl.haozip02.zip dtczhl.haozip03.zip dtczhl....
OPNET14.5安装程序(附安装教程) 绝对可用,放心下载,每一个part都可以找到
OPNET14.5安装教程 可用,按照提示一步一步安装即可
opnet的典型应用 几点小的知识,简单入门
基于OPNET的无线局域网网络仿真,为Opnet网络仿真实例
opnet14.5 本人刚安装并且运行成功,附带win7 + vs2008 + opnet14.5的安装说明 本分卷由好压(Haozip)生成 分卷文件共有以下12个: dtczhl.haozip01.zip dtczhl.haozip02.zip dtczhl.haozip03.zip dtczhl....
根据opnet联机文档翻译过来的 可能不是很准确,单很有参考帮助
opnet14.5 本人刚安装并且运行成功,附带win7 + vs2008 + opnet14.5的安装说明 本分卷由好压(Haozip)生成 分卷文件共有以下12个: dtczhl.haozip01.zip dtczhl.haozip02.zip dtczhl.haozip03.zip dtczhl....
版本:OPNET 14.5 对应书籍:[美]Adarshpal S. Sethi, Vasil Y.Hnatyshin. 计算机网络仿真OPNET实用指南[M]. 王玲芳, 母景琴, 译....【注】 RIP仿真包括:普通RIP、RIP触发扩展模式、RIP...不同的仿真结果位于不同场景下。
opnet环境中实现aodv路由协议建模
非常好的opnet入门资料 学习仿真的必读资源