association_stats.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package sctp
  2. import (
  3. "sync/atomic"
  4. )
  5. type associationStats struct {
  6. nDATAs uint64
  7. nSACKs uint64
  8. nT3Timeouts uint64
  9. nAckTimeouts uint64
  10. nFastRetrans uint64
  11. }
  12. func (s *associationStats) incDATAs() {
  13. atomic.AddUint64(&s.nDATAs, 1)
  14. }
  15. func (s *associationStats) getNumDATAs() uint64 {
  16. return atomic.LoadUint64(&s.nDATAs)
  17. }
  18. func (s *associationStats) incSACKs() {
  19. atomic.AddUint64(&s.nSACKs, 1)
  20. }
  21. func (s *associationStats) getNumSACKs() uint64 {
  22. return atomic.LoadUint64(&s.nSACKs)
  23. }
  24. func (s *associationStats) incT3Timeouts() {
  25. atomic.AddUint64(&s.nT3Timeouts, 1)
  26. }
  27. func (s *associationStats) getNumT3Timeouts() uint64 {
  28. return atomic.LoadUint64(&s.nT3Timeouts)
  29. }
  30. func (s *associationStats) incAckTimeouts() {
  31. atomic.AddUint64(&s.nAckTimeouts, 1)
  32. }
  33. func (s *associationStats) getNumAckTimeouts() uint64 {
  34. return atomic.LoadUint64(&s.nAckTimeouts)
  35. }
  36. func (s *associationStats) incFastRetrans() {
  37. atomic.AddUint64(&s.nFastRetrans, 1)
  38. }
  39. func (s *associationStats) getNumFastRetrans() uint64 {
  40. return atomic.LoadUint64(&s.nFastRetrans)
  41. }
  42. func (s *associationStats) reset() {
  43. atomic.StoreUint64(&s.nDATAs, 0)
  44. atomic.StoreUint64(&s.nSACKs, 0)
  45. atomic.StoreUint64(&s.nT3Timeouts, 0)
  46. atomic.StoreUint64(&s.nAckTimeouts, 0)
  47. atomic.StoreUint64(&s.nFastRetrans, 0)
  48. }