[Twisted-Python] UDP answer from different IP
Wolfgang.W.Eichler at gmx.de
Thu Apr 6 03:45:21 EDT 2006
I would like to clarify the situation and describe my current work-around:
My twisted application is on client machine A. It sends SNMP requests to server machine B.
self.proxy = agentproxy.AgentProxy(
ipAddress, port, # here '220.127.116.11', 6665
community = community,
snmpVersion = 'v1',
protocol = self.port.protocol,
df = self.proxy.getTable(oids, timeout= 0.5, retryCount=5)
Machine B has two interfaces to the network with IP '18.104.22.168' and '22.214.171.124' . Here runs some arbitrary SNMP Agent.
Twisted on A opens a port (25000 or so) and sends getNext requests.
These requests contain an ID, that is later used to identifiy incoming messages and relate them to the request.
To do this snmpprotocol.py has a function getRequestKey, that retrieves this ID from protocol elements.
When sending the getNext-message getRequestKey() returns:
(('126.96.36.199', 6665), 782)
This is the key which later should work to identify this request when the answers from B arrive.
But since B uses the other interface to answer, the message that arrives carries:
(('188.8.131.52', 6665), 782) and this key is not known.
I wonder why we need the IP address and port at this point, since the ID (782) is unique to machine A and port 25000 and is sufficient to identify the request to which this incoming message belongs.
I patched in snmpprotocol.py:
def getRequestKey( self, request, target ):
"""Get the request key from a request/response"""
for key in [
ID = request['pdu'][key]['request_id']
except KeyError, err:
except TypeError, err:
"""Unexpected TypeError retrieving request key %r: %s""",
# return target, ID.get()
raise KeyError( """Unable to get a request key id from %s for target %s"""%( request, target))
Could this be checked by some expert ? Any problem with this approach ?
More information about the Twisted-Python