Comments (7)
UDP is connectionless, so we should be able to fire off tons of requests and wait for the responses whenever, in theory?
Heck, Zmap can scan the internet @ 1.4 million packets per second... Looking into the architecture there...
Zmap:
- Raw ethernet socket (See: https://code.google.com/p/go/issues/detail?id=8432)
- Cache stuff that won't change (ethernet header, minus checksum)
- By generating and
caching the Ethernet layer packet, we prevent the Linux
kernel from performing a routing lookup, an arpcache
lookup, and netfilter checks for every packet.
- By generating and
- Don't handle responses - just use libpcap to grab (more or less) everything.
from gosnmp.
My experience writing a large snmp polling app for a large telco. I setup channels in my calling (golang) app to queue my requests, then started up many workers (each worker a goroutine that did a gosnmp call by pulling off the queue). Then an "aggregator" in another goroutine to aggregate my results from a "results" queue. That is, one master to many workers to one aggregator.
I found that golang/gosnmp wasn't slowing me down, rather slow devices (and network latency/capacity). In fact I setup a tunable "kill interval" in my app, because some devices were just so d!mn slow. If some devices hadn't answered within the time period, remaining workers would be killed and the next round of polling would start.
The interval was two minutes, so a few milliseconds of extra performance in the library doesn't interest me :-)
from gosnmp.
I agree with sonia's view. Raw sockets would add quite a layout of complexity. The kernel should be pretty efficient here anyway. Nathan: Is it device discovery or reading values that you're after? If it's device discovery, then maybe you can use a raw socket to scan, and then gosnmp to then read the values once you've confirmed the device exists.
from gosnmp.
@soniah
I have a similar design, I have a list of IPs stored in Redis, these get sent to NSQ (https://github.com/bitly/nsq), where I have a bunch of servers as consumers (well, each poller has multiple NSQ consumers). These consumers pull off messages from NSQ, and feed them to >10,000 goroutine workers. The results are then sent back to Redis (just 1 OID right now).
This maxes out at about 32,000/s.
I've not looked into adding a worker kill timeout, as I thought the SNMP timeout would do...
My devices are >20ms away (ping wise), but none should be more than 150ms away, even given that, when I need to poll 10s of millions of devices, I should be able to just send requests as quickly as possible and then just sit back and wait for them to respond (essentially performing an SNMP DDoS on myself...)
@codedance
No device discovery, and I have some other ideas other than raw sockets, which I'm going to try and prototype... I really dont want to be hand crafting packets, thats above the complexity I want as well.
from gosnmp.
Ok, so I had a try with this idea:
- Create a new function GenPacket(community string, version SnmpVersion, reqType PDUType, oids []string) which returns a []byte
- Create an empty UDPConn (net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0}))
- Turn the host addresses into net.UDPAddr's
- Write the returned packet using net.WriteToUDP([]byte, *net.UDPAddr)
- Figure out how to deal with the responses later
I can now do 137,000+ per second...
See my fork for the code specifics...
from gosnmp.
Cleaning up. Are you still working on this?
from gosnmp.
Possibly, haven't come back to it yet.
from gosnmp.
Related Issues (20)
- usmStatsUnknownUserNames as terminating error? HOT 3
- Chinese coding is garbled HOT 2
- How to configure read/write community? HOT 1
- marshal: marshalPDU: unable to marshal varbind list: unable to marshal OID: Value out of range HOT 2
- Should cancelling a context interrupt an ongoing operation?
- out of bounds error when parsing AuthNoPriv packet HOT 4
- msgMaxSize to be supported in SNMP v3 bulkwalk requests
- V3 feat needed: Load keys manually if the passphrases are not allowed be saved locally HOT 1
- Connect function in gosnmp always returns nil even if the credentials are not valid HOT 1
- Panic in unmarshalV3Header
- Compatibility with GoSNMPServer HOT 7
- `net-snmp` based validation testing HOT 5
- Request ID size too large
- Not handling `0` values correctly for `OpaqueDouble` or `OpaqueFloat`
- Using SnmpDecodePacket for Encrypted/Authenticated Packets in GoSNMP HOT 5
- Retry netConnect() on resolution failure HOT 2
- bulkwalk can omit OIDs that snmpwalk does show HOT 1
- Unable to receive SNMP response message, but the other party confirmed that it has been sent.
- SNMP-V3 trap-send not work
- OID index in tabular oid result HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gosnmp.