Coverage for aiocoap/numbers/constants.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

26 statements  

1# This file is part of the Python aiocoap library project. 

2# 

3# Copyright (c) 2012-2014 Maciej Wasilak <http://sixpinetrees.blogspot.com/>, 

4# 2013-2014 Christian Amsüss <c.amsuess@energyharvesting.at> 

5# 

6# aiocoap is free software, this file is published under the MIT license as 

7# described in the accompanying LICENSE file. 

8 

9"""Constants either defined in the CoAP protocol (often default values for lack 

10of ways to determine eg. the estimated round trip time). Some parameters are 

11invented here for practical purposes of the implementation (eg. 

12DEFAULT_BLOCK_SIZE_EXP, EMPTY_ACK_DELAY).""" 

13 

14COAP_PORT = 5683 

15"""The IANA-assigned standard port for COAP services.""" 

16 

17COAPS_PORT = 5684 

18 

19MCAST_IPV4_ALLCOAPNODES = "224.0.1.187" 

20MCAST_IPV6_LINKLOCAL_ALLNODES = "ff02::1" 

21MCAST_IPV6_LINKLOCAL_ALLCOAPNODES = "ff02::fd" 

22MCAST_IPV6_SITELOCAL_ALLNODES = "ff05::1" 

23MCAST_IPV6_SITELOCAL_ALLCOAPNODES = "ff05::fd" 

24MCAST_ALL = ( 

25 MCAST_IPV4_ALLCOAPNODES, 

26 MCAST_IPV6_LINKLOCAL_ALLNODES, 

27 MCAST_IPV6_LINKLOCAL_ALLCOAPNODES, 

28 MCAST_IPV6_SITELOCAL_ALLNODES, 

29 MCAST_IPV6_SITELOCAL_ALLCOAPNODES, 

30 ) 

31 

32# +-------------------+---------------+ 

33# | name | default value | 

34# +-------------------+---------------+ 

35# | ACK_TIMEOUT | 2 seconds | 

36# | ACK_RANDOM_FACTOR | 1.5 | 

37# | MAX_RETRANSMIT | 4 | 

38# | NSTART | 1 | 

39# | DEFAULT_LEISURE | 5 seconds | 

40# | PROBING_RATE | 1 Byte/second | 

41# +-------------------+---------------+ 

42 

43ACK_TIMEOUT = 2.0 

44"""The time, in seconds, to wait for an acknowledgement of a 

45confirmable message. The inter-transmission time doubles 

46for each retransmission.""" 

47 

48ACK_RANDOM_FACTOR = 1.5 

49"""Timeout multiplier for anti-synchronization.""" 

50 

51MAX_RETRANSMIT = 4 

52"""The number of retransmissions of confirmable messages to 

53non-multicast endpoints before the infrastructure assumes no 

54acknowledgement will be received.""" 

55 

56NSTART = 1 

57"""Maximum number of simultaneous outstanding interactions 

58 that endpoint maintains to a given server (including proxies)""" 

59 

60# +-------------------+---------------+ 

61# | name | default value | 

62# +-------------------+---------------+ 

63# | MAX_TRANSMIT_SPAN | 45 s | 

64# | MAX_TRANSMIT_WAIT | 93 s | 

65# | MAX_LATENCY | 100 s | 

66# | PROCESSING_DELAY | 2 s | 

67# | MAX_RTT | 202 s | 

68# | EXCHANGE_LIFETIME | 247 s | 

69# | NON_LIFETIME | 145 s | 

70# +-------------------+---------------+ 

71 

72MAX_TRANSMIT_SPAN = ACK_TIMEOUT * (2 ** MAX_RETRANSMIT - 1) * ACK_RANDOM_FACTOR 

73"""Maximum time from the first transmission 

74of a confirmable message to its last retransmission.""" 

75 

76MAX_TRANSMIT_WAIT = ACK_TIMEOUT * (2 ** (MAX_RETRANSMIT + 1) - 1) * ACK_RANDOM_FACTOR 

77"""Maximum time from the first transmission 

78of a confirmable message to the time when the sender gives up on 

79receiving an acknowledgement or reset.""" 

80 

81MAX_LATENCY = 100.0 

82"""Maximum time a datagram is expected to take from the start 

83of its transmission to the completion of its reception.""" 

84 

85PROCESSING_DELAY = ACK_TIMEOUT 

86""""Time a node takes to turn around a 

87confirmable message into an acknowledgement.""" 

88 

89MAX_RTT = 2 * MAX_LATENCY + PROCESSING_DELAY 

90"""Maximum round-trip time.""" 

91 

92EXCHANGE_LIFETIME = MAX_TRANSMIT_SPAN + MAX_RTT 

93"""time from starting to send a confirmable message to the time when an 

94acknowledgement is no longer expected, i.e. message layer information about the 

95message exchange can be purged""" 

96 

97DEFAULT_BLOCK_SIZE_EXP = 6 # maximum block size 1024 

98"""Default size exponent for blockwise transfers.""" 

99 

100EMPTY_ACK_DELAY = 0.1 

101"""After this time protocol sends empty ACK, and separate response""" 

102 

103REQUEST_TIMEOUT = MAX_TRANSMIT_WAIT 

104"""Time after which server assumes it won't receive any answer. 

105 It is not defined by IETF documents. 

106 For human-operated devices it might be preferable to set some small value 

107 (for example 10 seconds) 

108 For M2M it's application dependent.""" 

109 

110DEFAULT_LEISURE = 5 

111 

112MULTICAST_REQUEST_TIMEOUT = REQUEST_TIMEOUT + DEFAULT_LEISURE 

113 

114OBSERVATION_RESET_TIME = 128 

115"""Time in seconds after which the value of the observe field are ignored. 

116 

117This number is not explicitly named in RFC7641. 

118""" 

119 

120__all__ = [k for k in dir() if not k.startswith('_')]