Compare commits

...

2 Commits

Author SHA1 Message Date
Johannes Kimmel 199ff0f756 fix high buffer usage reporting 2023-08-23 21:24:57 +02:00
Johannes Kimmel a9cfa381af make use of -buffer option 2023-08-23 21:24:47 +02:00
1 changed files with 6 additions and 9 deletions

15
main.go
View File

@ -17,7 +17,6 @@ import (
)
const (
NUM_MSGS = 64
NUM_BUFFERS = 1
)
@ -55,9 +54,8 @@ func (vx *vx46) transform46(msgs4 []ipv4.Message, msgs6 []ipv6.Message) error {
}
func (vx *vx46) forward46() error {
//msgs4, msgs6 := prepareMsgs(vx.mtu)
msgs4 := [NUM_MSGS]ipv4.Message{}
msgs6 := [NUM_MSGS]ipv6.Message{}
msgs4 := make([]ipv4.Message, vx.buffers)
msgs6 := make([]ipv6.Message, vx.buffers)
for i := range msgs6 {
msgs4[i].Buffers = [][]byte{make([]byte, vx.mtu)}
@ -66,7 +64,7 @@ func (vx *vx46) forward46() error {
for {
n, err := vx.pc4.ReadBatch(msgs4[:], 0)
if n > NUM_MSGS*4/3 {
if n > vx.buffers*3/4 {
log.Printf("forward46: %d in", n)
}
if err != nil {
@ -114,9 +112,8 @@ func (vx *vx46) transform64(msgs6 []ipv6.Message, msgs4 []ipv4.Message) error {
}
func (vx *vx46) forward64() error {
//msgs4, msgs6 := prepareMsgs(vx.mtu)
msgs4 := [NUM_MSGS]ipv4.Message{}
msgs6 := [NUM_MSGS]ipv6.Message{}
msgs4 := make([]ipv4.Message, vx.buffers)
msgs6 := make([]ipv6.Message, vx.buffers)
for i := range msgs6 {
msgs6[i].Buffers = [][]byte{make([]byte, vx.mtu)}
@ -126,7 +123,7 @@ func (vx *vx46) forward64() error {
for {
n, err := vx.pc6.ReadBatch(msgs6[:], 0)
if n > NUM_MSGS*4/3 {
if n > vx.buffers*3/4 {
log.Printf("forward64: %d in", n)
}
if err != nil {