public DashboardAccess () { string alias = ConfigurationManager.AppSettings["Alias"]; string ipAddressRange = ConfigurationManager.AppSettings["AllowedIPList"]; string port = (String)ConfigurationManager.AppSettings["DashboardPort"]; string uri = string.Format("net.tcp://{0}:{1}/{2}Comm/", Dns.GetHostName(), port, alias); _dateTimeFormat = "yyyy-MM-dd HH-mm-ss.fff"; string assemblyTag = DateTime.Now.ToString(_dateTimeFormat); UpdateSettingsConfig(); _SubsystemHost = new SubsystemHost(alias, assemblyTag); List<DiscoveryMetadata> list = new List<DiscoveryMetadata>(); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BraodcastMetaDataAlias, alias)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadMetaDataIPAddresses, ipAddressRange)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataSubsystemTag, DateTime.Now.ToString(_dateTimeFormat))); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataAssemblyTag, assemblyTag)); _NetworkHost = new NetworkHost<ISubsystem>(_SubsystemHost, new Uri(uri), list); //monitor assembly file system directory for modified time _FileSystemWatcher = new FileSystemWatcher(); _FileSystemWatcher.Path = AppDomain.CurrentDomain.BaseDirectory; _FileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite; _FileSystemWatcher.Filter = "*.*"; _FileSystemWatcher.IncludeSubdirectories = true; _FileSystemWatcher.Changed += new FileSystemEventHandler(OnChanged); _FileSystemWatcher.Error += new ErrorEventHandler(FSWatcher_Error); }
private string GetTftpSessionId(NetworkHost sourceHost, ushort sourcePort, NetworkHost destinationHost, ushort destinationPort) { string sourceString = sourceHost.IPAddress.ToString() + "\t" + sourcePort.ToString(); string destinationString = destinationHost.IPAddress.ToString() + "\t" + destinationPort.ToString(); if (sourceString.CompareTo(destinationString) > 0) { return(sourceString + "\t" + destinationString); } else { return(destinationString + "\t" + sourceString); } }
public int ExtractData(NetworkTcpSession tcpSession, NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <Packets.AbstractPacket> packetList) { int bytesParsed = 0; foreach (Packets.AbstractPacket p in packetList) { //if(p.GetType().IsSubclassOf(typeof(Packets.NetBiosSessionService))) if (p.GetType() == typeof(Packets.NetBiosSessionService)) { bytesParsed += ((Packets.NetBiosSessionService)p).ParsedBytesCount; } } return(bytesParsed); }
public void TestNetworkHostConnect() { NetworkHost host = new NetworkHost(); TcpClient client; try { client = host.Connect("192.168.0.105"); Assert.IsType <TcpClient>(client); } catch (Exception ex) { Assert.IsType <Exception>(ex); } }
public ParametersEventArgs(long frameNumber, NetworkHost sourceHost, NetworkHost destinationHost, string sourcePort, string destinationPort, IEnumerable <KeyValuePair <string, string> > parameters, DateTime timestamp, string details) { this.FrameNumber = frameNumber; this.SourceHost = sourceHost; this.DestinationHost = destinationHost; this.SourcePort = sourcePort; this.DestinationPort = destinationPort; this.Parameters = new System.Collections.Specialized.NameValueCollection(); foreach (KeyValuePair <string, string> kvp in parameters) { this.Parameters.Add(kvp.Key, kvp.Value); } this.Timestamp = timestamp; this.Details = details; }
public static void SendNetworkMessage(int objectID, object obj, DeliveryMethod deliveryMethod = DeliveryMethod.ReliableSequenced) { // send message host -> client if (GameController.Instance.IsHost) { NetworkHost host = GameController.Instance.host; host.netManager.SendToAll(host.netPacketProcessor.Write(NetworkMessages.ToPacket(objectID, obj)), deliveryMethod); } // send message client -> host else { NetworkClient client = GameController.Instance.client; client.netManager.SendToAll(client.netPacketProcessor.Write(NetworkMessages.ToPacket(objectID, obj)), deliveryMethod); } }
internal PendingFileTransfer(NetworkHost dataSessionClient, ushort?dataSessionClientPort, NetworkHost dataSessionServer, ushort dataSessionServerPort, bool dataSessionIsPassive, FtpSession ftpControlSession) { this.dataSessionClient = dataSessionClient; this.dataSessionClientPort = dataSessionClientPort; this.dataSessionServer = dataSessionServer; this.dataSessionServerPort = dataSessionServerPort; this.dataSessionIsPassive = dataSessionIsPassive; this.fileDirectionIsDataSessionServerToDataSessionClient = null; this.fileTransferSessionEstablished = false; this.ftpControlSession = ftpControlSession; this.filename = null; this.details = ""; }
public static void SendNetworkMessageToPeer(int peerID, int objectID, object obj, DeliveryMethod deliveryMethod = DeliveryMethod.ReliableSequenced) { // send message host -> specific client if (!GameController.Instance.IsHost) { throw new InvalidOperationException("Can only use this method as host."); } NetworkHost host = GameController.Instance.host; foreach (NetPeer peer in host.netManager) { if (peer.Id == peerID) { peer.Send(host.netPacketProcessor.Write(NetworkMessages.ToPacket(objectID, obj)), deliveryMethod); } } }
public MessageEventArgs(PacketParser.ApplicationLayerProtocol protocol, NetworkHost sourceHost, NetworkHost destinationHost, int startFrameNumber, DateTime startTimestamp, string from, string to, string subject, string message, System.Collections.Specialized.NameValueCollection attributes) { this.Protocol = protocol; this.SourceHost = sourceHost; this.DestinationHost = destinationHost; this.StartFrameNumber = startFrameNumber; this.StartTimestamp = startTimestamp; this.From = from; this.To = to; this.Subject = subject; if (this.Subject != null && this.Subject.Length > MAX_SUBJECT_LENGTH) { this.Subject = this.Subject.Substring(0, MAX_SUBJECT_LENGTH) + "..."; } this.Message = message; this.Attributes = attributes; }
private void ExtractData(Packets.UpnpPacket upnpPacket, NetworkHost sourceHost) { if (upnpPacket.FieldList.Count > 0) { if (sourceHost.UniversalPlugAndPlayFieldList == null) { sourceHost.UniversalPlugAndPlayFieldList = new SortedList <string, string>(); } foreach (string field in upnpPacket.FieldList) { if (!sourceHost.UniversalPlugAndPlayFieldList.ContainsKey(field)) { sourceHost.UniversalPlugAndPlayFieldList.Add(field, field); } } } }
public DashboardAccess() { string Alias = ConfigurationManager.AppSettings["Alias"]; string ipAddressRange = ConfigurationManager.AppSettings["AllowedIPList"]; string uri = (String)ConfigurationManager.AppSettings["ConnectionUri"]; string path = AppDomain.CurrentDomain.BaseDirectory; string[] Directories = Directory.GetDirectories(path); DateTime lastModifiedTime = new DateTime(); if (Directories.Length > 0) { foreach (string dir in Directories) { string[] Files = Directory.GetFiles(dir); foreach (string file in Files) { if (lastModifiedTime < File.GetLastWriteTime(file)) { lastModifiedTime = File.GetLastWriteTime(file); } } } } List <DiscoveryMetadata> list = new List <DiscoveryMetadata>(); string assemblyTag = lastModifiedTime.ToString("yyyy-MM-dd_h-m-s-fff"); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BraodcastMetaDataAlias, Alias)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadMetaDataIPAddresses, ipAddressRange)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataSubsystemTag, DateTime.Now.ToString())); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataAssemblyTag, assemblyTag)); host = new NetworkHost <ISubsystem>(new SubsystemHost(Alias, assemblyTag), new Uri(uri), list); //monitor assembly file system directory for modified time m_FileSystemWatcher = new FileSystemWatcher(); m_FileSystemWatcher.Path = path; m_FileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite; m_FileSystemWatcher.Filter = "*.*"; m_FileSystemWatcher.IncludeSubdirectories = true; m_FileSystemWatcher.Changed += new FileSystemEventHandler(OnChanged); m_FileSystemWatcher.Error += new ErrorEventHandler(FSWatcher_Error); }
public DashboardAccess() { string Alias = ConfigurationManager.AppSettings["Alias"]; string ipAddressRange = ConfigurationManager.AppSettings["AllowedIPList"]; string uri = (String)ConfigurationManager.AppSettings["ConnectionUri"]; string path = AppDomain.CurrentDomain.BaseDirectory; string[] Directories = Directory.GetDirectories(path); DateTime lastModifiedTime = new DateTime(); if (Directories.Length > 0) { foreach (string dir in Directories) { string[] Files = Directory.GetFiles(dir); foreach (string file in Files) { if (lastModifiedTime < File.GetLastWriteTime(file)) { lastModifiedTime = File.GetLastWriteTime(file); } } } } List<DiscoveryMetadata> list = new List<DiscoveryMetadata>(); string assemblyTag = lastModifiedTime.ToString("yyyy-MM-dd_h-m-s-fff"); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BraodcastMetaDataAlias, Alias)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadMetaDataIPAddresses, ipAddressRange)); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataSubsystemTag, DateTime.Now.ToString())); list.Add(new DiscoveryMetadata(SubsystemCommInfo.BroadcastMetaDataAssemblyTag, assemblyTag)); host = new NetworkHost<ISubsystem>(new SubsystemHost(Alias, assemblyTag), new Uri(uri), list); //monitor assembly file system directory for modified time m_FileSystemWatcher = new FileSystemWatcher(); m_FileSystemWatcher.Path = path; m_FileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite; m_FileSystemWatcher.Filter = "*.*"; m_FileSystemWatcher.IncludeSubdirectories = true; m_FileSystemWatcher.Changed += new FileSystemEventHandler(OnChanged); m_FileSystemWatcher.Error += new ErrorEventHandler(FSWatcher_Error); }
public void ExtractData(ref NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <PacketParser.Packets.AbstractPacket> packetList) { Packets.UdpPacket udpPacket = null; foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.UdpPacket)) { udpPacket = (Packets.UdpPacket)p; } else if (udpPacket != null && p.GetType() == typeof(Packets.RtpPacket)) { Packets.RtpPacket rtpPacket = (Packets.RtpPacket)p; if (Enum.IsDefined(typeof(RtpPayloadType), rtpPacket.PayloadType)) { RtpPayloadType payloadType = (RtpPayloadType)rtpPacket.PayloadType; FiveTuple fiveTuple = new FiveTuple(sourceHost, udpPacket.SourcePort, destinationHost, udpPacket.DestinationPort, FiveTuple.TransportProtocol.UDP); AudioStream audioStream; Tuple <System.Net.IPAddress, ushort, System.Net.IPAddress, ushort, RtpPayloadType> key = new Tuple <System.Net.IPAddress, ushort, System.Net.IPAddress, ushort, RtpPayloadType>(sourceHost.IPAddress, udpPacket.SourcePort, destinationHost.IPAddress, udpPacket.DestinationPort, payloadType); if (this.audioStreams.ContainsKey(key)) { audioStream = this.audioStreams[key]; } else { //FileTransfer.FileStreamAssembler assembler = new FileTransfer.FileStreamAssembler(MainPacketHandler.FileStreamAssemblerList, fiveTuple, true, FileTransfer.FileStreamTypes.RTP, "AudioStream-" + fiveTuple.GetHashCode() + ".wav", "/", "RTP " + fiveTuple.ToString(), rtpPacket.ParentFrame.FrameNumber, rtpPacket.ParentFrame.Timestamp); //-1 is set instead of null if Content-Length is not defined //assembler.FileContentLength = -1; //assembler.FileSegmentRemainingBytes = -1; //this.MainPacketHandler.FileStreamAssemblerList.Add(assembler); //audioStream = new AudioStream(sourceHost, destinationHost, wavAudioFormat.Value, MainPacketHandler.FileStreamAssemblerList, fiveTuple, rtpPacket.ParentFrame.FrameNumber); audioStream = new AudioStream(sourceHost, destinationHost, payloadType, MainPacketHandler.FileStreamAssemblerList, fiveTuple, rtpPacket.ParentFrame.FrameNumber); this.audioStreams.Add(key, audioStream); base.MainPacketHandler.OnAudioDetected(audioStream); } audioStream.AddSamples(rtpPacket.ParentFrame.Data.Skip(rtpPacket.PacketStartIndex + Packets.RtpPacket.HEADER_LENGTH).ToArray(), rtpPacket.SampleTick, rtpPacket.ParentFrame.Timestamp, rtpPacket.SyncSourceID); } } } }
/// <summary> /// /// </summary> /// <param name="sourceHost"></param> /// <param name="sourcePort"></param> /// <param name="destinationHost"></param> /// <param name="destinationPort"></param> /// <param name="tcpTransfer">True=TCP, False=UDP</param> /// <param name="fileStreamType"></param> /// <param name="filename">for example "image.gif"</param> /// <param name="fileLocation">for example "/images", empty string for root folder</param> internal FileStreamAssembler(FileStreamAssemblerList parentAssemblerList, NetworkHost sourceHost, ushort sourcePort, NetworkHost destinationHost, ushort destinationPort, bool tcpTransfer, FileStreamTypes fileStreamType, string filename, string fileLocation, int fileContentLength, int fileSegmentRemainingBytes, string details, string extendedFileId, int initialFrameNumber, DateTime timestamp) { this.parentAssemblerList = parentAssemblerList; this.sourceHost = sourceHost; this.sourcePort = sourcePort; this.destinationHost = destinationHost; this.destinationPort = destinationPort; this.tcpTransfer = tcpTransfer; this.fileStreamType = fileStreamType; this.fileContentLength = fileContentLength;//this one can not be set already when the client requests the file...so it has to be changed later this.fileSegmentRemainingBytes = fileSegmentRemainingBytes; this.details = details; this.contentEncoding = Packets.HttpPacket.ContentEncodings.Identity;//default this.isActive = false; this.extendedFileId = extendedFileId; this.initialFrameNumber = initialFrameNumber; this.timestamp = timestamp; this.filename = filename; this.fileLocation = fileLocation; //Sigh I just hate the limitation on file and folder length. //See: http://msdn2.microsoft.com/en-us/library/aa365247.aspx //Or: http://blogs.msdn.com/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx //see if there is any fileLocation info in the filename and move it to the fileLocation FixFilenameAndLocation(ref this.filename, ref this.fileLocation); this.assembledByteCount = 0; this.tcpPacketBufferWindow = new SortedList <uint, byte[]>(); if (isActive) { this.fileStream = new System.IO.FileStream(GetFilePath(true), System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite); } else { this.fileStream = null; } }
// Use this for initialization void Awake() { networkHost = NetworkHost.GetInstance(); playerEneityRegistered = false; serverGameObjects = new Dictionary <int, Dictionary <int, GameObject> > { { GameSettings.OTHER_PLAYER_TYPE, new Dictionary <int, GameObject>() }, { GameSettings.MONSTER_TYPE, new Dictionary <int, GameObject>() }, { GameSettings.MISSILE_TYPE, new Dictionary <int, GameObject>() }, }; serverGameObjectsMovement = new Dictionary <int, Dictionary <int, Vector3> > { { GameSettings.OTHER_PLAYER_TYPE, new Dictionary <int, Vector3>() }, { GameSettings.MONSTER_TYPE, new Dictionary <int, Vector3>() }, { GameSettings.MISSILE_TYPE, new Dictionary <int, Vector3>() }, }; }
public void CleanupNetwork() { if (IsHost) { Destroy(host); host = null; Destroy(matchmakingHost); matchmakingHost = null; } else { Destroy(client); client = null; Destroy(matchmakingClient); matchmakingClient = null; } Destroy(GetComponent <NetworkSync>()); IsHost = false; }
public int ExtractData(NetworkTcpSession tcpSession, NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <PacketParser.Packets.AbstractPacket> packetList) { foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.SshPacket)) { Packets.SshPacket sshPacket = (Packets.SshPacket)p; if (!sourceHost.ExtraDetailsList.ContainsKey("SSH Version")) { sourceHost.ExtraDetailsList.Add("SSH Version", sshPacket.SshVersion); } if (!sourceHost.ExtraDetailsList.ContainsKey("SSH Application")) { sourceHost.ExtraDetailsList.Add("SSH Application", sshPacket.SshApplication); } return(p.PacketLength); } } return(0); }
public void ExtractData(ref NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <Packets.AbstractPacket> packetList) { //Packets.IIPPacket ipPacket = null; Packets.ITransportLayerPacket transportLayerPacket = null; foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.NetBiosNameServicePacket)) { ExtractData((Packets.NetBiosNameServicePacket)p, sourceHost, destinationHost, transportLayerPacket); } /*else if (p is Packets.IIPPacket) * ipPacket = (Packets.IIPPacket)p;*/ else if (p is Packets.ITransportLayerPacket tlp) { transportLayerPacket = tlp; } } }
private void Awake() { inNeedle = false; inIce = false; shootableMask = LayerMask.GetMask("Shootable"); tempNeedleTrap = null; tempIceTrap = null; shootRay = new Ray(); foreach (Transform child in transform) { if (child.gameObject.name == "ShootingPivot") { shootingPivot = child.gameObject; break; } } networkHost = NetworkHost.GetInstance(); }
internal NetworkCredential GetCredential(NetworkHost sourceHost, NetworkHost destinationHost, DateTime timestamp) { string credentialUser = ""; if (this.nick != null) { credentialUser = this.nick; } if (this.user != null) { credentialUser += "(IRC User: "******")"; } string credentialPassword = "******"; if (this.pass != null) { credentialPassword = this.pass; } return(new NetworkCredential(sourceHost, destinationHost, "IRC", credentialUser, credentialPassword, timestamp)); }
// Use this for initialization void Start() { KnownPeople = new HashSet <NetworkInfo>(); Serializer = new JSONPacketSerializer(); // Network = new NetworkHost(9560, 1); Network.ConfigureChannel("broadcast", ChannelType.UnreliableUnordered); Network.Open(); // Mark broadcast credentials Network.SetBroadcastCredentials(1234, 1); // NetworkHost.StartBroadcast(Network, Encoding.ASCII.GetBytes(NetworkHost.GetLocalAddress())); // var textUi = GetComponent <Text>(); textUi.text = ""; }
public void GetServerIP(string roomCode) { // If host is wanting its own local IP address if (roomCode == null) { mResult = NetworkHost.GetLocalAddress(); return; } mResult = null; string url = ServerLookupHostname + "/api/queryserver" + "?roomCode=" + roomCode; Debug.Log("Making webrequest to: " + url); WebRequest req = WebRequest.Create(url); req.ContentType = "application/json; charset=utf-8"; WebResponse res = req.GetResponse(); Stream resStream = res.GetResponseStream(); StreamReader reader = new StreamReader(resStream); string resData = reader.ReadToEnd(); Debug.Log(resData); reader.Close(); res.Close(); Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(resData); if (data["status"] == "ok") { mResult = data["ip"]; } else { mResult = "failure"; } }
// Update is called once per frame void Update() { Network.ProcessEvents(); // Broadcast Packets BroadcastPacket bPacket; while (Network.ReceiveBroadcast(out bPacket)) { // If not a local address if (!NetworkHost.IsLocalAddress(bPacket.RemoteInfo.Address)) { var address = bPacket.RemoteInfo.Address; var port = bPacket.RemoteInfo.Port; Debug.LogFormat("Broadcast Received From: {0}:{1}", address, port); if (KnownPeople.Contains(bPacket.RemoteInfo)) { continue; } else { KnownPeople.Add(bPacket.RemoteInfo); // var textUi = GetComponent <Text>(); textUi.text += address + "\n"; } } } // Regular Packets Packet packet; while (Network.Receive(out packet)) { // } }
public void ExtractData(ref NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <Packets.AbstractPacket> packetList) { foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.HpSwitchProtocolPacket)) { foreach (Packets.AbstractPacket f in packetList) { if (f.GetType() == typeof(Packets.HpSwitchProtocolPacket.HpSwField) && ((Packets.HpSwitchProtocolPacket.HpSwField)f).TypeByte == (byte)Packets.HpSwitchProtocolPacket.HpSwField.FieldType.IpAddress) { System.Net.IPAddress ip = new System.Net.IPAddress(((Packets.HpSwitchProtocolPacket.HpSwField)f).ValueBytes); if (sourceHost == null || sourceHost.IPAddress != ip) { if (base.MainPacketHandler.NetworkHostList.ContainsIP(ip)) { sourceHost = base.MainPacketHandler.NetworkHostList.GetNetworkHost(ip); } else { sourceHost = new NetworkHost(ip); lock (base.MainPacketHandler.NetworkHostList) base.MainPacketHandler.NetworkHostList.Add(sourceHost); } } } } if (sourceHost != null) { //do the same thing again, but now with the correct sourceHost foreach (Packets.AbstractPacket f in packetList) { if (f.GetType() == typeof(Packets.HpSwitchProtocolPacket.HpSwField)) { ExtractData(ref sourceHost, (Packets.HpSwitchProtocolPacket.HpSwField)f); } } } } } }
public int ExtractData(NetworkTcpSession tcpSession, NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <Packets.AbstractPacket> packetList) { bool successfulExtraction = false; Packets.HttpPacket httpPacket = null; Packets.TcpPacket tcpPacket = null; foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.HttpPacket)) { httpPacket = (Packets.HttpPacket)p; } else if (p.GetType() == typeof(Packets.TcpPacket)) { tcpPacket = (Packets.TcpPacket)p; } } if (httpPacket != null && tcpPacket != null) { if (httpPacket.PacketHeaderIsComplete) { //check if it is a POST and content length is small if (httpPacket.RequestMethod != Packets.HttpPacket.RequestMethods.POST || httpPacket.ContentLength > 4096 /* used to be 1024*/ || httpPacket.ContentIsComplete()) { successfulExtraction = ExtractHttpData(httpPacket, tcpPacket, sourceHost, destinationHost, base.MainPacketHandler); //successfulExtraction=true; } } } if (successfulExtraction) { return(tcpPacket.PayloadDataLength); } else { return(0); } }
public ParametersEventArgs(long frameNumber, FiveTuple fiveTuple, bool transferIsClientToServer, System.Collections.Specialized.NameValueCollection parameters, DateTime timestamp, string details) { this.FrameNumber = frameNumber; if (transferIsClientToServer) { this.SourceHost = fiveTuple.ClientHost; this.DestinationHost = fiveTuple.ServerHost; this.SourcePort = fiveTuple.Transport.ToString() + " " + fiveTuple.ClientPort; this.DestinationPort = fiveTuple.Transport.ToString() + " " + fiveTuple.ServerPort; } else { this.SourceHost = fiveTuple.ServerHost; this.DestinationHost = fiveTuple.ClientHost; this.SourcePort = fiveTuple.Transport.ToString() + " " + fiveTuple.ServerPort; this.DestinationPort = fiveTuple.Transport.ToString() + " " + fiveTuple.ClientPort; } this.Parameters = new System.Collections.Specialized.NameValueCollection(); this.Parameters = parameters; this.Timestamp = timestamp; this.Details = details; }
private void FixedUpdate() { // Run() needs to be called first for this body to execute. if (IsRunning) { // Process network events ( send, receive, broadcast, etc ) NetworkHost.ProcessEvents(); // Process broadcast packets. BroadcastPacket bPacket; while (NetworkHost.ReceiveBroadcast(out bPacket)) { Debug.LogFormat("Received Broadcast: {0} bytes from {1}", bPacket.Data.Length, bPacket.RemoteInfo); } // Process incoming packets from remote connections. if (NetworkHost.ConnectionCount > 0) { PacketQueue.GatherPackets(NetworkHost); } } }
public void ExtractData(ref NetworkHost sourceHost, NetworkHost destinationHost, IEnumerable <PacketParser.Packets.AbstractPacket> packetList) { Packets.UdpPacket udpPacket = null; foreach (Packets.AbstractPacket p in packetList) { if (p.GetType() == typeof(Packets.UdpPacket)) { udpPacket = (Packets.UdpPacket)p; } else if (udpPacket != null && p is Packets.RtpPacket rtpPacket) { //Packets.RtpPacket rtpPacket =(Packets.RtpPacket)p; if (Enum.IsDefined(typeof(RtpPayloadType), rtpPacket.PayloadType)) { RtpPayloadType payloadType = (RtpPayloadType)rtpPacket.PayloadType; FiveTuple fiveTuple = new FiveTuple(sourceHost, udpPacket.SourcePort, destinationHost, udpPacket.DestinationPort, FiveTuple.TransportProtocol.UDP); AudioStream audioStream; Tuple <System.Net.IPAddress, ushort, System.Net.IPAddress, ushort, RtpPayloadType> key = new Tuple <System.Net.IPAddress, ushort, System.Net.IPAddress, ushort, RtpPayloadType>(sourceHost.IPAddress, udpPacket.SourcePort, destinationHost.IPAddress, udpPacket.DestinationPort, payloadType); if (this.audioStreams.ContainsKey(key)) { audioStream = this.audioStreams[key]; } else { audioStream = new AudioStream(sourceHost, destinationHost, payloadType, MainPacketHandler.FileStreamAssemblerList, fiveTuple, rtpPacket.ParentFrame.FrameNumber); this.audioStreams.Add(key, audioStream); base.MainPacketHandler.OnAudioDetected(audioStream); } audioStream.AddSamples(rtpPacket.ParentFrame.Data.Skip(rtpPacket.PacketStartIndex + Packets.RtpPacket.HEADER_LENGTH).ToArray(), rtpPacket.SampleTick, rtpPacket.ParentFrame.Timestamp, rtpPacket.SyncSourceID); } } } }
public static List <NetworkMessage> PopNetworkMessages(int objectID) { if (objectID < 0) { throw new InvalidOperationException("GameObject has not yet been assigned an ObjectID."); } // fetch host's messages from clients if (GameController.Instance.IsHost) { NetworkHost host = GameController.Instance.host; List <NetworkMessage> messages = new List <NetworkMessage>(); foreach (int peerId in host.clientMessages.Keys) { messages.AddRange(host.clientMessages[peerId].PopMessages(objectID).Select(x => new NetworkMessage() { contents = x, peerId = peerId })); } return(messages); } // fetch client's messages from host else { NetworkClient client = GameController.Instance.client; if (client == null) { return(new List <NetworkMessage>()); } return(client.messages.PopMessages(objectID).Select(x => new NetworkMessage() { contents = x, peerId = client.netManager.FirstPeer.Id }).ToList()); } }
public EventsLoggerHost (Uri baseAddress, string MSMQAddress, string MSMQNamespace) { List<DiscoveryMetadata> list = new List<DiscoveryMetadata>(); list.Add(new DiscoveryMetadata(CommuncationInfo.MetaDataIPAddresses, "*")); host = new NetworkHost<IEventsLogger>(this, baseAddress, MSMQAddress, list, MSMQNamespace); }
internal static string GetKey(NetworkHost dataSessionClient, ushort?dataSessionClientPort, NetworkHost dataSessionServer, ushort?dataSessionServerPort) { StringBuilder sb = new StringBuilder(); sb.Append("Data session client : "); sb.Append(dataSessionClient.IPAddress.ToString()); sb.Append(" TCP/"); sb.Append(dataSessionClientPort.ToString()); sb.Append("\nData session server : "); sb.Append(dataSessionServer.IPAddress.ToString()); sb.Append(" TCP/"); sb.Append(dataSessionServerPort.ToString()); return(sb.ToString()); }
private void Awake() { inTrapGameObjects = new ArrayList(); networkHost = NetworkHost.GetInstance(); timer = 0f; }
public DetectorPlotHost(string connectionString, string address, int dataPort) { _networkHost = new NetworkHost<IDetectorPlot>(this, new Uri(connectionString)); _udpClient = new UdpClient(dataPort - 100); _remoteEp = new IPEndPoint(IPAddress.Parse(address), dataPort); }
private void ExtractData(ref NetworkHost sourceHost, NetworkHost destinationHost, Packets.DhcpPacket dhcpPacket) { if (dhcpPacket.OpCode == Packets.DhcpPacket.OpCodeValue.BootRequest && (sourceHost.MacAddress == null || dhcpPacket.ClientMacAddress != sourceHost.MacAddress)) { sourceHost.MacAddress = dhcpPacket.ClientMacAddress; } else if (dhcpPacket.OpCode == Packets.DhcpPacket.OpCodeValue.BootReply && (destinationHost.MacAddress == null || dhcpPacket.ClientMacAddress != destinationHost.MacAddress)) { destinationHost.MacAddress = dhcpPacket.ClientMacAddress; } if (dhcpPacket.OpCode == Packets.DhcpPacket.OpCodeValue.BootReply && (dhcpPacket.GatewayIpAddress != null && dhcpPacket.GatewayIpAddress != System.Net.IPAddress.None && dhcpPacket.GatewayIpAddress.Address > 0)) { destinationHost.ExtraDetailsList["Default Gateway"] = dhcpPacket.GatewayIpAddress.ToString(); } System.Collections.Specialized.NameValueCollection optionParameterList = new System.Collections.Specialized.NameValueCollection(); //now check all the DHCP options //byte dhcpMessageType=0x00;//1=Discover, 2=Offer, 3=Request, 5=Ack, 8=Inform foreach (Packets.DhcpPacket.Option option in dhcpPacket.OptionList) { //TODO: Add option to Parameters list if (option.OptionCode == 12)//hostname { string hostname = Utils.ByteConverter.ReadString(option.OptionValue); sourceHost.AddHostName(hostname); optionParameterList.Add("DHCP Option 12 Hostname", hostname); } else if (option.OptionCode == 15)//Domain Name { string domain = Utils.ByteConverter.ReadString(option.OptionValue); sourceHost.AddDomainName(domain); optionParameterList.Add("DHCP Option 15 Domain", domain); } else if (option.OptionCode == 50) //requested IP address { if (dhcpPacket.DhcpMessageType == 3) //Must be a DHCP Request { System.Net.IPAddress requestedIpAddress = new System.Net.IPAddress(option.OptionValue); if (sourceHost.IPAddress != requestedIpAddress) { if (!base.MainPacketHandler.NetworkHostList.ContainsIP(requestedIpAddress)) { NetworkHost clonedHost = new NetworkHost(requestedIpAddress); clonedHost.MacAddress = sourceHost.MacAddress; //foreach(string hostname in sourceHost.HostNameList) // clonedHost.AddHostName(hostname); lock (base.MainPacketHandler.NetworkHostList) base.MainPacketHandler.NetworkHostList.Add(clonedHost); //now change the host to the cloned one (and hope it works out...) sourceHost = clonedHost; } else { sourceHost = base.MainPacketHandler.NetworkHostList.GetNetworkHost(requestedIpAddress); if (dhcpPacket.OpCode == Packets.DhcpPacket.OpCodeValue.BootRequest && (sourceHost.MacAddress == null || dhcpPacket.ClientMacAddress != sourceHost.MacAddress)) { sourceHost.MacAddress = dhcpPacket.ClientMacAddress; } } } if (sourceHost.MacAddress != null && previousIpList.ContainsKey(sourceHost.MacAddress.ToString())) { //if(previousIpList.ContainsKey(sourceHost.MacAddress.ToString())) { sourceHost.AddNumberedExtraDetail("Previous IP", previousIpList[sourceHost.MacAddress.ToString()].ToString()); //sourceHost.ExtraDetailsList["Previous IP"]=previousIpList[sourceHost.MacAddress.ToString()].ToString(); previousIpList.Remove(sourceHost.MacAddress.ToString()); } } else if (dhcpPacket.DhcpMessageType == 1)//DHCP discover //see which IP address the client hade previously //They normally requests the same IP as they hade before... { System.Net.IPAddress requestedIpAddress = new System.Net.IPAddress(option.OptionValue); this.previousIpList[sourceHost.MacAddress.ToString()] = requestedIpAddress; } } /* * else if(option.OptionCode==53) {//DHCP message type * if(option.OptionValue!=null && option.OptionValue.Length==1) * dhcpMessageType=option.OptionValue[0]; * }/*/ else if (option.OptionCode == 60)//vendor class identifier { string vendorCode = Utils.ByteConverter.ReadString(option.OptionValue); sourceHost.AddDhcpVendorCode(vendorCode); optionParameterList.Add("DHCP Option 60 Vendor Code", vendorCode); } else if (option.OptionCode == 81) //Client Fully Qualified Domain Name { string domain = Utils.ByteConverter.ReadString(option.OptionValue, 3, option.OptionValue.Length - 3); sourceHost.AddHostName(domain); optionParameterList.Add("DHCP Option 81 Domain", domain); } else if (option.OptionCode == 125) //V-I Vendor-specific Information http://tools.ietf.org/html/rfc3925 { uint enterpriceNumber = Utils.ByteConverter.ToUInt32(option.OptionValue, 0); optionParameterList.Add("DHCP Option 125 Enterprise Number", enterpriceNumber.ToString()); byte dataLen = option.OptionValue[4]; if (dataLen > 0 && option.OptionValue.Length >= 5 + dataLen) { string optionData = Utils.ByteConverter.ReadString(option.OptionValue, 5, dataLen); optionParameterList.Add("DHCP Option 125 Data", optionData); } } else { string optionValueString = Utils.ByteConverter.ReadString(option.OptionValue); if (!System.Text.RegularExpressions.Regex.IsMatch(optionValueString, @"[^\u0020-\u007E]")) { optionParameterList.Add("DHCP Option " + option.OptionCode.ToString(), optionValueString); } } } if (optionParameterList.Count > 0) { //try to get the udp packet string sourcePort = "UNKNOWN"; string destinationPort = "UNKNOWN"; foreach (Packets.AbstractPacket p in dhcpPacket.ParentFrame.PacketList) { if (p.GetType() == typeof(Packets.UdpPacket)) { Packets.UdpPacket udpPacket = (Packets.UdpPacket)p; sourcePort = "UDP " + udpPacket.SourcePort; destinationPort = "UDP " + udpPacket.DestinationPort; break; } } Events.ParametersEventArgs ea = new Events.ParametersEventArgs(dhcpPacket.ParentFrame.FrameNumber, sourceHost, destinationHost, sourcePort, destinationPort, optionParameterList, dhcpPacket.ParentFrame.Timestamp, "DHCP Option"); MainPacketHandler.OnParametersDetected(ea); } }
public EventsLoggerHost(Uri address, string msmqAddress, string nameSpace) { List<DiscoveryMetadata> metaData = new List<DiscoveryMetadata>(); metaData.Add(new DiscoveryMetadata(CommuncationInfo.MetaDataIPAddresses, "*")); _host = new NetworkHost<IEventsLogger>(this, address, msmqAddress, metaData, nameSpace); }