📄 vfd.tcl
字号:
LIBCMD HTVFD $HVFD_1 vfdstruct $iHub $iSlot $iPort
unset vfd1Data
##########################################################################################################
# Fill in VFD2 data #
# #
# - VFD2 data is set up assigning the value to each individual byte. #
# - Setting Configuration to $HVFD_INCR and DataCount to 10 means the LSB will increment through a cycle #
# of 10 and then repeat. #
# - Range is 6 bytes #
# - Offset is 48 bits, so this VFD will overlay the MAC Source area of the packet. #
# - VFD 1 and 2 are in reverse order, so the VFD pattern in the first four packets will look as follows #
# (XX indicates non-VFD bytes in packet): #
# XX XX XX XX XX XX 00 11 22 33 44 55 XX XX XX XX etc. #
# XX XX XX XX XX XX 00 11 22 33 44 56 XX XX XX XX etc. #
# XX XX XX XX XX XX 00 11 22 33 44 57 XX XX XX XX etc. #
# XX XX XX XX XX XX 00 11 22 33 44 58 XX XX XX XX etc. #
# #
# - HTVFD is followed by $HFVD_2 to indicate VFD2 and points to the vfdstruct structure that holds the #
# configuration settings. #
##########################################################################################################
puts "Setup VFD2"
set vfdstruct(Configuration) $HVFD_INCR
set vfdstruct(Range) $VFD_LENGTH
set vfdstruct(Offset) 48
struct_new vfd2Data Int*$VFD_LENGTH
set vfd2Data(0.i) 0x55
set vfd2Data(1.i) 0x44
set vfd2Data(2.i) 0x33
set vfd2Data(3.i) 0x22
set vfd2Data(4.i) 0x11
set vfd2Data(5.i) 0x00
set vfdstruct(Data) vfd2Data
set vfdstruct(DataCount) 10
LIBCMD HTVFD $HVFD_2 vfdstruct $iHub $iSlot $iPort
unset vfd2Data
############################################################################################################
# Fill in VFD3 data #
# #
# - VFD3 is used to overlay the type field. #
# - Configuration is set to $HVFD_ENABLED (Configuration options are different for VFD 1 and 2 and VFD 3). #
# - Range of 2 means we will lay down a 2 byte long VFD in each packet. #
# - Combined with an Offset of 96 bits means it will VFD3 will overlay the EtherType field. #
# - The vfd3Data structure has six elements. #
# - Setting the DataCount to 3 means we are calling for three VFDs to be created from the vfd3Data area. #
# (Note: tha DataCount which functions as a cycle counter in VFD1 and VFD2, has a different function in #
# VFD3.) #
# - In VFD3 DataCount specifies the size of the VFD3 data to divide up, for example, if Range #
# was set to 24 and DataCount was set to 96, you would have a cycle of four #
# different 24 byte packets. #
# - This setup will generate a repeating pattern of three VFD3 overlaying the Ethertype area emulating a #
# cycle of an IP packet (0800) followed by an SNMP packet (814C), followed by a Novell packet (8137) and #
# then repeating. #
# - VFD3 is in opposite order compared to VFD1 and VFD1. First four packets will look as follows #
# (XX indicates non-VFD bytes in packet): #
# XX XX XX XX XX XX XX XX XX XX XX XX 08 00 XX XX etc #
# XX XX XX XX XX XX XX XX XX XX XX XX 81 4C XX XX etc #
# XX XX XX XX XX XX XX XX XX XX XX XX 81 37 XX XX etc #
# XX XX XX XX XX XX XX XX XX XX XX XX 08 00 XX XX etc #
# - HTVFD is followed by $HFVD_3 to indicate VFD3 and points to the vfdstruct structure that holds the #
# configuration settings. #
############################################################################################################
puts "Setup VFD3"
set vfdstruct(Configuration) $HVFD_ENABLED
set vfdstruct(Range) 2
set vfdstruct(Offset) 96
struct_new vfd3Data Int*6
set vfd3Data(0.i) 0x08
set vfd3Data(1.i) 0x00
set vfd3Data(2.i) 0x81
set vfd3Data(3.i) 0x4C
set vfd3Data(4.i) 0x81
set vfd3Data(5.i) 0x37
set vfdstruct(Data) vfd3Data
set vfdstruct(DataCount) 6
LIBCMD HTVFD $HVFD_3 vfdstruct $iHub $iSlot $iPort
unset vfd3Data
unset vfdstruct
struct_new cap Layer3CaptureSetup
# Start capture
set cap(ulCaptureMode) $CAPTURE_MODE_FILTER_ON_EVENTS
set cap(ulCaptureLength) $CAPTURE_LENGTH_ENTIRE_FRAME
set cap(ulCaptureEvents) $CAPTURE_EVENTS_ALL_FRAMES
LIBCMD HTSetStructure $L3_CAPTURE_SETUP 0 0 0 cap 0 $iHub2 $iSlot2 $iPort2
LIBCMD HTSetCommand $L3_CAPTURE_START 0 0 0 0 $iHub2 $iSlot2 $iPort2
puts "Start capture"
unset cap
# send data
puts "Sending data"
LIBCMD HTRun $HTRUN $iHub $iSlot $iPort
after 1000
# Stop capture
LIBCMD HTSetCommand $L3_CAPTURE_STOP 0 0 0 0 $iHub2 $iSlot2 $iPort2
puts "Stop catpure"
struct_new cap_count Layer3CaptureCountInfo
struct_new packet Layer3CaptureData
# Get capture count
LIBCMD HTGetStructure $::L3_CAPTURE_COUNT_INFO 0 0 0 cap_count 0 $iHub2\
$iSlot2 $iPort2
puts "Capture count $cap_count(ulCount)"
# Display capture packets
puts "Display captured packets"
for {set index 0 } {$index < $cap_count(ulCount)} {incr index} {
puts "\nPacket $index\n"
LIBCMD HTGetStructure $L3_CAPTURE_PACKET_DATA_INFO $index 0 0 packet 0 $iHub2 $iSlot2 $iPort2
puts "Packet Length $packet(uiLength)\n"
# Display the packet
for {set i 0} {$i < $packet(uiLength)} {incr i} {
if {!($i % 16) && ($i != 0)} {
puts ""
}
set byte $packet(cData.$i._ubyte_)
puts -nonewline " [format %02X $byte] "
}
puts ""
}
unset cap_count
unset packet
puts "\n"
#UnLink from the chassis
puts "UnLinking from the chassis now..."
LIBCMD NSUnLink
puts "DONE!"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -