Example #1
0
        /// <summary>
        /// Start up a session on the server side
        /// </summary>
        /// <param name="udpChannel">What channel are we on</param>
        /// <param name="message">What was the last message we got?</param>
        public void Accept(UDPChannel udpChannel, byte[] message)
        {
            DtlsServerProtocol serverProtocol = new DtlsServerProtocol(new SecureRandom());

            DtlsServer server = new DtlsServer(_serverKeys, _userKeys);

            server.TlsEventHandler += OnTlsEvent;
#if SUPPORT_TLS_CWT
            server.CwtTrustKeySet = CwtTrustKeySet;
#endif

            _transport.UDPChannel = udpChannel;
            _transport.Receive(message);

            //  Make sure we do not startup a listing thread as the correct call is always made
            //  byt the DTLS accept protocol.


            _listening = 1;
            DtlsTransport dtlsServer = serverProtocol.Accept(server, _transport);
            _listening = 0;

            _dtlsSession              = dtlsServer;
            AuthenticationKey         = server.AuthenticationKey;
            AuthenticationCertificate = server.AuthenticationCertificate;

            new Thread(StartListen).Start();
        }
        /// <summary>
        /// Tell the channel to set itself up and start processing data
        /// </summary>
        public void Start()
        {
            if (System.Threading.Interlocked.CompareExchange(ref _running, 1, 0) > 0)
            {
                return;
            }

            if (_udpChannel == null)
            {
                if (_localEndPoint != null)
                {
                    _udpChannel = new UDPChannel(_localEndPoint);
                }
                else
                {
                    _udpChannel = new UDPChannel(_port);
                }
            }

            _udpChannel.DataReceived += ReceiveData;
            if (SendBufferSize > 0)
            {
                _udpChannel.SendBufferSize = SendBufferSize;
            }
            if (ReceiveBufferSize > 0)
            {
                _udpChannel.ReceiveBufferSize = ReceiveBufferSize;
            }

            _udpChannel.Start();
        }
 public SceneEstimatorChannelRX seChannel = null;                // seChannel = new SceneEstimatorChannelRX(this);
 public SceneEstimatorInterfaceListener()
 {
     seChannel          = new SceneEstimatorChannelRX(this);
     clusterChannel     = new UDPChannel(SceneEstimatorObstacleChannelNames.AnyClusterChannelName, IPAddress.Parse("239.132.1.35"), 30035);
     localRoadChannel   = new UDPChannel(LocalRoadModelChannelNames.LocalRoadModelChannelName, IPAddress.Parse("239.132.1.35"), 30035);
     lmLocalRoadChannel = new UDPChannel(LocalRoadModelChannelNames.LMLocalRoadModelChannelName, IPAddress.Parse("239.132.1.34"), 30034);
 }
Example #4
0
 public Connection(int id, UDPChannel channel, IPEndPoint sendingEndPoint)
 {
     _id              = id;
     _channel         = channel;
     _sendingEndPoint = sendingEndPoint;
     _seqId           = 0;
 }
Example #5
0
        static IChannel NewUDPChannel(System.Net.EndPoint localEP, ICoapConfig config)
        {
            UDPChannel channel = new UDPChannel(localEP);

            channel.ReceiveBufferSize = config.ChannelReceiveBufferSize;
            channel.SendBufferSize    = config.ChannelSendBufferSize;
            channel.ReceivePacketSize = config.ChannelReceivePacketSize;
            return(channel);
        }
Example #6
0
        static IChannel NewUDPChannel(Int32 port, ICoapConfig config)
        {
            UDPChannel channel = new UDPChannel(port);

            channel.ReceiveBufferSize = config.ChannelReceiveBufferSize;
            channel.SendBufferSize    = config.ChannelSendBufferSize;
            channel.ReceivePacketSize = config.ChannelReceivePacketSize;
            return(channel);
        }
Example #7
0
        public NetworkManager(int localPort, EventManager eventManager, int delay, float packetLoss)
        {
            _connectionList    = new List <Connection>();
            _receiver          = new UDPChannel(localPort, ReceiveEventFakingLatencyAndPacketLoss);
            _connectionFactory = new ConnectionFactory(_receiver);
            _eventManager      = eventManager;

            _delay      = delay;
            _packetLoss = packetLoss;
        }
Example #8
0
            public ChannelListViewItem(IChannel channel, ChannelListView listView) : base(channel.Name, "dynamic channel", listView.Groups["dynamic"])
            {
                this.name           = channel.Name;
                this.dynamicChannel = true;

                endpoint = null;
                if (channel is UDPChannel)
                {
                    UDPChannel udpChannel = (UDPChannel)channel;
                    endpoint = new IPEndPoint(udpChannel.IP, udpChannel.Port);

                    listener = new ChannelListener(endpoint, ChannelType.UDPChannel);
                }

                this.SubItems.Add(endpoint == null ? channel.GetType().Name : endpoint.ToString());
                this.SubItems.Add("");
                this.SubItems.Add("");
            }
Example #9
0
        /// <summary>
        /// Create the DTLS connection over a specific UDP channel.
        /// We already know what address we are going to use
        /// </summary>
        /// <param name="udpChannel">UDP channel to use</param>
        public void Connect(UDPChannel udpChannel)
        {
#if SUPPORT_TLS_CWT
            if (CwtTrustKeySet != null)
            {
                _client = new DtlsClient(null, _userKey, CwtTrustKeySet);
            }
            else
            {
#endif
            if (_userKey.PrivateKey.HasKeyType((int)GeneralValuesInt.KeyType_Octet))
            {
                CBORObject kid = _userKey.PrivateKey[CoseKeyKeys.KeyIdentifier];

                BasicTlsPskIdentity pskIdentity;
                pskIdentity = new BasicTlsPskIdentity(kid != null ? kid.GetByteString() : new byte[0],
                                                      _userKey.PrivateKey[CoseKeyParameterKeys.Octet_k].GetByteString());
                _client = new DtlsClient(null, pskIdentity);
            }
            else if (_userKey.PrivateKey.HasKeyType((int)GeneralValuesInt.KeyType_EC2))
            {
                _client = new DtlsClient(null, _userKey);
            }
#if SUPPORT_TLS_CWT
        }
#endif

            _client.TlsEventHandler += OnTlsEvent;

            DtlsClientProtocol clientProtocol = new DtlsClientProtocol(new SecureRandom());

            _transport.UDPChannel = udpChannel;
            AuthenticationKey     = _userKey.PrivateKey;

            _listening = 1;
            DtlsTransport dtlsClient = clientProtocol.Connect(_client, _transport);
            _listening   = 0;
            _dtlsSession = dtlsClient;

            //  We are now in the world of a connected system -
            //  We need to do the receive calls

            new Thread(StartListen).Start();
        }
Example #10
0
 void Start()
 {
     perDeltaTime = 0.05f;
     curDeltaTime = 0f;
     StartNetSend = false;
     UdpTick      = true;
     socket       = ConnectSocket.getSocketInstance();
     udpSocket    = UDPChannel.Instance;
     if (!udpSocket.isInit)
     {
         udpSocket.init();
     }
     SocketQueue.getInstance().setCallback(ReceiveResponseData);
     dispatch = new GameNetMessageDispatch();
     dispatch.logicNetSwap = this;
     udpSocket.setCallback(dispatch.DispatchMessage);
     udpSocket.setSendCallback(dispatch.DispatchMessage);
     GameGlobalData.player.GetComponent <PlayerBehaviourCollector>().logicSwap = this;
     StartCoroutine(SendStartInfo());
 }
Example #11
0
        public void Start()
        {
            if (System.Threading.Interlocked.CompareExchange(ref _running, 1, 0) > 0)
            {
                return;
            }

            if (_udpChannel == null)
            {
                if (_localEP != null)
                {
                    _udpChannel = new UDPChannel(_localEP);
                }
                else
                {
                    _udpChannel = new UDPChannel(_port);
                }
            }

            _udpChannel.DataReceived += ReceiveData;

            _udpChannel.Start();
        }
Example #12
0
 public ConnectionFactory(UDPChannel channel)
 {
     _channel = channel;
 }