Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only getting one "Traffic Item Statistics" when I have multiple traffic items #79

Open
assadniang opened this issue Nov 29, 2023 · 0 comments

Comments

@assadniang
Copy link

Hello,

IxNetwork 9.20
Python3
ixnetwork-restpy==1.1.11

I have a IxNetwork config file with 2 traffic items configured, from the GUI I am able to get the stats from both traffic items in the "Traffic Item Statistics"

With the following code, I am only able to get the "Traffic Item Statistic" from only one traffic item
When I print the "Traffic Item Statistics", I only see 1 of the 2 traffic items:

Code:

"""This script demonstrates how to get started with ixnetwork_restpy scripting.

The script demonstrates the following:
    - connect to an IxNetwork test platform, authenticate, add a new session and clear the config
    - create 1 tx port and 1 rx port
    - create traffic from the tx port to the rx port
    - start traffic
    - print statistics
    - stop traffic 
"""
import os, sys, traceback
from pprint import pprint
import time, re
from ixnetwork_restpy import SessionAssistant, Files, StatViewAssistant


#  local_file=False 
#       config file is on ixNet API Server machine,
#       It must be stored under  'C:\\Users\\<user name>\\AppData\\Local\\Ixia\\sdmStreamManager\\common\\' dir
#  local_file=True
#       config file is on the script machine

#configFile = r"C:\\Users\\an144a\\Documents\\Ixia\\IxNetwork\\Repository\\Cisco-SDWAN Flexware Performance Test-noHW.ixncfg"
#configFile = r'C:\\Users\\an144a\\AppData\\Local\\Ixiay\\Cisco-SDWAN Flexware Performance Test-noHW.ixncfg'
#configFile = r'C:/Users/an144a/AppData/Local/Ixiay/cisco_sdwan_automation.ixncfg'
configFile = r'C:/Users/an144a/AppData/Local/Ixia/sdmStreamManager/common/cisco_sdwan_automation_api.ixncfg'



#The script will configure following Ixia chassis 
ixChassisIpList = ['135.16.178.57']

# IP - CARD - PORT
portList = [[ixChassisIpList[0], 5,5], [ixChassisIpList[0], 5, 6]]

# Forcefully take port ownership if the portList are owned by other users.
forceTakePortOwnership = True

# For linux and connection_manager only. Set to True to leave the session alive for debugging.
debugMode = False

try:

    # create a test tool session
    session_assistant = SessionAssistant(IpAddress='172.30.7.215', IgnoreEnvProxy=True,  LogLevel=SessionAssistant.LOGLEVEL_INFO, ClearConfig=False)

    ixnetwork = session_assistant.Ixnetwork

    ixnetwork.info('Loading config file: {0}'.format(configFile))
    ixnetwork.LoadConfig(Files(configFile, local_file=True))

    # Assign ports
    testPorts = []
    vportList = [vport.href for vport in ixnetwork.Vport.find()]
    for port in portList:
        testPorts.append(dict(Arg1=port[0], Arg2=port[1], Arg3=port[2]))

    ixnetwork.AssignPorts(testPorts, [], vportList, forceTakePortOwnership)

    # create tx and rx port resources
    #port_map = session_assistant.PortMapAssistant()
    #port_map.Map('135.16.178.57', 2, 3, Name='10GE LAN - Flex SDWAN')
    #port_map.Map('135.16.178.57', 2, 4, Name='10GE LAN - C8500X')

    # finding all the traffic items in our config
    traffic_items = ixnetwork.Traffic.TrafficItem.find()
    print(traffic_items)
    ixnetwork.StartAllProtocols(Arg1='sync')
    time.sleep(20)
    
    # push ConfigElement settings down to HighLevelStream resources
    traffic_items.Generate()

    ixnetwork.info('Apply config')
    ixnetwork.Traffic.Apply()
    
    ixnetwork.info('Starting traffic')
    ixnetwork.Traffic.StartStatelessTrafficBlocking()

    # StatViewAssistant could also filter by regex, LESS_THAN, GREATER_THAN, EQUAL. 
    # Examples:
    #    flowStatistics.AddRowFilter('Port Name', StatViewAssistant.REGEX, '^Port 1$')
    #    flowStatistics.AddRowFilter('Tx Frames', StatViewAssistant.LESS_THAN, 50000)
    time.sleep(30)
    trafficItemStatistics = StatViewAssistant(ixnetwork, 'Traffic Item Statistics')
    print(trafficItemStatistics)
    # Get the statistic values
    #txFrames = trafficItemStatistics.Rows[0]['Tx Frames']
    #rxFrames = trafficItemStatistics.Rows[0]['Rx Frames']
    #ixnetwork.info('\nTraffic Item Stats:\n\tTxFrames: {}  RxFrames: {}\n'.format(txFrames, rxFrames))

    time.sleep(30)
    #ixnetwork.info('{}\n'.format(trafficItemStatistics))
    for rowNumber,trafStat in enumerate(trafficItemStatistics.Rows):
        #ixnetwork.info('\n\nSTATS: {}\n\n'.format(trafStat))
        ixnetwork.info('\n\nRow:{}  Traffic Item:{}  Tx Frames:{}  Rx Frames:{}  Loss %:{}  \n'.format(rowNumber, trafStat['Traffic Item'], trafStat['Tx Frames'], trafStat['Rx Frames'], trafStat['Loss %']))


    # print statistics
    #print(session_assistant.StatViewAssistant('Port Statistics'))
    #print(session_assistant.StatViewAssistant('Traffic Item Statistics'))
    #print(session_assistant.StatViewAssistant('Flow Statistics'))

    # stop traffic
    ixnetwork.Traffic.StopStatelessTrafficBlocking()
    ixnetwork.StopAllProtocols(Arg1='sync')
    
    #portMap.Disconnect()
    if debugMode == False:
        # For linux and connection_manager only
        session_assistant.Session.remove()

except Exception as errMsg:
    print('\n%s' % traceback.format_exc(None, errMsg))
    if debugMode == False and 'session' in locals():
        session_assistant.Session.remove()

Output:

As you can see only 1 traffic item statistic is outputed, while I have 2

[an144a@mtlab-auto ixia]$ python3 cisco_sdwan_perf.py 
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] using python version 3.8.17 (default, Aug 10 2023, 15:47:44) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-20)]
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] using ixnetwork-restpy version 1.1.11
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [WARNING] Verification of certificates is disabled
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Determining the platform and rest_port using the 172.30.7.215 address...
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [WARNING] Unable to connect to http://172.30.7.215:11009.
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Connection established to `https://172.30.7.215:11009 on windows`
2023-11-29 10:28:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Using IxNetwork api server version 9.20.2112.6
2023-11-29 10:28:45 [ixnetwork_restpy.connection tid:139856911769856] [INFO] User info IxNetwork/MTLAB-DELL-T340/an144a.13832
2023-11-29 10:28:45 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Loading config file: C:/Users/an144a/AppData/Local/Ixia/sdmStreamManager/common/cisco_sdwan_automation_api.ixncfg
TrafficItem[0]: /api/v1/sessions/1/ixnetwork/traffic/trafficItem/15
        AllowSelfDestined: False
        BgpEpeOrdinalValue: 0
        BgpEpeSidType: nodeSID
        BiDirectional: False
        EgressEnabled: False
        EnableDynamicMplsLabelValues: False
        EnableMacsecEgressOnlyAutoConfig: True
        Enabled: True
        Errors: []
        EvpnNextHopOrdinalValue: 0
        FlowGroupCount: 10
        FrerDuplicateElimination: False
        HasOpenFlow: False
        HostsPerNetwork: 1
        InterAsBgpPreference: one
        InterAsLdpPreference: two
        LabelPreferences: []
        MaxNumberOfVpnLabelStack: 2
        MergeDestinations: True
        MulticastForwardingMode: replication
        Name: Site10 --> Site40
        NumVlansForMulticastReplication: 1
        OrdinalNo: 0
        OriginatorType: endUser
        RawTrafficRxPortsBehavior: replicated
        RegenerateCount: 0
        RoundRobinPacketOrdering: False
        RouteMesh: oneToOne
        SrcDestMesh: oneToOne
        State: unapplied
        Suspend: False
        TrafficItemType: l2L3
        TrafficType: ipv4
        TransmitMode: interleaved
        TransportLdpPreference: two
        TransportRsvpTePreference: one
        UseControlPlaneFrameSize: True
        UseControlPlaneRate: True
        Warnings: []
TrafficItem[1]: /api/v1/sessions/1/ixnetwork/traffic/trafficItem/16
        AllowSelfDestined: False
        BgpEpeOrdinalValue: 0
        BgpEpeSidType: nodeSID
        BiDirectional: False
        EgressEnabled: False
        EnableDynamicMplsLabelValues: False
        EnableMacsecEgressOnlyAutoConfig: True
        Enabled: True
        Errors: []
        EvpnNextHopOrdinalValue: 0
        FlowGroupCount: 10
        FrerDuplicateElimination: False
        HasOpenFlow: False
        HostsPerNetwork: 1
        InterAsBgpPreference: one
        InterAsLdpPreference: two
        LabelPreferences: []
        MaxNumberOfVpnLabelStack: 2
        MergeDestinations: True
        MulticastForwardingMode: replication
        Name: Site40 --> Site10
        NumVlansForMulticastReplication: 1
        OrdinalNo: 0
        OriginatorType: endUser
        RawTrafficRxPortsBehavior: replicated
        RegenerateCount: 0
        RoundRobinPacketOrdering: False
        RouteMesh: oneToOne
        SrcDestMesh: oneToOne
        State: unapplied
        Suspend: False
        TrafficItemType: l2L3
        TrafficType: ipv4
        TransmitMode: interleaved
        TransportLdpPreference: two
        TransportRsvpTePreference: one
        UseControlPlaneFrameSize: True
        UseControlPlaneRate: True
        Warnings: []
2023-11-29 10:29:35 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Apply config
2023-11-29 10:29:37 [ixnetwork_restpy.connection tid:139856911769856] [INFO] Starting traffic
Row:0  View:Traffic Item Statistics  Sampled:2023-11-29 10:30:14.288122 UTC
        Traffic Item: Site40 --> Site10
        Tx Frames: 46920
        Rx Frames: 46920
        Frames Delta: 0
        Loss %: 0.000
        Tx Frame Rate: 1680.000
        Rx Frame Rate: 1680.000
        Tx L1 Rate (bps): 10283480.000
        Rx L1 Rate (bps): 10399920.000
        Rx Bytes: 34968488
        Tx Rate (Bps): 1251835.000
        Rx Rate (Bps): 1266390.000
        Tx Rate (bps): 10014680.000
        Rx Rate (bps): 10131120.000
        Tx Rate (Kbps): 10014.680
        Rx Rate (Kbps): 10131.120
        Tx Rate (Mbps): 10.015
        Rx Rate (Mbps): 10.131
        Store-Forward Avg Latency (ns): 834033
        Store-Forward Min Latency (ns): 331780
        Store-Forward Max Latency (ns): 14406440
        First TimeStamp: 00:00:00.403
        Last TimeStamp: 00:00:28.366
2023-11-29 10:30:44 [ixnetwork_restpy.connection tid:139856911769856] [INFO] 

Row:0  Traffic Item:Site40 --> Site10  Tx Frames:97250  Rx Frames:97250  Loss %:0.000  

[an144a@mtlab-auto ixia]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant