Ejemplo n.º 1
0
        //public long getMessageNumber() {
        //    return messageNumber;
        //}

        //public void setMessageNumber(long messageNumber) {
        //    this.messageNumber = messageNumber;
        //}



        //public long getTimeStamp() {
        //    return timeStamp;
        //}


        //public void setTimeStamp(long timeStamp) {
        //    this.timeStamp = timeStamp;
        //}



        //public long getDestinationID() {
        //    return destinationID;
        //}

        //public void setDestinationID(long destinationID) {
        //    this.destinationID = destinationID;
        //}


        /**
         * return the header according to specification p.5
         * @return
         */
        byte[] GetHeader()
        {
            byte[] res = new byte[16];
            Array.Copy(PacketUtil.EncodeControlPacketType(controlPacketType), 0, res, 0, 4);
            Array.Copy(PacketUtil.Encode(GetAdditionalInfo()), 0, res, 4, 4);
            Array.Copy(PacketUtil.Encode(timeStamp), 0, res, 8, 4);
            Array.Copy(PacketUtil.Encode(destinationID), 0, res, 12, 4);
            return(res);
        }
Ejemplo n.º 2
0
        /*
         * aplivation data
         * @param
         */

        //public void setData(byte[] data) {
        //    this.data = data;
        //}


        //public long getPacketSequenceNumber() {
        //    return this.packetSequenceNumber;
        //}

        //public void setPacketSequenceNumber(long sequenceNumber) {
        //    this.packetSequenceNumber = sequenceNumber;
        //}



        ////public long getMessageNumber() {
        ////    return this.messageNumber;
        ////}


        ////public void setMessageNumber(long messageNumber) {
        ////    this.messageNumber = messageNumber;
        ////}


        //public long getDestinationID() {
        //    return this.destinationID;
        //}


        //public long getTimeStamp() {
        //    return this.timeStamp;
        //}


        //public void setDestinationID(long destinationID) {
        //    this.destinationID = destinationID;
        //}


        //public void setTimeStamp(long timeStamp) {
        //    this.timeStamp = timeStamp;
        //}

        /**
         * complete header+data packet for transmission
         */

        public byte[] GetEncoded()
        {
            //header.length is 16
            byte[] result = new byte[16 + data.Length];
            Array.Copy(PacketUtil.Encode(packetSequenceNumber), 0, result, 0, 4);
            Array.Copy(PacketUtil.Encode(messageNumber), 0, result, 4, 4);
            Array.Copy(PacketUtil.Encode(timeStamp), 0, result, 8, 4);
            Array.Copy(PacketUtil.Encode(destinationID), 0, result, 12, 4);
            Array.Copy(data, 0, result, 16, data.Length);
            return(result);
        }
Ejemplo n.º 3
0
        //public long getMsgFirstSeqNo()
        //{
        //    return msgFirstSeqNo;
        //}

        //public void setMsgFirstSeqNo(long msgFirstSeqNo)
        //{
        //    this.msgFirstSeqNo = msgFirstSeqNo;
        //}

        //public long getMsgLastSeqNo()
        //{
        //    return msgLastSeqNo;
        //}

        //public void setMsgLastSeqNo(long msgLastSeqNo)
        //{
        //    this.msgLastSeqNo = msgLastSeqNo;
        //}


        public override byte[] EncodeControlInformation()
        {
            try
            {
                MemoryStream bos = new MemoryStream();
                bos.Write(PacketUtil.Encode(msgFirstSeqNo), 0, 8);
                bos.Write(PacketUtil.Encode(msgLastSeqNo), 0, 8);
                return(bos.ToArray());
            }
            catch (Exception e)
            {
                // can't happen
                return(null);
            }
        }
Ejemplo n.º 4
0
        //public long getAckSequenceNumber() {
        //    return ackSequenceNumber;
        //}
        //public void setAckSequenceNumber(long ackSequenceNumber) {
        //    this.ackSequenceNumber = ackSequenceNumber;
        //}


        /**
         * get the ack number (the number up to which all packets have been received (excluding))
         * @return
         */
        //public long getAckNumber() {
        //    return ackNumber;
        //}

        ///**
        // * set the ack number (the number up to which all packets have been received (excluding))
        // * @param ackNumber
        // */
        //public void setAckNumber(long ackNumber) {
        //    this.ackNumber = ackNumber;
        //}

        /**
         * get the round trip time (microseconds)
         * @return
         */
        //public long getRoundTripTime() {
        //    return roundTripTime;
        //}
        ///**
        // * set the round trip time (in microseconds)
        // * @param RoundTripTime
        // */
        //public void setRoundTripTime(long RoundTripTime) {
        //    roundTripTime = RoundTripTime;
        //}

        /**
         * set the variance of the round trip time (in microseconds)
         * @param RoundTripTime
         */
        //public void setRoundTripTimeVar(long roundTripTimeVar) {
        //    roundTripTimeVariance = roundTripTimeVar;
        //}

        //public long getRoundTripTimeVar() {
        //    return roundTripTimeVariance;
        //}

        //public long getBufferSize() {
        //    return bufferSize;
        //}

        //public void setBufferSize(long bufferSiZe) {
        //    this.bufferSize = bufferSiZe;
        //}

        //public long getPacketReceiveRate() {
        //    return pktArrivalSpeed;
        //}
        //public void setPacketReceiveRate(long packetReceiveRate) {
        //    this.pktArrivalSpeed = packetReceiveRate;
        //}


        //public long getEstimatedLinkCapacity() {
        //    return estimatedLinkCapacity;
        //}

        //public void setEstimatedLinkCapacity(long estimatedLinkCapacity) {
        //    this.estimatedLinkCapacity = estimatedLinkCapacity;
        //}


        public override byte[] EncodeControlInformation()
        {
            try {
                MemoryStream bos = new MemoryStream();
                bos.Write(PacketUtil.Encode(ackNumber), 0, 8);
                bos.Write(PacketUtil.Encode(roundTripTime), 0, 8);
                bos.Write(PacketUtil.Encode(roundTripTimeVariance), 0, 8);
                bos.Write(PacketUtil.Encode(bufferSize), 0, 8);
                bos.Write(PacketUtil.Encode(pktArrivalSpeed), 0, 8);
                bos.Write(PacketUtil.Encode(estimatedLinkCapacity), 0, 8);

                return(bos.ToArray());
            } catch (Exception e) {
                // can't happen
                return(null);
            }
        }
Ejemplo n.º 5
0
 public override byte[] EncodeControlInformation()
 {
     try {
         MemoryStream bos    = new MemoryStream(24);
         byte[]       buffer = null;
         buffer = PacketUtil.Encode(udtVersion);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(socketType);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(initialSeqNo);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(packetSize);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(maxFlowWndSize);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(connectionType);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(socketID);
         bos.Write(buffer, 0, buffer.Length);
         buffer = PacketUtil.Encode(cookie);
         bos.Write(buffer, 0, buffer.Length);
         //bos.Write(PacketUtil.encode(socketType));
         //bos.Write(PacketUtil.encode(initialSeqNo));
         //bos.Write(PacketUtil.encode(packetSize));
         //bos.Write(PacketUtil.encode(maxFlowWndSize));
         //bos.Write(PacketUtil.encode(connectionType));
         //bos.Write(PacketUtil.encode(socketID));
         // bos.Write(PacketUtil.encode(cookie));//cd 2018-08-28
         for (int i = 0; i < 4; i++)
         {
             buffer = PacketUtil.Encode(peerIP[i]);
             bos.Write(buffer, 0, buffer.Length);
             //bos.write(PacketUtil.encode(peerIP[i]));
         }
         buffer = bos.ToArray();
         bos.Close();
         return(buffer);
     } catch (Exception e) {
         // can't happen
         return(null);
     }
 }