예제 #1
0
        /**********************************************************************
         *********************************************************************/
        //this method imitates the sender of a packet. It is called by the method invoke
        public static void SendPackageAt(int seqnum)
        {
            if (!stopEverything)
            {
                if (seqnum == nextSeqnum)
                {
                    DrawFillLeft(seqnum);
                }

                //pending if not already acknowledged . Add to list only once
                if (!arrivedAck.Any() && !pendingAck.Contains(seqnum) ||
                    arrivedAck.Any() && !arrivedAck.Contains(seqnum) && !pendingAck.Contains(seqnum))
                {
                    pendingAck.Add(seqnum);
                }

                //define object
                float yPos = 15 + (65 * (28 - seqnum)); //calculate where the box !starts! in the coordinate system
                var   pp   = new OldPipelineProtocolsPack(seqnum, 0);
                pp.Position = new CCPoint(80, yPos);
                layer.AddChild(pp);

                //define actions
                float timeToTake        = 5f;
                var   distance          = new CCPoint(280, yPos);             //82 to 278 = 278-82 = 196
                var   sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the object 196 in x-direction within 5 seconds
                var   removeAction      = new CCRemoveSelf();                 //this action removes the object

                //define sequence of actions and apply to object
                var cc_seq1 = new CCSequence(sendPackageAction, removeAction);
                pp.RunAction(cc_seq1);
            }
        }
예제 #2
0
 public static void PackArrived(OldPipelineProtocolsPack pp)
 {
     //if there has no other pack with the same seqnum has arrived before
     if (!arrivedPack.Any() || arrivedPack.Any() && !arrivedPack.Contains(pp.seqnum))
     {
         arrivedPack.Add(pp.seqnum);
         DrawFillRight(pp.seqnum);
         baseOfWindowRight = FindFirstNotYetArrivedPack();
         DrawWindowRight(baseOfWindowRight);
     }
     SendACKFor(pp.seqnum);
     layer.RemoveChild(pp);
 }
예제 #3
0
        /**********************************************************************
         *********************************************************************/
        public static void SlowDownPack(OldPipelineProtocolsPack pp, int xPos)
        {
            //stop running actions
            pp.StopAllActions();

            //define actions
            float yPos              = 15 + (65 * (28 - pp.seqnum));
            float timeToTake        = 8f;
            var   distance          = new CCPoint(280, yPos);
            var   sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the Object to the CCPoint
            var   removeAction      = new CCRemoveSelf();                 //this action removes the object*/

            //define sequence of actions and apply to object
            var cc_seq1 = new CCSequence(sendPackageAction, removeAction);

            pp.RunAction(cc_seq1);
        }
예제 #4
0
 public static void PackArrived(OldPipelineProtocolsPack pp)
 {
     //if it is the exoected seqnum and there has no other pack with the same seqnum has arrived before
     if (pp.seqnum == expectedSeqnum && (!arrivedPack.Any() || arrivedPack.Any() && !arrivedPack.Contains(pp.seqnum)))
     {
         arrivedPack.Add(pp.seqnum);
         DrawFillRight(pp.seqnum);
         expectedSeqnum = FindFirstNotYetArrivedPack();
         DrawExpectedSeqnum();
         SendACKFor(pp.seqnum);
     }
     else if (pp.seqnum <= expectedSeqnum)
     {
         SendACKFor(pp.seqnum);
     }
     else if (pp.seqnum > expectedSeqnum)
     {
         SendACKFor(arrivedPack.Last()); // send ACK for las recent in Order received Pack
     }
     layer.RemoveChild(pp);
 }
예제 #5
0
 public static void PackLost(OldPipelineProtocolsPack pp)
 {
 }
예제 #6
0
 /**********************************************************************
  *********************************************************************/
 public static void PackCorrupt(OldPipelineProtocolsPack pp)
 {
 }
예제 #7
0
 /**********************************************************************
  *********************************************************************/
 public static void PackCorrupt(OldPipelineProtocolsPack pp)
 {
     SendACKFor(arrivedPack.Last()); // send ACK for las recent in Order received Pack
 }