5 Replies Latest reply on Aug 29, 2011 8:57 AM by Michael Thornburgh

    confused over nearid, farid, nearNonce etc

    entrepreneur101

      I am confused over various IDs

      Does nearId equals farid on other end

      what is nearNonce id

       

      I found a high level architecture explanation that beautifully explained how P2P works overall.

      Are there any more articles with detailed explanation of how all pieces fit together in the puzzle?

       

      thanks for helping

       

      A book that walks me through various pieces in puzzle would be a blessing. Is there any Cirrus book out there?

        • 1. Re: confused over nearid, farid, nearNonce etc
          Michael Thornburgh Adobe Employee

          a NetConnection.nearID is that NetConnection's "peer ID"; it is a cryptographically unforgeable identifier for that NetConnection. peers refer to you by your peer ID.

           

          the nearID on the near end is the farID on the other end.

           

          the nearNonce on the near end is the farNonce on the other end. the nonces are private, unguessable, cryptographically unforgeable tokens derived from the end-to-end encryption keys and are distinct for each distinct end-to-end connection.  in other words, your peer ID is the same for all peers you talk to, but your nonces are different for each peer you talk to.

          • 2. Re: confused over nearid, farid, nearNonce etc
            entrepreneur101 Level 1

             

             

             

            Michael, thanks for the explanation. I tried what you said and I am getting different results:

             

            Issue #1). I connected two users and I find user1.farid = user2.farid. I would expect user1.nearid = user2.farid and vice versa.

            Here is the output

             

             

            user1: local stream published with nearID = 19f4a43877e0a812dfa25045d96fcee6c8d44792b18ff26fda80262a01f8c65c

            user1: remote stream received with far id = G:0100010101020103010c0f0e766964656f4368617447726f7570011b00

             

            user2: local stream published with nearID = b7a4995f8e3cfddc5d6f261f3a3ed9facee1d5aea495888e4dade3b009df3256

            user2: remote stream received with far id = G:0100010101020103010c0f0e766964656f4368617447726f7570011b00

             

             

            code is as follows:

             

             

            private function startSendingVideo():NetStream

            {

            outgoingStream = new NetStream(netConnection, groupspec.groupspecWithAuthorizations());

             

            .........

            .........

            outgoingStream.publish("abcd");

             

            debug("local stream published with nearID = " + netConnection.nearNonce);

            return outgoingStream;

            }

            private function playIncomingStream():void
            {
            incomingStream = new NetStream(netConnection, groupspec.groupspecWithAuthorizations());
            incomingStream.receiveVideo(true);
            incomingStream.receiveAudio(true);
            ...........
            ...........
            incomingStream.addEventListener(NetStatusEvent.NET_STATUS, eventHandler);
            debug("remote stream received with far id = " + incomingStream.farID);
            incomingStream.play("abcd");
            }
            question #2). convertPeerIDToGroupAddress - lets say user1 has peerid of user2. This enables user1 to find which group user2 is currently in and join that group (kind of like follow this user). Correct?

            question #3: I am getting confused about how do all these IDs fit together. I guess I am hoping to get an entity relationship diagram or some explanation of how all these objects fit together.

             

            sorry for so many questions. I am trying to understand so I can use it properly.

            thanks again

            • 3. Re: confused over nearid, farid, nearNonce etc
              Michael Thornburgh Adobe Employee

              the farID for a NetStream is only meaningful for 1:1 NetStreams, not group NetStreams.  you're seeing group specifications ("groupspecs"), not peer IDs.  groupspecs start with "G:".

               

              the nonces on NetStreams are not defined when using groups, only for 1:1.

               

              the 1:1 P2P API works like this: publisher publishes with

               

                var ns:NetStream = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);

                ...

                ns.publish("streamname");

                sendMyPeerIDToOtherPeerSomehow(netConnection.nearID);

               

              subscriber subscribes with

               

                var ns:NetStream = new NetStream(netConnection, publishersPeerIDYouGotSomehow);

                ...

                ns.play("streamname");

               

              NetGroup.convertPeerIDToGroupAddress() takes a peerID (a 64-digit hex string, from NetConnection.nearID) and converts it (via SHA256) to a different 64-digit hex string which is used for group topology purposes and directed routing.

              1 person found this helpful
              • 4. Re: confused over nearid, farid, nearNonce etc
                entrepreneur101 Level 1

                Thanks again Micheal, that takes me one step further.

                 

                I have another ID problem.

                 

                I have two clients connected via NetGroup.

                 

                First client has netconnection.nearId = 1b5cab71697bc852220ee2651288690d84faf11141ae8f936d6731e5bc0c97a9

                 

                When it joins NetGroup, the second client receives event: NetGroup.Neighbor.Connect event. Here value of

                event.info.neighbor = 9536722f1a0c5580e49ef4fedbf727325f12f96232d2c9f8a749d8271f02d712

                 

                What is event.info.neighbor number? Is there a way to figure out neighbor's peerId from event.info.neighbor?

                 

                thanks for all the help

                • 5. Re: confused over nearid, farid, nearNonce etc
                  Michael Thornburgh Adobe Employee

                  the event.info.neighbor is the "group address" of the neighbor.  event.info.peerID is the peer ID of the neighbor. you can convert a peer ID to a group address, but not the reverse, since the group address is a SHA256 hash of the peer ID (and other data).