149 lines
4.9 KiB
Python
149 lines
4.9 KiB
Python
from pyutils import *
|
|
import time
|
|
import random
|
|
|
|
def tc1():
|
|
random.seed(int(time.time() * 1000))
|
|
genPkt = GenPkt()
|
|
#-------------------------------------------------------------------------
|
|
#>>>>>>错误的数据包1
|
|
genPkt.clean()
|
|
|
|
data = list()
|
|
'''
|
|
for i in range(128):
|
|
data.append(random.randint(0, 255))
|
|
'''
|
|
data = data + [0x57, 0x17, 0xfd, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40]
|
|
for i in range(64):
|
|
data.append(random.randint(0, 255))
|
|
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
|
for i in range(64):
|
|
data.append(random.randint(0, 255))
|
|
data = data + [0, 0]
|
|
|
|
genPkt.setPkt(2, data)
|
|
gen_file_def = "err_pkt1"
|
|
sm_idx = 0
|
|
|
|
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
|
+genWriteTransPktCode(gen_file_def, sm_idx)
|
|
+genTrgTransPktCode(gen_file_def, sm_idx)
|
|
+genReadAckPktCode(gen_file_def, sm_idx))
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
|
return gen_file_def
|
|
|
|
|
|
def tc2():
|
|
random.seed(int(time.time() * 1000))
|
|
genPkt = GenPkt()
|
|
|
|
gen_file_def = "errorpkt_tc02"
|
|
sm_idx = 0
|
|
tc_des = "发送错误的数据包\\n" \
|
|
+ "通过嗅探包、设置顺序地址命令等重新建立网络。"
|
|
|
|
#-------------------------------------------------------------------------
|
|
#>>>>>>错误的数据包2
|
|
genPkt.clean()
|
|
|
|
data = list()
|
|
'''
|
|
for i in range(128):
|
|
data.append(random.randint(0, 255))
|
|
'''
|
|
|
|
data = data + [0xb2, 0x4e, 0xd3, 0xe2, 0xa8, 0xd3, 0x86, 0x01, 0x44, 0x3f]
|
|
for i in range(64):
|
|
data.append(random.randint(0, 255))
|
|
data = data + [0, 0, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x40]
|
|
for i in range(64):
|
|
data.append(random.randint(0, 255))
|
|
data = data + [0, 0]
|
|
|
|
genPkt.setPkt(2, data)
|
|
|
|
sm_idx = 0
|
|
genPkt.addBeforeExc(genTcStartFrameCode(gen_file_def, tc_des))
|
|
|
|
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
|
+genWriteTransPktCode(gen_file_def, sm_idx)
|
|
+genTrgTransPktCode(gen_file_def, sm_idx)
|
|
+genReadAckPktCode(gen_file_def, sm_idx))
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
|
|
|
genPkt.clean()
|
|
|
|
gen_file_def_ap = gen_file_def + "_rw"
|
|
sm_idx = 0
|
|
|
|
data = [0,] * 32
|
|
genPkt.addSubPkt(0, 0, 0, 0xd, 32, data)
|
|
|
|
clear_int = [0xff, 0xff, 0xff, 0xff]
|
|
|
|
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def_ap, sm_idx)
|
|
+genWriteTransPktCode(gen_file_def_ap, sm_idx)
|
|
+genTrgTransPktCode(gen_file_def_ap, sm_idx)
|
|
+genReadAckPktCode(gen_file_def_ap, sm_idx)
|
|
+genIFRwDataCode(1, 0x74, False, 4)
|
|
+genIFRwDataCode(2, 0x74, False, 4)
|
|
+genIFRwDataCode(3, 0x74, False, 4)
|
|
+genIFRwDataCode(4, 0x74, False, 4)
|
|
|
|
+genIFRwDataCode(1, 0x78, True, 4, clear_int)
|
|
+genIFRwDataCode(2, 0x78, True, 4, clear_int)
|
|
+genIFRwDataCode(3, 0x78, True, 4, clear_int)
|
|
+genIFRwDataCode(4, 0x78, True, 4, clear_int)
|
|
|
|
+genIFRwDataCode(1, 0x74, False, 4)
|
|
+genIFRwDataCode(2, 0x74, False, 4)
|
|
+genIFRwDataCode(3, 0x74, False, 4)
|
|
+genIFRwDataCode(4, 0x74, False, 4)
|
|
|
|
+genTcEndFrameCode(gen_file_def))
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1, True, gen_file_def_ap)
|
|
|
|
return gen_file_def
|
|
|
|
|
|
def tc3():
|
|
random.seed(int(time.time() * 1000))
|
|
genPkt = GenPkt()
|
|
#-------------------------------------------------------------------------
|
|
#>>>>>>错误的数据包3
|
|
genPkt.clean()
|
|
|
|
data = list()
|
|
for i in range(1024):
|
|
data.append(random.randint(0, 255))
|
|
|
|
genPkt.setPkt(2, data)
|
|
gen_file_def = "err_pkt3"
|
|
sm_idx = 0
|
|
|
|
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
|
+genWriteTransPktCode(gen_file_def, sm_idx)
|
|
+genTrgTransPktCode(gen_file_def, sm_idx)
|
|
+genReadAckPktCode(gen_file_def, sm_idx))
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
|
return gen_file_def
|
|
|
|
|
|
def tc4():
|
|
genPkt = GenPkt()
|
|
#-------------------------------------------------------------------------
|
|
#>>>>>>错误的嗅探数据包
|
|
|
|
genPkt.clean()
|
|
genPkt.setPkt(2, [0, 0, 0, 0])
|
|
gen_file_def = "detect_err_pkt"
|
|
sm_idx = 0
|
|
|
|
genPkt.addAfterExc(genWriteTransLenCode(gen_file_def, sm_idx)
|
|
+genWriteTransPktCode(gen_file_def, sm_idx)
|
|
+genTrgTransPktCode(gen_file_def, sm_idx)
|
|
+genReadAckPktCode(gen_file_def, sm_idx))
|
|
genPkt.gen("./generated/shin/%s.vh"%(gen_file_def, ), 1)
|
|
return gen_file_def
|