Пример #1
0
import DCC

B = DCC.Unit()
local = ('127.0.0.1', 12200)
datalink = ('127.0.0.1', 11200)
dest = ('127.0.0.1', 11200)
B.debug4(local, dest, datalink)
print('B.start to recv')
print(B.recv())
res = input('end...')
Пример #2
0
            continue
        else:
            return True
    return False

#配置交换机表
switchtable = {
    '127.0.0.1:12100':'127.0.0.1:11102',
     '127.0.0.1:11200':'127.0.0.1:11101'
     }

#初始化路由表
Atable = []
routetable.addTable(('127.0.0.1',12000),("127.0.0.1",12100),1,Atable)

a1 = DCC.Unit()
#第一个是本地,后两个乱绑定,不会动用它里面的发送函数
local = ('127.0.0.1',11100)
a1.debug4(local,('127.0.0.1',19986),('127.0.0.1',19985)) 

readable = [a1.sk]
repeat = ''
print('start to host......')
while(1):
    #随机交换路由表
    num = randint(1,10)
    if(num==3):
        packaged = routetable.packageTables(Atable).encode()
        waitForChunk = a1.bin2Frames(a1.bytes2Bin(packaged),306)
        afterChunk = a1.dataWrap(waitForChunk[0],randint(0,254))
        a1.datalink = ('127.0.0.1',11102)