6 ms·
For.. reasons, I found myself having to make a 'driver' for a PoE+ sensing device this month. The manufacturer had an SDK, but compiling it requires an old vers
by MrLeap 7y ago
For.. reasons, I found myself having to make a 'driver' for a PoE+ sensing device this month. The manufacturer had an SDK, but compiling it requires an old version of Visual Studio - a bouquet of dependencies, and it had no OSX support. None of the bundled applications would do what I needed (namely, let me forward the raw sensing data to another application.. SOMEHOW).
The data isn't encoded in the usual ways, so even 4 hours of begging FFMPEG were to no avail.
A few glances at wireshark payloads, the roughly translated documentation, and weighing my options, I embarked on a harrowing journey to synthesize the correct incantation of bytes to get the device to give me what I needed.
I've never worked with RTP/RTSP prior to this -- and I was disheartened to see nodejs didn't have any nice libraries for them. Oh well, it's just udp when it comes down to it, right?
SO MY NAIVETE BEGOT A JOURNEY INTO THE DARKNESS. Being a bit of an unknown-unknown, this project did _not_ budget time for the effort this relatively impromptu initiative required. An element of sentimentality for the customer, and perhaps delusions of grandeur, I convinced myself I could just crunch it out in a few days.
A blur of coffee and 7 days straight crunch later, I built a daisy chain of crazy that achieved the goal I set out for. I read rfc3550 so many times I nearly have it committed to memory. The final task was to figure out how to forward the stream I had ensorcelled to another application. UDP seemed like the "right" choice, if I could preserve the heavy lifting I had accomplished to reassemble the frames of data.. MTU sizes are not big enough to accomodate this (hence probably why the device uses RTP, LOL.). OSX supports some hilariously massive MTU's (It's been a few days, but I want to say something like 13,000 bytes?) Still, I'd have to chunk and reasemble each frame into quarters. Having to write _additional_ client logic to handle drops and OOO and relying on OSX's embiggened MTU's when I wanted this to be relatively OS independent... and the SHIP OR DIE pressure from above made me do bad. At this point, I was so crunched out that the idea of writing reconnect logic and doing it with TCP was painful so I'm here to confess... I did bad...
The client application spawns a webserver, and the clients poll via HTTP at about 30HZ. Ahhh it's gross...
I'm basically adrift on a misery raft of my own manufacture. Maybe protobufs would be better? I've slept enough nights to take a melon baller to the bad parts..
- sneak 7y agoWhat does it sense that changes >=30 times a second?
- ses1984 7y agoI'm guessing video frames given ffmpeg was part of the story.
- Craighead 7y ago60 hz electricity in American electric systems maybe? Thus its polling every other wave?
- dahfizz 7y agoYou only use the Real Time Protocol (RTP) when you need time sensitive data streaming (typically audio or video)
- jsight 7y agoI was curious about that to. Lots of references to video related standards that imply its a PoE camera, but then why isn't the data encoded in the usual ways? What does that mean?
- MrLeap 7y agoWhat codec would you use for a camera that captures not RGB, but poetry of the soul? CONTEXTLESS, HEADERLESS, ENDLESS BYTE STREAMS OF COURSE, where the literal, idealized (remember udp) position of each byte is part of a vector in a non euclidean coordinate system.
- cfallin 7y ago> What codec would you use for a camera that captures not RGB, but poetry of the soul? I would love to read a collaborative work between you and James Mickens -- this genre of writing seems sadly under-present in the computing world...
- 7y ago
- jtbayly 7y agoThis needs to be its own post. Lol.
- anticensor 7y ago> embiggened For non-native speakers: embiggened means huge, enlarged, overgrown. I am not a native speaker of English either
- squiggleblaz 7y ago*For non-Simpsons watchers The word was created as a joke in a Simpsons episode, a word used in Springfield only. It is described as "perfectly cromulent" by a Springfielder, which is evidently meant to mean "acceptable" or "ordinary" but is another Springfieldism. The joke may be lost on future generations who don't realise they're not normal words.
- skykooler 7y agoActually, "embiggened" is an actual word, though archaic, it's been around for over 130 years. The coinage of "cromulant" to describe it as such was the joke there, not "embiggen" itself. Source: https://en.wiktionary.org/wiki/embiggen https://en.wiktionary.org/wiki/embiggen
- kalleboo 7y agoThe show writers thought they came up with the word on their own, they didn't know about the previous usage of the word in 1884 (the episode was written in 1996, the internet wasn't quite as full of facts back then), "embiggen" was still supposed to be a joke.
- kahirsch 7y agoIt was used once in 1884 and the writer there specifically said he invented it. There are no other recorded uses of the word before The Simpsons.
- MrLeap 7y agoTo be fair to everyone, I've had native English speakers tell me what I speak is barely English.
- hinkley 7y agohttps://en.m.wikipedia.org/wiki/Jumbo_frame https://en.m.wikipedia.org/wiki/Jumbo_frame The wiki page talks about getting 5% more data through at full saturation but it doesn’t mention an important detail that I recall from when it was proposed. It turned out with gigabit Ethernet or higher that a single TCP connection cannot saturate the channel with an MTU of 1500 bytes. The bandwidth went up but the latency did not go down, and ACKs don’t arrive fast enough to keep the sender from getting throttled by the TCP windowing algorithm. If I have a typical network with a bunch of machines on it nattering at each other, that might not sound so bad. But when I really just need to get one big file or stream from one machine to another, it becomes a problem. So they settled on a multiple of 1500 bytes to avoid uneven packet fragmentation (if you get half packets every nth packet you lose that much throughput). Somehow that multiple became 6. And then other people wanted bigger or smaller and I’m not quite sure how OS X ended up with 13000. You’re gonna get 8x1500 + 1000 there. Or worse, 9000 + 4000.
- hinkley 7y agoIn college I only had one group project, which scandalized me but apparently lots of others found this normal. We had to fire UDP packets over the network and feed them to an MJPeG card. You got more points based on the quality of the video stream. My very industrious teammate did 75% of the work (4 man team, I did 20%, if you are generous with the value of debugging). One of the things we/he tried was to just drop packets that arrived out of order rather than reorder them. Turned out the reordering logic was reducing framerates. So he ran some trials and looked at OOO traffic, and across the three or so routers between source and sink he never observed a single packet arriving out of order. So we just dropped them instead and got ourselves a few more frames per second.
- pantalaimon 7y agoTbh that's what most real time video/audio applications will do. Reordering adds latency and that is worse than the occasional dropped frame.
- MrLeap 7y agoI can drop a frame, I can't casually drop misordered packets. It takes many packets to build a frame. I have to reorder interframe packets (actually I just insert-in-order). If I drop packets, I get data scrolling like a busted CRT raster. I'm using a KoalaBarrel. Koalas receive envelopes full of eucalyptus leaves. Koalas have to eat their envelopes in order. First koala to get his full subscription becomes fat enough to crush all the koalas beneath him. Keep adding koalas. Disregard letters addressed to dead koalas.
- shawnz 7y agoNot saying this is the ideal solution, but you could just drop any frame that contains any out of order packets. If an out of order packet arrives, just drop the current frame and start ignoring packets until you find the start of another frame.
- madddiagnosis 7y ago
- vermilingua 7y agoSounds like Crestron, and if so I feel for you.