Debian Codegraph @

association_stats.go

raw
1 // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
2 // SPDX-License-Identifier: MIT
3
4 package sctp
5
6 import (
7 "sync/atomic"
8 )
9
10 type associationStats struct {
11 nPacketsReceived uint64
12 nPacketsSent uint64
13 nDATAs uint64
14 nSACKsReceived uint64
15 nSACKsSent uint64
16 nT3Timeouts uint64
17 nAckTimeouts uint64
18 nFastRetrans uint64
19 }
20
21 func (s *associationStats) incPacketsReceived() {
22 atomic.AddUint64(&s.nPacketsReceived, 1)
23 }
24
25 func (s *associationStats) getNumPacketsReceived() uint64 {
26 return atomic.LoadUint64(&s.nPacketsReceived)
27 }
28
29 func (s *associationStats) incPacketsSent() {
30 atomic.AddUint64(&s.nPacketsSent, 1)
31 }
32
33 func (s *associationStats) getNumPacketsSent() uint64 {
34 return atomic.LoadUint64(&s.nPacketsSent)
35 }
36
37 func (s *associationStats) incDATAs() {
38 atomic.AddUint64(&s.nDATAs, 1)
39 }
40
41 func (s *associationStats) getNumDATAs() uint64 {
42 return atomic.LoadUint64(&s.nDATAs)
43 }
44
45 func (s *associationStats) incSACKsReceived() {
46 atomic.AddUint64(&s.nSACKsReceived, 1)
47 }
48
49 func (s *associationStats) getNumSACKsReceived() uint64 {
50 return atomic.LoadUint64(&s.nSACKsReceived)
51 }
52
53 func (s *associationStats) incSACKsSent() {
54 atomic.AddUint64(&s.nSACKsSent, 1)
55 }
56
57 func (s *associationStats) getNumSACKsSent() uint64 {
58 return atomic.LoadUint64(&s.nSACKsSent)
59 }
60
61 func (s *associationStats) incT3Timeouts() {
62 atomic.AddUint64(&s.nT3Timeouts, 1)
63 }
64
65 func (s *associationStats) getNumT3Timeouts() uint64 {
66 return atomic.LoadUint64(&s.nT3Timeouts)
67 }
68
69 func (s *associationStats) incAckTimeouts() {
70 atomic.AddUint64(&s.nAckTimeouts, 1)
71 }
72
73 func (s *associationStats) getNumAckTimeouts() uint64 {
74 return atomic.LoadUint64(&s.nAckTimeouts)
75 }
76
77 func (s *associationStats) incFastRetrans() {
78 atomic.AddUint64(&s.nFastRetrans, 1)
79 }
80
81 func (s *associationStats) getNumFastRetrans() uint64 {
82 return atomic.LoadUint64(&s.nFastRetrans)
83 }
84
85 func (s *associationStats) reset() {
86 atomic.StoreUint64(&s.nPacketsReceived, 0)
87 atomic.StoreUint64(&s.nPacketsSent, 0)
88 atomic.StoreUint64(&s.nDATAs, 0)
89 atomic.StoreUint64(&s.nSACKsReceived, 0)
90 atomic.StoreUint64(&s.nSACKsSent, 0)
91 atomic.StoreUint64(&s.nT3Timeouts, 0)
92 atomic.StoreUint64(&s.nAckTimeouts, 0)
93 atomic.StoreUint64(&s.nFastRetrans, 0)
94 }