Printer FriendlyEmail Article Link

How to create a Spirent TestCenter streamblock with GTP header plus Custom header using TCL API?

Answer

 

Requirement to create a streamblock with the following PDU header Stack

 

Sample TCL code:
# Create a stream block.
 set hStreamBlock [stc::create streamBlock -under $hPortTx -insertSig true \
               -frameConfig "" -frameLengthMode FIXED -maxFrameLength 1200 -FixedFrameLength 128]
 
# Add an EthernetII Protocol Data Unit (PDU).
set hEthernet [stc::create ethernet:EthernetII -under $hStreamBlock -name sb1_eth  \
                             -srcMac  00:00:20:00:00:00 \
                                -dstMac 00:00:00:00:00:40]
 
# Create a VLAN container  
 set hVlanContainer [stc::create vlans -under $hEthernet]
 
# Create Vlan 1
 stc::create Vlan -under $hVlanContainer -pri 000 -cfi 0 -id 100 -type 0x88a8
# Create Vlan 2
 stc::create Vlan -under $hVlanContainer -pri 000 -cfi 0 -id 101
 
# Create Inner IP header
 stc::create ipv4:IPv4 -under $hStreamBlock -name sb1_ipv4 -destAddr 1.1.1.1 \
                                                               -sourceAddr 2.2.2.2 -checksum 0x3333
 
# Create UDP Header
 stc::create udp:Udp -under $hStreamBlock -name sb1_udp -destPort 1000 \
                                                               -sourcePort 2000 -checksum 0x1000
 
# Create a GTP header
 set gtphdr [stc::create gtpv1:GTPv1 -under $hStreamBlock -protcol GTP -version 1 -teid 0 -name sb1_gtp ]
 
 
# Create a Modifier for the TEID
 set RangeModifierCSRC [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask \
        -StepValue \
        -RecycleCount "10" \
        -OffsetReference \
        -Name \
        -EnableStream true]
 
# Create a Cusom header 1
 set hCustom1 [stc::create custom:Custom -under $hStreamBlock -pattern "0000" -name Custom1]
 
# Add a modifier for the Customer Header Byte Pattern
 set RangeModifier_custom1 [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask \
        -StepValue \
        -RecycleCount "10" \
        -Data \
        -OffsetReference \
        -Name ]
 
# Create a Custom header 2
 set hCustom2 [stc::create custom:Custom -under $hStreamBlock -pattern "0000" -name Custom2]
 
# Create Outer IP Header
 stc::create ipv4:IPv4 -under $hStreamBlock -name sb2_ipv4 \
                                               – destAddr 3.3.3.3 \
                                   -sourceAddr 4.4.4.4 -checksum 0x4444
 
 # Create Modifier for the Soure IP address
 set RangeModifier(3) [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask {255.255.255.255} \
        -StepValue {0.0.0.1} \
        -RecycleCount "10" \
        -Data {4.4.4.4} \
        -OffsetReference ]
 
 
 
stc::apply
# Save the configuration into .tcc and verify using the GUI.
stc::perform savetotcc -filename GTP.tcc
Sample TCL code:
# Create a stream block.
 set hStreamBlock [stc::create streamBlock -under $hPortTx -insertSig true \
               -frameConfig "" -frameLengthMode FIXED -maxFrameLength 1200 -FixedFrameLength 128]
 
# Add an EthernetII Protocol Data Unit (PDU).
set hEthernet [stc::create ethernet:EthernetII -under $hStreamBlock -name sb1_eth  \
                             -srcMac  00:00:20:00:00:00 \
                                -dstMac 00:00:00:00:00:40]
 
# Create a VLAN container  
 set hVlanContainer [stc::create vlans -under $hEthernet]
 
# Create Vlan 1
 stc::create Vlan -under $hVlanContainer -pri 000 -cfi 0 -id 100 -type 0x88a8
# Create Vlan 2
 stc::create Vlan -under $hVlanContainer -pri 000 -cfi 0 -id 101
 
# Create Inner IP header
 stc::create ipv4:IPv4 -under $hStreamBlock -name sb1_ipv4 -destAddr 1.1.1.1 \
                                                               -sourceAddr 2.2.2.2 -checksum 0x3333
 
# Create UDP Header
 stc::create udp:Udp -under $hStreamBlock -name sb1_udp -destPort 1000 \
                                                               -sourcePort 2000 -checksum 0x1000
 
# Create a GTP header
 set gtphdr [stc::create gtpv1:GTPv1 -under $hStreamBlock -protcol GTP -version 1 -teid 0 -name sb1_gtp ]
 
 
# Create a Modifier for the TEID
 set RangeModifierCSRC [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask \
        -StepValue \
        -RecycleCount "10" \
        -OffsetReference \
        -Name \
        -EnableStream true]
 
# Create a Cusom header 1
 set hCustom1 [stc::create custom:Custom -under $hStreamBlock -pattern "0000" -name Custom1]
 
# Add a modifier for the Customer Header Byte Pattern
 set RangeModifier_custom1 [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask \
        -StepValue \
        -RecycleCount "10" \
        -Data \
        -OffsetReference \
        -Name ]
 
# Create a Custom header 2
 set hCustom2 [stc::create custom:Custom -under $hStreamBlock -pattern "0000" -name Custom2]
 
# Create Outer IP Header
 stc::create ipv4:IPv4 -under $hStreamBlock -name sb2_ipv4 \
                                               – destAddr 3.3.3.3 \
                                   -sourceAddr 4.4.4.4 -checksum 0x4444
 
 # Create Modifier for the Soure IP address
 set RangeModifier(3) [stc::create "RangeModifier" \
        -under $hStreamBlock \
        -Mask {255.255.255.255} \
        -StepValue {0.0.0.1} \
        -RecycleCount "10" \
        -Data {4.4.4.4} \
        -OffsetReference ]
 
 
 
stc::apply
# Save the configuration into .tcc and verify using the GUI.
stc::perform savetotcc -filename GTP.tcc

Product : Spirent TestCenter,L2-3,Automation,API