parent
54e3a4864b
commit
86d9a33716
Binary file not shown.
@ -1,63 +0,0 @@
|
||||
class AllSimConnect():
|
||||
# todo: 连接类
|
||||
def __init__(self, nodex, nodex_ifs, nodey, nodey_ifs, config=None):
|
||||
"""
|
||||
连接对象
|
||||
:param nodex: 节点
|
||||
:param nodex_ifs: 节点接口
|
||||
:param nodey: 节点
|
||||
:param nodey_ifs: 节点接口
|
||||
"""
|
||||
self.ConfigCorrect = 0 if config is None else config
|
||||
self.NobjS = nodex
|
||||
self.NobjE = nodey
|
||||
self.IfsS = nodex_ifs
|
||||
self.IfsE = nodey_ifs
|
||||
|
||||
class SimHost():
|
||||
"""
|
||||
主机类
|
||||
"""
|
||||
def __init__(self, x=0, y=0, id=None, config=None, label=None):
|
||||
self.ObjID = id
|
||||
self.ObjType = 1
|
||||
self.ObjLabel = label
|
||||
self.interface = []
|
||||
self.connections = []
|
||||
|
||||
class SimRouter():
|
||||
"""
|
||||
路由类
|
||||
"""
|
||||
def __init__(self, x=0, y=0, id=None, config=None, label=None, *args):
|
||||
self.ObjID = id
|
||||
self.ObjType = 2
|
||||
self.ObjLabel = label
|
||||
self.router_table = {}
|
||||
|
||||
class SimSwitch():
|
||||
"""
|
||||
交换机类
|
||||
"""
|
||||
def __init__(self, x=0, y=0, id=None, config=None, label=None, *args):
|
||||
self.ObjID = id
|
||||
self.ObjType = 3
|
||||
self.ObjLabel = label
|
||||
self.mac_table = {}
|
||||
|
||||
class SimHub():
|
||||
"""
|
||||
集线器类
|
||||
"""
|
||||
def __init__(self, x=0, y=0, id=None, config=None, label=None, *args):
|
||||
self.ObjID = str() if id is None else id
|
||||
self.ObjType = 4
|
||||
self.ObjLabel = label
|
||||
|
||||
if __name__ == '__main__':
|
||||
AllSimObj = []
|
||||
host1 = SimHost()
|
||||
AllSimObj.append(host1)
|
||||
router = SimRouter()
|
||||
AllSimObj.append(router)
|
||||
connect = AllSimConnect(host1, 1, router, 1)
|
@ -0,0 +1,33 @@
|
||||
from NetworkAnalog import NetWorkAnalog
|
||||
from SimObjs import *
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
AllSimObj = {}
|
||||
root = Window()
|
||||
root.title('网络拓扑图')
|
||||
root_attr = {
|
||||
"width": root.winfo_screenwidth() * 0.83,
|
||||
"height": root.winfo_screenheight() * 0.85,
|
||||
}
|
||||
size = '%dx%d+%d+%d' % (root_attr['width'], root_attr['height'], (root.winfo_screenwidth() - root_attr['width']) / 2,
|
||||
(root.winfo_screenheight() - root_attr['height']) / 2 - 30)
|
||||
canvas = NetWorkAnalog(root, width=root_attr['width'], heigh=root_attr['height'], bg="white")
|
||||
canvas.place(x=0, y=0, anchor='nw')
|
||||
root.geometry(size)
|
||||
host1 = SimHost(canvas, 406, 268)
|
||||
AllSimObj[host1.ObjID] = host1
|
||||
host2 = SimHost(canvas, 323, 285)
|
||||
AllSimObj[host2.ObjID] = host2
|
||||
router = SimRouter(canvas, 216, 263)
|
||||
AllSimObj[router.ObjID] = router
|
||||
host1_router_connect = AllSimConnect(canvas, host1, 1, router, 1)
|
||||
host2_router_connect = AllSimConnect(canvas, host2, 1, router, 2)
|
||||
host1.connections[0] = host1_router_connect
|
||||
router.connections[0] = host1_router_connect
|
||||
host2.connections[0] = host2_router_connect
|
||||
router.connections[1] = host2_router_connect
|
||||
conns = [host1_router_connect, host2_router_connect]
|
||||
canvas.show_obj(AllSimObj, conns)
|
||||
root.mainloop()
|
Binary file not shown.
Loading…
Reference in new issue