[simulation] add configuration MAX_NETWORK_SIZE (#5565)

Currently, the WELLKNOWN_NODE_ID = 34 is not properly defined.

- In virtual time simulation, WELLKNOWN_NODE_ID limits the number of
  ports each PORT_OFFSET can occupy. The virtual time simulator
  listens at the nodeid=0 port rather than nodeid=34 port. So, there
  is no such thing as wellknown node ID in virtual time simulation.

- In real time simulation, the sniffer listens at the nodeid=34
  port. This PR changes it to nodeid=0 port to be consistent with
  other parts.

- In posix virtual time, the simulator listens at the nodeid=0
  port. So, there is no such thing as wellknown node ID in Posix
  virtual time.

This commit changes it to MAX_NETWORK_SIZE = 33 and make it
(configuration OPENTHREAD_SIMULATION_MAX_NETWORK_SIZE) configurable in
simulation by:

- Makefile configuration: MAX_NETWORK_SIZE
- Cmake configuration: OT_SIMULATION_MAX_NETWORK_SIZE
This commit is contained in:
Simon Lin
2020-10-16 10:57:03 -07:00
committed by GitHub
parent 92078815f5
commit 913037b508
11 changed files with 37 additions and 21 deletions
+2 -2
View File
@@ -137,7 +137,7 @@ class VirtualTime(BaseSimulator):
EVENT_DATA = 5
BASE_PORT = 9000
MAX_NODES = 34
MAX_NODES = 33
MAX_MESSAGE = 1024
END_OF_TIME = float('inf')
PORT_OFFSET = int(os.getenv('PORT_OFFSET', '0'))
@@ -152,7 +152,7 @@ class VirtualTime(BaseSimulator):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ip = '127.0.0.1'
self.port = self.BASE_PORT + (self.PORT_OFFSET * self.MAX_NODES)
self.port = self.BASE_PORT + (self.PORT_OFFSET * (self.MAX_NODES + 1))
self.sock.bind((ip, self.port))
self.devices = {}