Example #1
0
 public void Send(IdentifiedClient dest, Message message)
 {
     /*message = new CharacterNameSuggestionRequestMessage();
      * var src = dest == m_player ? m_server : m_player;
      *
      * using (var writer = new BigEndianStream.BigEndianWriter())
      * {
      *  // We need to create all the packet layers.
      *
      *  // LinkLayer -> Ethernet
      *  var ethernetLayer = new EthernetLayer()
      *                          {
      *                              Source = src.Mac,
      *                              Destination = dest.Mac
      *                          };
      *
      *  // InternetLayer -> IPv4
      *  src.Ipv4Id += 2;
      *  var ipv4Layer = new IpV4Layer()
      *                      {
      *                          Source = src.Ip,
      *                          Destination = dest.Ip,
      *                          Ttl = 128,
      *                          Identification = src.Ipv4Id
      *                      };
      *
      *  // TransportLayer -> TCP
      *  var tcpLayer = new TcpLayer()
      *                     {
      *                         SourcePort = src.Port,
      *                         DestinationPort = dest.Port,
      *                         SequenceNumber = src.TcpId,
      *                         AcknowledgmentNumber = src.AckId,
      *                         ControlBits = TcpControlBits.Push | TcpControlBits.Acknowledgment,
      *                         Window = 4140
      *                     };
      *
      *  //Write Message in Buffer
      *  message.Pack(writer);
      *
      *  // PayloadLayer
      *  var payloadLayer = new PayloadLayer()
      *                         {
      *                             Data = new Datagram(writer.Data)
      *                         };
      *
      *  // Build Packet
      *  var builder = new PacketBuilder(ethernetLayer, ipv4Layer, tcpLayer, payloadLayer);
      *  var packet = builder.Build(DateTime.Now);
      *
      *  //Add to Sended
      *  dest.Sended.Add(src.AckId);
      *
      *  m_communicator.SendPacket(packet);
      * }*/
 }
Example #2
0
        private void ConfirmReception(IdentifiedClient src, IdentifiedClient dest)
        {
            // LinkLayer -> Ethernet
            var ethernetLayer = new EthernetLayer()
            {
                Source      = src.Mac,
                Destination = dest.Mac
            };

            // InternetLayer -> IPv4
            src.Ipv4Id += 2;
            var ipv4Layer = new IpV4Layer()
            {
                Source         = src.Ip,
                Destination    = dest.Ip,
                Ttl            = 128,
                Identification = src.Ipv4Id
            };

            // TransportLayer -> TCP
            var tcpLayer = new TcpLayer()
            {
                SourcePort           = src.Port,
                DestinationPort      = dest.Port,
                SequenceNumber       = src.TcpId,
                AcknowledgmentNumber = src.AckId,
                ControlBits          = TcpControlBits.Acknowledgment,
                Window = 4140
            };

            // Build Packet
            var builder = new PacketBuilder(ethernetLayer, ipv4Layer, tcpLayer);
            var packet  = builder.Build(DateTime.Now);

            m_communicator.SendPacket(packet);
        }
Example #3
0
 /// <summary>
 ///   Resets this instance.
 /// </summary>
 public void Reset()
 {
     m_server = new IdentifiedClient("Serveur");
     m_player = new IdentifiedClient("Player");
 }