Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Informs acknowledgement #211

Open
sankara05 opened this issue Oct 15, 2018 · 4 comments
Open

Informs acknowledgement #211

sankara05 opened this issue Oct 15, 2018 · 4 comments

Comments

@sankara05
Copy link

sankara05 commented Oct 15, 2018

Hi,

We have a distributed application running as containers. I need some help to set the source address for the acknowledgment packet going out of pysnmp.

So, this is our workflow:

  • The agent sends the informs to the application (running on server 1)

  • Application forwards the UDP packet to the informs processing app (running on server 2) --> It's for load balancing.

  • Server 2 receives and process the informs, sends the acknowledgment back to the Agent. This is done by the SNMP engine --> But the source IP is for the ack packet is set to the server 2 IP.

And our agent drops the acknowledgment bcos the informs were sent to the server 1.
Is there any way I can set the source address for the ack packet? Need some help.

Code:

from pysnmp.carrier.twisted.dgram import udp

self.snmp_engine = engine.SnmpEngine()
udp_transport.addressType().setLocalAddress(('1.2.3.4', 0))
        udp_transport.openServerMode(('::', self.informs_port))
        udp_transport.enablePktInfo()

        config.addTransport(
            self.snmp_engine,
            udp.domainName,
            udp_transport
        )

Note : I am using twisted udptransport.

Sa.

@sankara05
Copy link
Author

sankara05 commented Oct 17, 2018

Follow up question: When the pysnmp receives the informs, it sends out the ack. In my case, the source IP is reset to a different IP, with this doesn't it need to recalculate the checksums?? I am seeing checksum errors and the packet is getting dropped. Any help??? @etingof Can you please help?

@etingof
Copy link
Owner

etingof commented Oct 17, 2018

In my case, the source IP is reset to a different IP, with this doesn't it need to recalculate the checksums??

I am pretty sure pysnmp should not and in fact it does not mess with IP/UDP checksums. I believe this is done by the TCP/IP stack in the kernel (or even by the NICs now days). If checksum calculation is offloaded to the NIC, I can imagine tcpdump might not see the final checksum in the outgoing traffic.

It would be helpful if you paste some network related code - what you ended up with for the time being?

@etingof
Copy link
Owner

etingof commented Oct 17, 2018

Did you manage to override source IP in responses? I think it's doable, but I am not sure that necessary API is exposed especially for Twisted.

@sankara05
Copy link
Author

sankara05 commented Oct 18, 2018

@etingof No. I am not able to. I have been looking at the code and realized that we need to have Python 3 to spoof the local address.

For ex:

https://github.com/etingof/pysnmp/blob/master/pysnmp/carrier/sockmsg.py#L12

This is what I am thinking for spoofing the address with twisted: We make a custom twisted.internet.udp.Port implementation where self.socket.send and self.socket.sendto in write are replaced with calls to sendmsg similar to what pysnmp does. Then we will replace the twisted dispatcher with our custom implementation. @etingof Any thoughts on this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants