41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
|
|
import binascii
|
|||
|
|
import logging
|
|||
|
|
import sys
|
|||
|
|
|
|||
|
|
sys.path.insert(0, '/home/zjz/CCSDS_study/netzob-030/test/src')
|
|||
|
|
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
|||
|
|
|
|||
|
|
from netzob.all import *
|
|||
|
|
|
|||
|
|
samples = ["00ff1f000000", "00fe1f000000", "00fe1f000000", "00fe1f000000",
|
|||
|
|
"00ff1f000000", "00ff1f000000", "00ff0f000000", "00fe2f000000"]
|
|||
|
|
|
|||
|
|
messages = [RawMessage(data=binascii.unhexlify(s)) for s in samples]
|
|||
|
|
symbol = Symbol(messages=messages)
|
|||
|
|
symbol.encodingFunctions.add(TypeEncodingFunction(HexaString))
|
|||
|
|
|
|||
|
|
print("=== 原始消息 ===")
|
|||
|
|
print(symbol)
|
|||
|
|
|
|||
|
|
print("\n=== 默认 splitStatic ===")
|
|||
|
|
Format.splitStatic(symbol)
|
|||
|
|
print(symbol)
|
|||
|
|
|
|||
|
|
print("\n=== SIZE_8,静态/动态字段均不合并 ===")
|
|||
|
|
Format.splitStatic(symbol, unitSize=UnitSize.SIZE_8,
|
|||
|
|
mergeAdjacentStaticFields=False,
|
|||
|
|
mergeAdjacentDynamicFields=False)
|
|||
|
|
print(symbol)
|
|||
|
|
|
|||
|
|
print("\n=== SIZE_16,静态/动态字段均不合并 ===")
|
|||
|
|
Format.splitStatic(symbol, unitSize=UnitSize.SIZE_16,
|
|||
|
|
mergeAdjacentStaticFields=False,
|
|||
|
|
mergeAdjacentDynamicFields=False)
|
|||
|
|
print(symbol)
|
|||
|
|
|
|||
|
|
print("\n=== SIZE_16,合并相邻动态字段 ===")
|
|||
|
|
Format.splitStatic(symbol, unitSize=UnitSize.SIZE_16,
|
|||
|
|
mergeAdjacentStaticFields=False,
|
|||
|
|
mergeAdjacentDynamicFields=True)
|
|||
|
|
print(symbol)
|