{"action":"created","issue":{"url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/45","labels_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/45/comments","events_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/45/events","html_url":"https://github.com/ReactiveSocket/reactivesocket/issues/45","id":103606963,"number":45,"title":"Optional frame header length before version is problematic","user":{"login":"wmiaw","id":156189,"avatar_url":"https://avatars.githubusercontent.com/u/156189?v=3","gravatar_id":"","url":"https://api.github.com/users/wmiaw","html_url":"https://github.com/wmiaw","followers_url":"https://api.github.com/users/wmiaw/followers","following_url":"https://api.github.com/users/wmiaw/following{/other_user}","gists_url":"https://api.github.com/users/wmiaw/gists{/gist_id}","starred_url":"https://api.github.com/users/wmiaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmiaw/subscriptions","organizations_url":"https://api.github.com/users/wmiaw/orgs","repos_url":"https://api.github.com/users/wmiaw/repos","events_url":"https://api.github.com/users/wmiaw/events{/privacy}","received_events_url":"https://api.github.com/users/wmiaw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-27T22:18:25Z","updated_at":"2015-08-28T19:32:21Z","closed_at":null,"body":"Are the first 8 bits your version or the R (which right now has no defined value) followed by a frame length? A frame length that fits within the lower 24 bits also means that the first 8 bits of a frame-lengthed frame will look the exact same as the first 8 bits of a frame-not-lengthed frame, because your initial version is zero.\r\n\r\nIf you ever want to increment the version in order to support a different frame header field length you won't be able to. But that might be important.\r\n\r\nSuggest making the version the very first thing. Magic strings are also sometimes used to differentiate between random bytes and the start of a message, which might be even more important considering you could start reading almost anywhere in the binary stream coming across the wire."},"comment":{"url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/comments/135867663","html_url":"https://github.com/ReactiveSocket/reactivesocket/issues/45#issuecomment-135867663","issue_url":"https://api.github.com/repos/ReactiveSocket/reactivesocket/issues/45","id":135867663,"user":{"login":"wmiaw","id":156189,"avatar_url":"https://avatars.githubusercontent.com/u/156189?v=3","gravatar_id":"","url":"https://api.github.com/users/wmiaw","html_url":"https://github.com/wmiaw","followers_url":"https://api.github.com/users/wmiaw/followers","following_url":"https://api.github.com/users/wmiaw/following{/other_user}","gists_url":"https://api.github.com/users/wmiaw/gists{/gist_id}","starred_url":"https://api.github.com/users/wmiaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmiaw/subscriptions","organizations_url":"https://api.github.com/users/wmiaw/orgs","repos_url":"https://api.github.com/users/wmiaw/repos","events_url":"https://api.github.com/users/wmiaw/events{/privacy}","received_events_url":"https://api.github.com/users/wmiaw/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T19:32:21Z","updated_at":"2015-08-28T19:32:21Z","body":"Framing should not be a layered concern. Sure, you can make your protocol frame smaller by saying you will leverage the underlying protocol's frame to size your frame, but that's dangerous. Because by design the underlying protocol is not required to stay the same for the entire communication nor be visible to the higher layers.\r\n\r\nThe only requirement you have stated so far is that the underlying protocol is reliable. Well, Ethernet is reliable and has a frame size (that varies in size depending on the driver's configuration) so if you could query the configured frame size you could leave off your length field when constructing the message, and if you could query the frame size when you receive the data you could parse properly. And does this also mean for Ethernet you need to modify your Ethernet frame size every single time you send a Reactive Socket frame? And serialize all of that possibly requiring low-level access to the Ethernet driver?\r\n\r\nAlso, what about a situation where you have endpoint A on one network X and endpoint B on a second network Y, with X and Y connected through a third network Z? Say X is using Ethernet, Y is using ATM (which has fixed-size frames, so you can't change it to suit your Reactive Socket frame sizes), and Z uses something else completely. You're using Reactive Socket over protocols that provide framing, but you definitely cannot rely upon the underlying protocol framing being used to inform the Reactive Socket stacks of the frame sizes.\r\n\r\nThe part about the magic string to indicate where a frame starts is to give you a way to recover if a frame gets corrupted and your input buffer position is now at some wrong location and you need to try and drop bytes until you find the start of the next frame."}}