Skip to content

Commit

Permalink
Updating script to send 10M+ packets to have consistency with the sample
Browse files Browse the repository at this point in the history
generation.

"This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia's intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind."
  • Loading branch information
trathod1 committed Oct 17, 2024
1 parent b03aa93 commit 56daa57
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions feature/sflow/otg_tests/sflow_base_test/sflow_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ var (
flowConfigs = []flowConfig{
{
name: "flowS",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 64,
},
{
name: "flowM",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 512,
},
{
name: "flowL",
packetsToSend: 1000000,
ppsRate: 100000,
packetsToSend: 10000000,
ppsRate: 300000,
frameSize: 1500,
},
}
Expand Down Expand Up @@ -385,7 +385,6 @@ func createFlow(t *testing.T, ate *ondatra.ATEDevice, config gosnappi.Config, fc
flow.Metrics().SetEnable(true)
flow.Size().SetFixed(fc.frameSize)
flow.Rate().SetPps(fc.ppsRate)
flow.Duration().FixedPackets().SetPackets(fc.packetsToSend)
e1 := flow.Packet().Add().Ethernet()
e1.Src().SetValues([]string{ateSrc.MAC})

Expand Down Expand Up @@ -425,6 +424,7 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {

found := false
packetCount := 0
sampleCount := 0
sflowSamples := uint32(0)
for packet := range packetSource.Packets() {
if ipLayer := packet.Layer(layers.LayerTypeIPv4); ipLayer != nil {
Expand All @@ -433,7 +433,7 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {
t.Logf("tos %d, payload %d, content %d, length %d", ipv4.TOS, len(ipv4.Payload), len(ipv4.Contents), ipv4.Length)
if ipv4.TOS == 32 {
found = true
break
sampleCount++
}
}
} else if ipLayer := packet.Layer(layers.LayerTypeIPv6); ipLayer != nil {
Expand All @@ -442,16 +442,19 @@ func validatePackets(t *testing.T, filename string, ip IPType, fc flowConfig) {
t.Logf("tos %d, payload %d, content %d, length %d", ipv6.TrafficClass, len(ipv6.Payload), len(ipv6.Contents), ipv6.Length)
if ipv6.TrafficClass == 32 {
found = true
break
sampleCount++
}
}
}

}
if !found {
t.Error("sflow packets not found")
t.Logf("SFlow samples captured: %v", sampleCount)
if !found || sampleCount < 9 {
t.Errorf("sflow packets not found: got %v, want 9", sampleCount)
}

handle, _ = pcap.OpenOffline(filename)
packetSource = gopacket.NewPacketSource(handle, handle.LinkType())
for packet := range packetSource.Packets() {
if sflowLayer := packet.Layer(layers.LayerTypeSFlow); sflowLayer != nil {
sflow := sflowLayer.(*layers.SFlowDatagram)
Expand Down

0 comments on commit 56daa57

Please sign in to comment.