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&#