One team documents the protocol as a spec. A second team takes the spec and writes implementations. The advantage of this for open source is that when the protocol changes, it's relatively simple for that first team to update the spec, and safe for the second team to update their code.
This is legal and safe. It is how the first clone PCs survived even IBM's lawyers.
Not a typical recommendation, but they actually created a not half-bad Television series out of the story. From everything I've read on the subject, the first season of the show actually does stay pretty close to how things actually went down (with some 'dramatic' elements slightly embellished since it is on TV after all). The story is worth reading about (sorry for no recommendations on this), and the show, at least the first season which concerns this issue in particular, is worth watching as well if the topic interests you. The show is called 'Halt and Catch Fire'
Basically, you need to find developers with no experience at all with the technology (e.g. never used Skype before), and then get another set of developers to reverse engineer the product, and send the spec to the "naive" developers, for lack of a better term.
Two teams in the same firm, as gruez says below. The key is that the second team does not look at the internals of the product, and that the two teams communicate only by specifications of interfaces (physical, software, electronic, etc.) and not of behavior.
This approach to cloning was established long ago (1960's) by IBM's competitors and has always been legal.
You can just google "clean room design", Wikipedia is quite informative on it.
BTW a few early PC firms did try to cut corners and clone the PC BIOS without the chinese wall; they were sued and died. This isn't theory; it's been practice for decades.
This is legal and safe. It is how the first clone PCs survived even IBM's lawyers.