Skip to content

Commit 5da0943

Browse files
authored
Merge pull request #564 from intel-go/gregory/counters
Implemented send/receive statistic counters for #390
2 parents fd9230c + 590bb19 commit 5da0943

File tree

7 files changed

+720
-66
lines changed

7 files changed

+720
-66
lines changed

common/common.go

+6
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,9 @@ func dropInvalidCPUs(nums []int, maxcpu int) []int {
9797
}
9898
return nums[:i]
9999
}
100+
101+
// RXTXStats describes statistics for sender or receiver flow function
102+
// node.
103+
type RXTXStats struct {
104+
PacketsProcessed, PacketsDropped, BytesProcessed uint64
105+
}

examples/forwarding/forwarding.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// Copyright 2017 Intel Corporation.
1+
// Copyright 2017-2019 Intel Corporation.
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

55
package main
66

77
import (
8+
"flag"
9+
"net"
10+
811
"github.com/intel-go/nff-go/flow"
912
"github.com/intel-go/nff-go/packet"
1013
)
@@ -13,10 +16,23 @@ var l3Rules *packet.L3Rules
1316

1417
// Main function for constructing packet processing graph.
1518
func main() {
19+
inport := flag.Uint("inport", 0, "Port for receiving packets.")
20+
numflows := flag.Uint("numflows", 5, "Number of output flows to use. First flow with number zero is used for dropped packets.")
21+
nostats := flag.Bool("nostats", false, "Disable statics HTTP server.")
22+
flag.Parse()
23+
1624
var err error
25+
var statsServerAddres *net.TCPAddr = nil
26+
if !*nostats {
27+
// Set up address for stats web server
28+
statsServerAddres = &net.TCPAddr{
29+
Port: 8080,
30+
}
31+
}
32+
1733
// Initialize NFF-GO library at 16 cores by default
1834
config := flow.Config{
19-
CPUList: "0-15",
35+
StatsHTTPAddress: statsServerAddres,
2036
}
2137
flow.CheckFatal(flow.SystemInit(&config))
2238

@@ -25,11 +41,11 @@ func main() {
2541
flow.CheckFatal(err)
2642

2743
// Receive packets from zero port. Receive queue will be added automatically.
28-
inputFlow, err := flow.SetReceiver(0)
44+
inputFlow, err := flow.SetReceiver(uint16(*inport))
2945
flow.CheckFatal(err)
3046

3147
// Split packet flow based on ACL.
32-
flowsNumber := uint16(5)
48+
flowsNumber := uint16(*numflows)
3349
outputFlows, err := flow.SetSplitter(inputFlow, l3Splitter, uint(flowsNumber), nil)
3450
flow.CheckFatal(err)
3551

0 commit comments

Comments
 (0)