]> Cypherpunks.ru repositories - govpn.git/blob - cpr.go
Ability to generate Constant Packet Rate traffic
[govpn.git] / cpr.go
1 package govpn
2
3 import (
4         "net"
5         "time"
6 )
7
8 type UDPCPR net.UDPConn
9
10 var (
11         cprCycle  time.Duration
12         cprEnable bool = false
13 )
14
15 // Initialize Constant Packet Rate. rate is KiB/s.
16 func CPRInit(rate int) {
17         if rate <= 0 {
18                 return
19         }
20         NoiseEnable = true
21         cprEnable = true
22         cprCycle = time.Second / time.Duration(rate*(1<<10)/MTU)
23         heartbeatPeriod = cprCycle
24 }