-
Notifications
You must be signed in to change notification settings - Fork 1
/
path.go
61 lines (52 loc) · 1.14 KB
/
path.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package minq
import "net"
type Path struct {
connection *Connection
isPathZero bool
transport Transport
pathID uint32
weight int
owd uint64
local *net.UDPAddr
remote *net.UDPAddr
}
func NewPath(connection *Connection, transport Transport, pathId uint32, local, remote *net.UDPAddr, weight int) *Path {
return &Path{
connection,
false,
transport,
pathId,
weight,
0,
local,
local,
}
}
// Send a ping Frame, evaluate the RTT in relation to pathZero
/*
func (p *Path) updateMetric(referenceRTT uint16) uint16 {
frames := make([]frame, 1)
f := newPingFrame()
frames[0] = f
p.connection.sendFramesInPacket(0, frames)
p.connection.send
b := make([]byte, 1024)
p.connection.streams[0].Read(b)
return owd
}
*/
func (p *Path) GetWeight() int {
return p.weight
}
func (p *Path) GetPathID() uint32 {
return p.pathID
}
func (p *Path) setOwd(owd int64) {
p.owd = uint64(owd)
}
func (p *Path) String() string {
return "local: " + p.local.String() + " " + "remote: " + p.remote.String()
}
func (p *Path) contains(address string) bool {
return (p.local.String() == address || p.remote.String() == address)
}