Пример #1
0
 /// <summary>
 /// * @param host
 /// * @param port
 /// * @param endpoint
 /// * @throws SocketException,UnknownHostException
 /// </summary>
 /// <param name="endpoint"></param>
 /// <param name="session"></param>
 public UDTSocket(UDPEndPoint endpoint, UDTSession session)
 {
     this.endpoint = endpoint;
     this.session  = session;
     this.receiver = new UDTReceiver(session, endpoint);
     this.sender   = new UDTSender(session, endpoint);
 }
Пример #2
0
 /// <summary>
 /// create a receiver with a valid {@link UDTSession}
 /// </summary>
 /// <param name="session"></param>
 /// <param name="endpoint"></param>
 public UDTReceiver(UDTSession session, UDPEndPoint endpoint)
 {
     this.roundTripTimeVar = roundTripTime / 2;
     this.endpoint         = endpoint;
     this.session          = session;
     //( System.DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0).Ticks)/10000;
     //如果要得到Java中 System.currentTimeMillis() 一样的结果,就可以写成 上面那样,也可以这样写:
     // TimeSpan ts=new TimeSpan( System.DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0).Ticks);
     //(long)ts.TotalMilliseconds;
     this.sessionUpSince = (long)ts.TotalMilliseconds;
     this.statistics     = session.getStatistics();
     if (!session.isReady())
     {
         Log.Write(this.ToString(), "UDTSession is not ready.");
     }
     ackHistoryWindow         = new AckHistoryWindow(16);
     packetHistoryWindow      = new PacketHistoryWindow(16);
     receiverLossList         = new ReceiverLossList();
     packetPairWindow         = new PacketPairWindow(16);
     largestReceivedSeqNumber = (int)session.getInitialSequenceNumber() - 1;
     bufferSize      = session.getReceiveBufferSize();
     handoffQueue    = new Queue <UDTPacket>(4 * session.getFlowWindowSize());
     storeStatistics = false;      //Boolean.getBoolean("udt.receiver.storeStatistics");
     initMetrics();
     start();
 }
Пример #3
0
 ///// <summary>
 ///// Create a UDT ServerSocket
 ///// </summary>
 ///// <param name="port">本地端口</param>
 public UDTServerSocket(int port)
 {
     try
     {
         endpoint = new UDPEndPoint(port);//127.0.0.1 65321
         Log.Write(this.ToString(), "Created server endpoint on port " + endpoint.getLocalPort());
     }
     catch (Exception exc)
     {
         Log.Write(this.ToString(), "Create a UDT ServerSocket err", exc);
     }
 }
 public UDTClient(IPAddress address, int localport)
 {
     try
     {
         //create endpoint
         clientEndpoint = new UDPEndPoint(address, localport);
         Log.Write(this.ToString(), "Created client endpoint on port " + localport);
     }
     catch (Exception exc)
     {
         Log.Write(this.ToString(), exc);
     }
 }
Пример #5
0
 public UDTSender(UDTSession session, UDPEndPoint endpoint)
 {
     if (!session.isReady())
     {
         Log.Write(this.ToString(), "UDTSession is not ready.");
     }
     this.endpoint         = endpoint;
     this.session          = session;
     statistics            = session.getStatistics();
     senderLossList        = new SenderLossList();
     sendBuffer            = new Dictionary <long, DataPacket>(session.getFlowWindowSize());
     sendQueue             = new Queue <DataPacket>(1000);
     lastAckSequenceNumber = (int)session.getInitialSequenceNumber();
     currentSequenceNumber = (int)session.getInitialSequenceNumber() - 1;
     waitForAckLatch.Set(new CountDownLatch(1));
     waitForSeqAckLatch.Set(new CountDownLatch(1));
     storeStatistics = false;       //Boolean.getBoolean("udt.sender.storeStatistics");
     initMetrics();
     doStart();
 }
 public ClientSession(UDPEndPoint endPoint, Destination dest) : base("ClientSession localPort=" + endPoint.getLocalPort(), dest)
 {
     this.endPoint = endPoint;
     Log.Write(this.ToString(), "Created " + toString());
 }
Пример #7
0
 public ServerSession(byte[] dp, UDPEndPoint endPoint)
     : base("ServerSession localPort=" + endPoint.getLocalPort() + " peer=" + endPoint.remoteIP.Address + ":" + endPoint.remoteIP.Port, new Destination(endPoint.remoteIP.Address, endPoint.remoteIP.Port))
 {
     this.endPoint = endPoint;
     Log.Write(this.ToString(), "Created " + toString() + " talking to " + endPoint.remoteIP.Address + ":" + endPoint.remoteIP.Port);
 }
Пример #8
0
 public UDTClient(UDPEndPoint endpoint)
 {
     clientEndpoint = endpoint;
 }
Пример #9
0
 public UDTClient(int _port)
 {
     //create endpoint
     clientEndpoint = new UDPEndPoint(_port);
     Log.Write(this.ToString(), "Created client endpoint on port " + clientEndpoint.getLocalPort());
 }