[snmp] RE: Bind to a specific port
Josh Bers
jbers at bbn.com
Tue May 27 14:12:56 BST 2008
Hi Birgit,
Thanks for your many responses...
It turns out my issue was not setting the ContextEngineId to the
AuthEngineId (the stack may want to do this by default for Authoritative
contexts).
As you say, the agent side clearly is not as well developed, yet. I think
that the whole socket issue deserves some re-design to serve in agent
capacity...Sharing a single socket for sending out datagrams might be the
way to go for an agent....
You currently have a single listening context receiving requests on port 161
(say). Then to reply you'd like to use the same socket to send the response
to the requestor... (this can be the sendTo address of the socket or read
from the context), however, you don't want to create a new socket to respond
to the requestor (as the stack currently does) because then you will indeed
have to pick a random open port number to avoid conflicting with other
contexts...and it wastes system resources..
The way the DatagramSocket works you can create it with a specific local
Port number (see SocketAddress or SocketId) and leave the local IP
un-defined (null). Since the underlying impl uses sendTo it can send to any
number of remote destinations at packet send time.
That way over the wire all responses from the agent will have the src port
be 161....
Josh
-----Original Message-----
From: Birgit Arkesteijn [mailto:birgit at westhawk.co.uk]
Sent: Tuesday, May 27, 2008 12:13 PM
To: Josh Bers
Cc: 'List for discussion of the Westhawk SNMP stack'
Subject: Re: Bind to a specific port
Hi Josh,
No, there isn't.
I have to read up on DatagramSocket and DatagramPacket (used by our
StandardSocket), but a quick glance doesn't tell me how to specify the
local port on the fly.
As far as I can tell, you can give the local port to listen *on* (i.e.
all incoming packets that are send to port 161), but as far as I can
tell, not the local port where to send *from*.
Cheers, Birgit
On 25/05/08 05:03, Josh Bers wrote:
> I am attempting to create an agent, however, when I send response to a
> manager the stack uses a different port (local) on which to send
> responses from, e.g., if I am listening on port 1162 for requests,
> responses go out on 1190 (or other random port). Is there a way to tell
> the stack to use a specific local port when sending response pdu's?
>
>
>
> Thanks,
>
>
>
> Josh
>
>
>
> Josh Bers
>
> Senior Engineer, Mobile Networking Systems
>
> BBN Technologies
>
> web: www.bbn.com <http://www.bbn.com> ph: (617) 873-4262 fax: (617)
873-4523
>
>
>
--
-- Birgit Arkesteijn, birgit at westhawk.co.uk,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
More information about the snmp
mailing list