OpenIxia / IxNetwork

A central location for IxNetwork sample scripts and utilities. Please also visit http://openixia.com
MIT License
50 stars 59 forks source link

What does the magical number 11 mean? #111

Closed wenijinew closed 3 years ago

wenijinew commented 4 years ago

Hi,

In below line, it used 11. What does 11 mean here? And how to get API document of getPacketFromDataCapture to know how to use it? https://github.com/OpenIxia/IxNetwork/blob/bf23803e95ae66f49b4d2252b3d938818e48f540/LowLevelApi/NGPF/Tcl/Capture/Sample_Capture_SearchInsidePacket.tcl#L298

I tried to use the same code to check captured packets and got exception: (Not sure if it's caused by 11) ERROR: ::ixNet::ERROR-Packet index is greater than packet count

therkong commented 4 years ago

The 11 means the 11th packet from the capture buffer. After the call, 11th packet of the capture will be represented by currentPkt object. The best document that explains the ixNet low level api can be access from ixNetwork API Windows GUI from the Help-> API Help->Low Level API Guide. p157 of the pdf document has the capture info. If you don't have ixNet API Windows version, just let me know. I can send you the doc via ftp.

wenijinew commented 4 years ago

@therkong I have the LL API Guide. Why does it use 11th rather than other packet? Is it possible that it has no 11th packet captured? What's the 11th packet? Is the 11th packet consistent for all traffic? And I think the below line is used to set currentPkt: https://github.com/OpenIxia/IxNetwork/blob/bf23803e95ae66f49b4d2252b3d938818e48f540/LowLevelApi/NGPF/Tcl/Capture/Sample_Capture_SearchInsidePacket.tcl#L297

therkong commented 4 years ago

11 is just an example. It makes more sense if the example shows packet 1 instead of 11. [ixNet getAttr $captureObj2 -dataPacketCounter] returns the number of data packets in the capture buffer. You should do a for loop. See example below:

set numPackets [ixNet getAttr $vPort1/capture -dataPacketCounter]

for {set i 0} {$i < $numPackets} {incr i} { set status [ixNet exec getPacketFromDataCapture $currentPkt $i]

foreach pktStack [ixNet getList $currentPkt stack] {
    puts "********Display Stack Name:: [ixNet getAttr $pktStack -displayName]"

    foreach pktStackField [ixNet getList $pktStack field] {
        puts "Field Name:[ixNet getAttr $pktStackField -displayName] - Field Value: [ixNet getAttr $pktStackField -fieldValue]"
    }
}

}

wenijinew commented 4 years ago

https://github.com/OpenIxia/IxNetwork/blob/bf23803e95ae66f49b4d2252b3d938818e48f540/LowLevelApi/NGPF/Tcl/Capture/Sample_Capture_SearchInsidePacket.tcl#L297 The index above is 0. Is it possible to have more than one item in the list returned by ixNet getList $captureObj2 currentPacket ?

therkong commented 4 years ago

It should be always just one item in the list. It is pointer to the currentPacket. "ixNet exec getPacketFromDataCapture $currentPkt " $i" brings the i'th packet to $currentPkt.