On 3/27/24 00:15, Teus Benschop wrote:
On Wed, 27 Mar 2024 at 00:58, Bart Van Assche <bvanass...@acm.org> wrote:
Please explain why you want to obtain that information and also
how you plan to use it. Which APIs to modify will depend on the
answer to that question.
Hello Bert,
Thank you for asking this question.
The background to this is that we are building software to control
traffic signs above the highways. These signs are controlled through
one of the NTCIP protocols (https://www.ntcip.org). And this protocol
again is based on the SNMP protocol. Each traffic sign contains one
SNMP agent that listens on a given port number.
We are building a simulator to simulate all of those traffic signs.
Currently one simulator simulates one traffic sign. The traffic sign
has many and large SNMP tables registered with Net-SNMP. Due to the
sheer size and amount of objects in the SNMP tables, plus many other
registered objects, one simulator now allocates about 350 Mbytes of
memory.
If we simulate, say, 20 traffic signs, then the allocated memory
becomes about 7 Gbytes. If we simulate 100 traffic signs, then the
allocated memory becomes around 35 Gigabytes.
We now have the idea to only run one SNMP agent, and hence allocate
only 350 Megabytes of memory, but then let this SNMP agent listen on
multiple ports, through the Net-SNMP library.
The traffic signs listen on the TCP protocol, hence the simulator uses
TCP too.
If the simulator listens on, say, port 2001, 2002, 2003, and so on,
then this would simulate traffic sign #1 on port 2001, traffic sign #2
on port 2002, and traffic sign #3 on port 2003. If the traffic control
software sends a SNMP get request to, say, port 2002, then the traffic
sign simulator knows that it should respond with data about traffic
sign #2.
Hence if the Net-SNMP library would expose the TCP port number that a
given request was sent to, the simulator would make a call to the
Net-SNMP library to find the port number, and give an appropriate
response.
This is the reason why I want to obtain the port number, and this
would be the intended usage of it.
Hi Teus,
Thanks for the background information. I'm not sure the Net-SNMP API
needs to be modified to realize this. How about the following approach:
* Use netsnmp_register_handler() in MIB implementations to associate
OIDs with callback functions.
* In the handler callback function, use the
reqinfo->asp->session->local_port information.
* Make sure that session->local_port is set correctly. This may
require a code change in Net-SNMP.
Best regards,
Bart.
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders