/// <summary> /// Initalizes ThreadTypeData to be used by different threads. /// </summary> /// <param name="IPv4Support"></param> /// <param name="IPv6Support"></param> public RegistrarServer(TrafficType traffTypes, TimeSpan timeoutPeriod) { if (timeoutPeriod != TimeSpan.Zero) { this.timeoutPeriod = timeoutPeriod; } clientRegTable = new Hashtable(); if ((traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[2]; ThreadTypeData[0] = TrafficType.IPv4; ThreadTypeData[1] = TrafficType.IPv6; } else if (((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6)) { ThreadTypeData = new TrafficType[1]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4; } else { ThreadTypeData[0] = TrafficType.IPv6; } } else { Debug.Assert(false); throw new Exception("Either IPv6 or IPv4 should be enabled"); } }
/// <summary> /// Creates the threadtype table based on IPv6/IPv4 support /// </summary> public MCtoUC(TrafficType traffTypes) { if ((traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if (((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6)) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception("Either IPv6 or IPv4 should be enabled"); } }
/// <summary> /// Creates the threadtype table based on IPv6/IPv4 support /// </summary> public MCtoUC(TrafficType traffTypes) { if ( (traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if ( ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4 ) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6 ) ) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception("Either IPv6 or IPv4 should be enabled"); } }
private async Task WriteTrafficData(MonitoredPort port, long octets, TrafficType trafficType) { var entity = new CollectedTrafficData { TimeScanned = DateTime.Now, Octets = octets, TrafficType = trafficType, PortNumber = port.PortNumber, SnmpIpAddress = port.SnmpIpAddress }; var existing = await CollectedTrafficDatas.Query() .Where(data => data.TrafficType == trafficType) .Include(data => data.MonitoredPort) .Where(data => data.MonitoredPort.SnmpIpAddress == port.SnmpIpAddress) .Where(data => data.MonitoredPort.PortNumber == port.PortNumber) .OrderByDescending(data => data.TimeScanned) .FirstOrDefaultAsync(); if (existing == null) { entity.DiffedTimeSpan = null; entity.Octets = octets; entity.AbsoluteOctets = octets; } else { entity.DiffedTimeSpan = (entity.TimeScanned - existing.TimeScanned); entity.Octets = (octets - existing.AbsoluteOctets); entity.AbsoluteOctets = octets; } CollectedTrafficDatas.Insert(entity); }
/// <summary> /// Creates the threadtype table based on IPv6/IPv4 support /// </summary> public MCtoUC(RegistrarServer registrar, TrafficType traffTypes) { this.registrar = registrar; if ((traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if (((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6)) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception(Strings.EnableEitherIPv6OrIPv4); } }
public void OnLocationChanged(Location location) { MyLocation = location; if (ActivateButton.Checked) { LocationTextView.Text = "Latitude: " + System.Math.Round(location.Latitude, 7).ToString() + " | Longitude: " + System.Math.Round(location.Longitude, 7).ToString(); try { locationManager.RequestLocationUpdates(locationProvider, 0, 0, this); double speed = location.Speed * 3.6; if (speed >= 30) { MyTrafficType = TrafficType.Auto; SpeedTypeImageView.SetImageResource(Resource.Drawable.car); } else if (speed >= 6) { MyTrafficType = TrafficType.Fahrrad; SpeedTypeImageView.SetImageResource(Resource.Drawable.bike); } else { MyTrafficType = TrafficType.ZuFuß; SpeedTypeImageView.SetImageResource(Resource.Drawable.walk); } SpeedTextView.Text = Math.Round(speed, 1).ToString() + " km/h"; } catch { } } }
public BuyTicketsModel() { date = GameModel.Instance.Start; startlocation = "上海"; stoplocation = "沈阳"; type = TrafficType.Train; }
/// <summary> /// Сгенерировать запрос для получения самых больших значений скорости из каждой таблицы для определенного терминала /// </summary> /// <param name="terminalId">id терминала</param> /// <param name="trafficType">направление трафика</param> /// <param name="quantity">количество записей, получаемых из каждой таблицы</param> /// <returns></returns> private string GenerateTopFivePercentQuery(uint terminalId, TrafficType trafficType, long quantity) { string resultQuery = string.Empty; string queryTemplate = string.Empty; if (trafficType == TrafficType.Downstream) { queryTemplate = Queries.TopFivePercentDownstreamTrafficQueryTemplate; } else if (trafficType == TrafficType.Upstream) { queryTemplate = Queries.TopFivePercentUpstreamTrafficQueryTemplate; } for (int tableIndex = 0; tableIndex < _tablesCount; tableIndex++) { string query = string.Empty; //ota_minute_stats string tableName = string.Format(minuteTableName, tableIndex); string castTableName = string.Format(castMinuteTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); //raw_ota_stats tableName = string.Format(rawTableName, tableIndex); castTableName = string.Format(castRawTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); //ota_hour_stats tableName = string.Format(hourTableName, tableIndex); castTableName = string.Format(castHourTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); } return(resultQuery); }
/// <summary> /// 获取大交通 /// </summary> /// <param name="StartCityName">出发城市</param> /// <param name="trafficType">交通</param> /// <returns></returns> protected string GetBigTraffic(string StartCityName, TrafficType trafficType, string EndCityName, TrafficType endTraffic) { string traffic = string.Empty; traffic = StartCityName + trafficType.ToString() + "出发 " + endTraffic.ToString() + EndCityName + " 回"; return(traffic); }
/// <summary> /// Creates the threadtype table based on IPv6/IPv4 support /// </summary> public MCtoUC(RegistrarServer registrar, TrafficType traffTypes) { this.registrar = registrar; if ( (traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if ( ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4 ) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6 ) ) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception(Strings.EnableEitherIPv6OrIPv4); } }
/// <summary> /// Initalizes all sockets /// </summary> /// <param name="traffTypes">TrafficType indicating whether to initalize IPv6/IPv4 Sockets</param> public void InitAll(TrafficType traffTypes) { try { lock (this) { if (!IsInitalized) { if ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6) { InitSocket(out sockMCv6RTP, TrafficType.MCv6RTP); InitSocket(out sockUCv6RTP, TrafficType.UCv6RTP); InitSocket(out sockMCv6RTCP, TrafficType.MCv6RTCP); InitSocket(out sockUCv6RTCP, TrafficType.UCv6RTCP); } if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { InitSocket(out sockMCv4RTP, TrafficType.MCv4RTP); InitSocket(out sockUCv4RTP, TrafficType.UCv4RTP); InitSocket(out sockMCv4RTCP, TrafficType.MCv4RTCP); InitSocket(out sockUCv4RTCP, TrafficType.UCv4RTCP); } IsInitalized = true; } } } catch (Exception e) { throw new Exception("Socket Initialization Error", e); } }
public void SetTypeOfTraffic(int n) { type = (TrafficType)n; lights = trafficDic.First(dic => dic.type == type).sprites; maxIndex = lights.Length; isReversed = (type == TrafficType.ThreeReverse); SetRandomLight(); ChangeLight(); }
private static IntPtr CreateHandle(TrafficType traffic, bool isMultiPoint, Proximity proximity, Transport transports) { var handle = alljoyn_sessionopts_create((byte)traffic, isMultiPoint.ToQccBool(), (byte)proximity, (ushort)transports); if (handle == IntPtr.Zero) { throw new InvalidOperationException("Could not create session options"); } return(handle); }
protected override void InitUI() { base.InitUI(); Tips.gameObject.SetActive(false); date = BuyTicketsModel.Instance.date; GoDate.text = date.ToString(DateFormat); Src.text = BuyTicketsModel.Instance.startlocation; Dst.text = BuyTicketsModel.Instance.stoplocation; trafficType = BuyTicketsModel.Instance.type; SetToggle(trafficType); }
public TrafficMessage(string st, string sl, string t, string n, string et, string el, string m, bool b, bool d, int i, TrafficType type) { StartTime = st; StartLocation = sl; Time = t; Number = n; EndTime = et; EndLocation = el; Money = m; buy = b; isDelay = d; id = i; trafficType = type; }
public void SetToggle(TrafficType type) { if (type == TrafficType.Plane) { TrainImage.gameObject.SetActive(false); AirImage.gameObject.SetActive(true); } else { TrainImage.gameObject.SetActive(true); AirImage.gameObject.SetActive(false); } BuyTicketsModel.Instance.type = type; }
public void SetToggle(TrafficType type) { if (type == TrafficType.Plane) { AirPlaneImage.enabled = true; TrainImage.enabled = false; } else { TrainImage.enabled = true; AirPlaneImage.enabled = false; } BuyTicketsModel.Instance.type = type; }
/// <summary> /// Initalizes a ThreadType(s) to keep the required initalization data for threads to start /// </summary> public UCtoUCMC(RegistrarServer registrar, TrafficType traffTypes) { this.registrar = registrar; // initialize multicast enabled flag... String setting = ConfigurationManager.AppSettings[AppConfig.SendMulticast]; if (setting != null) { try { SendMulticast = Boolean.Parse(setting); } catch (Exception) { SendMulticast = true; } } if ( (traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if ( ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4 ) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6 ) ) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception(Strings.EnableEitherIPv6OrIPv4); } }
/// <summary> /// Initalizes a ThreadType(s) to keep the required initalization data for threads to start /// </summary> public UCtoUCMC(RegistrarServer registrar, TrafficType traffTypes) { this.registrar = registrar; // initialize multicast enabled flag... String setting = ConfigurationManager.AppSettings[AppConfig.SendMulticast]; if (setting != null) { try { SendMulticast = Boolean.Parse(setting); } catch (Exception) { SendMulticast = true; } } if ((traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[4]; ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv6RTP; ThreadTypeData[2] = TrafficType.IPv4RTCP; ThreadTypeData[3] = TrafficType.IPv6RTCP; } else if (((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6)) { ThreadTypeData = new TrafficType[2]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4RTP; ThreadTypeData[1] = TrafficType.IPv4RTCP; } else { ThreadTypeData[0] = TrafficType.IPv6RTP; ThreadTypeData[1] = TrafficType.IPv6RTCP; } } else { Debug.Assert(false); throw new Exception(Strings.EnableEitherIPv6OrIPv4); } }
public void InitButtonEvent() { back.onClick.AddListener(delegate() { mc.ShowView(ViewID.BuyTickets); }); yesterday.onClick.AddListener(delegate() { SetDate(date.AddDays(-1)); StartCoroutine(Search()); }); tomorrow.onClick.AddListener(delegate() { SetDate(date.AddDays(1)); StartCoroutine(Search()); }); BtnGoData.onClick.AddListener(delegate() { GameObject go = PopUpManager.Instance.AddUiLayerPopUp(Prefabs.Calendar); CalendarView cv = go.GetComponent <CalendarView>(); cv.Date = date; cv.AddCallback(SetDate); PopUpManager.Instance.SetPopupPanelAutoClose(go); }); Train.onValueChanged.AddListener(delegate(bool isOn) { if (isOn) { trafficType = TrafficType.Train; SetToggle(trafficType); StartCoroutine(Search()); } }); Airplane.onValueChanged.AddListener(delegate(bool isOn) { if (isOn) { trafficType = TrafficType.Plane; SetToggle(trafficType); StartCoroutine(Search()); } }); }
public Session(TrafficType traffic, bool isMultiPoint, Proximity proximity, Transport transports) : base(CreateHandle(traffic, isMultiPoint, proximity, transports)) { }
public async Task <List <PortStatistics> > GetHighscore(int countOfEntries, DateTime startTime, DateTime endTime, TrafficType type) { try { var entriesInTimespan = await CollectedTrafficDatas.Query() .Where(data => data.TrafficType == type) .Where(data => data.DiffedTimeSpan != null) .Include(data => data.MonitoredPort) .Where(data => !data.MonitoredPort.ExcludeFromStatistics) .GroupBy(data => data.MonitoredPort) .Select(data => data.Where(inner => inner.TimeScanned >= startTime)) .Select(data => data.Where(inner => inner.TimeScanned <= endTime)) .Select(data => data.OrderBy(inner => inner.TimeScanned)) .Select(data => new { Sum = data.Sum(inner => inner.Octets), Data = data }) .OrderByDescending(data => data.Sum) .Take(countOfEntries) .ToListAsync(); var desiredSampledSeconds = (endTime - startTime).TotalSeconds; var results = new List <PortStatistics>(); var monitoredPorts = await MonitoredPorts.Query() .Include(port => port.SnmpTarget) .ToListAsync(); foreach (var entry in entriesInTimespan) { var sampledSeconds = entry.Data.Sum(entity => entity.DiffedTimeSpan.Value.TotalSeconds); var correctionFactor = (float)desiredSampledSeconds / sampledSeconds; var trafficInSpan = (long)(correctionFactor * entry.Sum); var result = new PortStatistics { MonitoredPort = monitoredPorts.FirstOrDefault( port => port.SnmpIpAddress == entry.Data.FirstOrDefault().SnmpIpAddress&& port.PortNumber == entry.Data.FirstOrDefault().PortNumber), }; result.SnmpTarget = result.MonitoredPort.SnmpTarget; result.Comment = result.MonitoredPort.Comment; var bytesPerSecond = trafficInSpan / desiredSampledSeconds; var ordinals = new[] { "", "K", "M", "G", "T", "P", "E" }; var ordinal = 0; while (bytesPerSecond > 1024) { bytesPerSecond /= 1024; ordinal++; } result.EstimatedSpeed = String.Format("{0} {1}b/s", Math.Round(bytesPerSecond, 2, MidpointRounding.AwayFromZero), ordinals[ordinal]); switch (type) { case TrafficType.Inbound: result.InboundTraffic = trafficInSpan; break; case TrafficType.Outbound: result.OutboundTraffic = trafficInSpan; break; } results.Add(result); } return(results); } catch { return(new List <PortStatistics>()); } }
void SpawnVehicle(TrafficType type) { int randomIndex = -1; Spawner randomSpawner = null; WaypointMovementController spawnedVehicle = null; switch (type) { case TrafficType.Car: //Spawn car at random Spawner position randomIndex = UnityEngine.Random.Range(0, CarSpawners.Length); randomSpawner = CarSpawners[randomIndex]; if (randomSpawner.Object.GetComponent <Spawn>().PositionIsOccupied) { //Spawner position is already occupied by another unit, don't spawn. return; } spawnedVehicle = Instantiate(CarPrefab, randomSpawner.Object.transform.position, Quaternion.identity).GetComponent <WaypointMovementController>(); spawnedVehicle.transform.parent = CarParent.transform; spawnedVehicle.spawnLocation = randomSpawner.Location; break; case TrafficType.Train: //Spawn train at random Spawner position randomIndex = UnityEngine.Random.Range(0, TrainSpawners.Length); randomSpawner = TrainSpawners[randomIndex]; if (randomSpawner.Object.GetComponent <Spawn>().PositionIsOccupied) { //Spawner position is already occupied by another unit, don't spawn. return; } spawnedVehicle = Instantiate(TrainPrefab, randomSpawner.Object.transform.position, Quaternion.identity).GetComponent <WaypointMovementController>(); spawnedVehicle.transform.parent = TrainParent.transform; spawnedVehicle.spawnLocation = randomSpawner.Location; break; case TrafficType.Boat: //Spawn boat at random Spawner position randomIndex = UnityEngine.Random.Range(0, BoatSpawners.Length); randomSpawner = BoatSpawners[randomIndex]; if (randomSpawner.Object.GetComponent <Spawn>().PositionIsOccupied) { //Spawner position is already occupied by another unit, don't spawn. return; } spawnedVehicle = Instantiate(BoatPrefab, randomSpawner.Object.transform.position, Quaternion.identity).GetComponent <WaypointMovementController>(); spawnedVehicle.transform.parent = BoatParent.transform; spawnedVehicle.spawnLocation = randomSpawner.Location; break; case TrafficType.Bicycle: //Spawn cyclist at random Spawner position randomIndex = UnityEngine.Random.Range(0, CyclistSpawners.Length); randomSpawner = CyclistSpawners[randomIndex]; if (randomSpawner.Object.GetComponent <Spawn>().PositionIsOccupied) { //Spawner position is already occupied by another unit, don't spawn. return; } spawnedVehicle = Instantiate(CyclistPrefab, randomSpawner.Object.transform.position, Quaternion.identity).GetComponent <WaypointMovementController>(); spawnedVehicle.transform.parent = CyclistParent.transform; spawnedVehicle.spawnLocation = randomSpawner.Location; break; case TrafficType.Pedestrian: //Spawn pedestrian at random Spawner position randomIndex = UnityEngine.Random.Range(0, PedestrianSpawners.Length); randomSpawner = PedestrianSpawners[randomIndex]; if (randomSpawner.Object.GetComponent <Spawn>().PositionIsOccupied) { //Spawner position is already occupied by another unit, don't spawn. return; } spawnedVehicle = Instantiate(PedestrianPrefab, randomSpawner.Object.transform.position, Quaternion.identity).GetComponent <WaypointMovementController>(); spawnedVehicle.transform.parent = PedestrianParent.transform; spawnedVehicle.spawnLocation = randomSpawner.Location; break; } }
public void AddTrafficType(TrafficType trType) { throw new NotImplementedException(); }
public AirportTrafficMVVM(Airport destination, long value, TrafficType type) { this.Destination = destination; this.Value = value; this.Type = type; }
/// <summary> /// Сгенерировать запрос для получения самых больших значений скорости из каждой таблицы для определенного терминала /// </summary> /// <param name="terminalId">id терминала</param> /// <param name="trafficType">направление трафика</param> /// <param name="quantity">количество записей, получаемых из каждой таблицы</param> /// <returns></returns> private string GenerateTopFivePercentQuery(uint terminalId, TrafficType trafficType, long quantity) { string resultQuery = string.Empty; string queryTemplate = string.Empty; if (trafficType == TrafficType.Downstream) queryTemplate = Queries.TopFivePercentDownstreamTrafficQueryTemplate; else if (trafficType == TrafficType.Upstream) queryTemplate = Queries.TopFivePercentUpstreamTrafficQueryTemplate; for (int tableIndex = 0; tableIndex < _tablesCount; tableIndex++) { string query = string.Empty; //ota_minute_stats string tableName = string.Format(minuteTableName, tableIndex); string castTableName = string.Format(castMinuteTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); //raw_ota_stats tableName = string.Format(rawTableName, tableIndex); castTableName = string.Format(castRawTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); //ota_hour_stats tableName = string.Format(hourTableName, tableIndex); castTableName = string.Format(castHourTableName, tableIndex); if (trafficType == TrafficType.Upstream) { query = string.Format(queryTemplate, tableName, terminalId, _startPeriodString, _endPeriodString, quantity); } else if (trafficType == TrafficType.Downstream) { query = string.Format(queryTemplate, tableName, castTableName, terminalId, _startPeriodString, _endPeriodString, quantity); } resultQuery = UnionQueries(resultQuery, query); } return resultQuery; }
private void Awake() { trafficType = TrafficType.Train; base.Awake(); }
/// <summary> /// Intitalizes one socket based on the given parameters. /// </summary> /// <param name="sock">The socket class to be initalized</param> /// <param name="addrFamily">The address family for the socket to be initalized to (InterNetwork/InterNetworkV6)</param> /// <param name="isUnicast">Wether this socket is to be used for Multicast or Unicast</param> /// <param name="traffType">Wether this socket is to be used for RTP traffic or RTCP</param> private static void InitSocket(out Socket sock, TrafficType traffTypes) { int bindPort = 0; SocketOptionLevel sOL = 0; AddressFamily addrFamily = AddressFamily.InterNetwork; IPAddress bindInterface = null; #region initalizing bindPort, sOL, addrFamily and BindInterface based on function prarameters switch (traffTypes) { case TrafficType.UCv4RTP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.UCv4RTCP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTCP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTCP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTCP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; default: Debug.Assert(false); throw new ArgumentException("Invalid traffic type combination"); } #endregion sock = new Socket(addrFamily, SocketType.Dgram, ProtocolType.Udp); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 1500 * 160); // Multicast receive only if ((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, -1); } // Unicast socket sends multicast data, so set some multicast sending properties on it if ((traffTypes & TrafficType.Unicast) == TrafficType.Unicast) { sock.SetSocketOption(sOL, SocketOptionName.MulticastTimeToLive, 128); // Only set this value if it is other than the default if(ReflectorMgr.MulticastInterfaceRouteIndex > 0) { sock.SetSocketOption(sOL, SocketOptionName.MulticastInterface, (int)IPAddress.HostToNetworkOrder(ReflectorMgr.MulticastInterfaceRouteIndex)); } } sock.Bind(new IPEndPoint(bindInterface, bindPort)); if (((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) && (! ReflectorMgr.MCLoopbackOff)) { sock.SetSocketOption(sOL, SocketOptionName.MulticastLoopback, 1); } }
/// <summary> /// Starts listening in an infinite loop for incomming connections from RegistrarClient. Here are the /// scenarios: /// Client Request Client Status in Table Table Action Server Response to Client /// ------------------- ---------------------- ------------ ------------------------- /// 1 Msg(Join,GIP,GP,N) (CIP, GIP, GP) entry NOT FOUND Insert Msg(Confirm,GIP,GP,RndConfirmNum) /// 2 Msg(Join,GIP,GP,N) (CIP, GIP, GP) entry FOUND None Msg(ReConfirm,GIP,GP,FoundConfirmNum) /// 3 Msg(Leave,GIP,GP,ConfirmNum) Entry Found ConirmNum match Delete Msg(Confirm,GIP,GP,FoundConfirmNum) /// 4 Msg(Leave,GIP,GP,ConfirmNum) Entry Found ConirmNum mismatch None Msg(ConfirmNumMismatchError,0,0,0) /// 5 Msg(Leave,GIP,GP,ConfirmNum) Entry Not Found None Msg(LeaveWithoutJoinError,0,0,0) /// 6 Msg(Leave,GIP,GP,ConfirmNum) Lookup Error None Msg(UnknownError,0,0,0) /// /// </summary> public void Start() { TrafficType traffTypes = TrafficType.None; if (idxRSThreadTypeData < ThreadTypeData.Length) { lock (ThreadTypeData) { traffTypes = ThreadTypeData[idxRSThreadTypeData]; System.Threading.Thread.CurrentThread.Name = "Reflector_RegistrarServer_" + traffTypes.ToString(); idxRSThreadTypeData++; } } else { throw new Exception("Number of created threads exceed the number of thread types defined."); } IPEndPoint localEP; if ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6) { localEP = new IPEndPoint(IPAddress.IPv6Any, ReflectorMgr.RegistrarServerPort); } else { localEP = new IPEndPoint(IPAddress.Any, ReflectorMgr.RegistrarServerPort); } // Initializing the TCP server NetworkStream netStream; BinaryFormatter bf = new BinaryFormatter(); Object obj; RegisterMessage regMsg, regMsgResponse; // Initializing the TcpListener TcpListener tcpL = new TcpListener(localEP); if ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6) { tcpLv6 = tcpL; } else { tcpLv4 = tcpL; } tcpL.Start(); Socket srvS = null; // An inifinite loop which works as follows: // 1. Block until a connection arrives. // 2. If it is a join request // Lookup (ClientIP,GroupIP,GroupPort) and send back Confirm or ReConfirm // 2. If it is a leave request // Lookup (ClientIP,GroupIP,GroupPort) and if exist send back Confirm or ConfirmNumMismatch // if not exist send back LeaveWithoutJoinError // if unknown error send back UnknownError // 2. If neither join nor leave // send back InvalidRequest // 3. Close the connection. // while (true) { try { srvS = tcpL.AcceptSocket(); // Can't use AcceptTcpClient since the client information is protected netStream = new NetworkStream(srvS, System.IO.FileAccess.ReadWrite, true); //Getting a network stream so I can serialize the class into it. // Getting the request Object from stream obj = bf.Deserialize(netStream); regMsg = (RegisterMessage)obj; eventLog.WriteEntry("RegistrarServer: Received Request:" + regMsg.ToString(), EventLogEntryType.Information, (int)ReflectorEventLog.ID.JoinLeave); switch (regMsg.msgType) { case MessageType.Join: // Processing Join Request regMsgResponse = ProcessJoinRequest(regMsg, ((IPEndPoint)srvS.RemoteEndPoint).Address); break; case MessageType.Leave: // Processing Leave Request regMsgResponse = ProcessLeaveRequest(regMsg, ((IPEndPoint)srvS.RemoteEndPoint).Address); break; default: // Invalid Message Type regMsgResponse = new RegisterMessage(MessageType.InvalidRequest, IPAddress.Any); break; } bf.Serialize(netStream, regMsgResponse); netStream.Close(); srvS.Close(); } // On stopping the service, avoid the AbortException written in the event viewer catch (ThreadAbortException) {} catch (Exception e) { eventLog.WriteEntry("RegistrarServer: Network Error while receiving/sending request message. Client: " + ((srvS != null)?((IPEndPoint)srvS.RemoteEndPoint).ToString():"") + " " + e.ToString(), EventLogEntryType.Error, (int)ReflectorEventLog.ID.Error); } } // end while } // end Start method
/// <summary> /// Initalizes ThreadTypeData to be used by different threads. /// </summary> /// <param name="IPv4Support"></param> /// <param name="IPv6Support"></param> public RegistrarServer(TrafficType traffTypes, TimeSpan timeoutPeriod) { if(timeoutPeriod != TimeSpan.Zero) { this.timeoutPeriod = timeoutPeriod; } clientRegTable = new Hashtable(); if ( (traffTypes & TrafficType.IPv4andIPv6) == TrafficType.IPv4andIPv6) { ThreadTypeData = new TrafficType[2]; ThreadTypeData[0] = TrafficType.IPv4; ThreadTypeData[1] = TrafficType.IPv6; } else if ( ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4 ) || ((traffTypes & TrafficType.IPv6) == TrafficType.IPv6 ) ) { ThreadTypeData = new TrafficType[1]; if ((traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { ThreadTypeData[0] = TrafficType.IPv4; } else { ThreadTypeData[0] = TrafficType.IPv6; } } else { Debug.Assert(false); throw new Exception("Either IPv6 or IPv4 should be enabled"); } }
protected override void Awake() { type = TrafficType.Train; base.Awake(); }
/// <summary> /// The constructor which reads config setting and calls the constructor for the sockets and three servers. /// </summary> public ReflectorMgr() { string setting; if ((setting = ConfigurationManager.AppSettings[AppConfig.JoinPort]) != null) { registrarServerPort = int.Parse(setting); } if ((setting = ConfigurationManager.AppSettings[AppConfig.UnicastPort]) != null) { reflectorUnicastRTPListenPort = int.Parse(setting); } TimeSpan timeoutPeriod = TimeSpan.Zero; if ((setting = ConfigurationManager.AppSettings[AppConfig.TimeOutMinutes]) != null) { // Minutes timeoutPeriod = new TimeSpan(0, int.Parse(setting), 0); } if ((setting = ConfigurationManager.AppSettings[AppConfig.MultipleInterfaceSupport]) != null) { multipleInterfaceSupport = bool.Parse(setting); } if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv4Support]) != null) { if (bool.Parse(setting)) { enabledTrafficTypes |= TrafficType.IPv4; } } if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6Support]) != null) { if (bool.Parse(setting)) { if (Socket.OSSupportsIPv6) { enabledTrafficTypes |= TrafficType.IPv6; } else { eventLog.WriteEntry("IPv6 not enabled in OS. Ignoring IPv6 from app.config.", EventLogEntryType.Warning, ReflectorEventLog.ID.Error); } } } // If the user has set both IPv6 support and IPv4 support to false, we go to default // config: IPv4Support only. if (enabledTrafficTypes < TrafficType.IPv4) { enabledTrafficTypes = TrafficType.IPv4; } if ((setting = ConfigurationManager.AppSettings[AppConfig.MCLoopbackOff]) != null) { mcLoopbackOff = bool.Parse(setting); } if ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceRouteIndex]) != null) { // Route print produces a hexadecimal number mcInterfaceRouteIndex = Convert.ToInt32(setting, 16); } if ((enabledTrafficTypes & TrafficType.IPv4) == TrafficType.IPv4) { if (((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceIP]) != null) && multipleInterfaceSupport) { multicastInterfaceIP = IPAddress.Parse(setting); } else { //Workaround: Pass a generic IPv4 multicast IP. multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("233.4.5.6")); } if (((setting = ConfigurationManager.AppSettings[AppConfig.UnicastInterfaceIP]) != null) && multipleInterfaceSupport) { unicastInterfaceIP = IPAddress.Parse(setting); } else { // The interface which is routed toward the Root name servers unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("198.41.0.4")); } } if ((enabledTrafficTypes & TrafficType.IPv6) == TrafficType.IPv6) { if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6MulticastInterfaceIP]) != null) && multipleInterfaceSupport) { IPv6multicastInterfaceIP = IPAddress.Parse(setting); } else { //Workaround: Pass a generic IPv6 multicast IP. IPv6multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("ff1e::1")); } if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6UnicastInterfaceIP]) != null) && multipleInterfaceSupport) { IPv6unicastInterfaceIP = IPAddress.Parse(setting); } else { // The interface which is routed toward 6bone.net IPv6unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("2001:5c0:0:2::24")); } } try { sockets = new ReflectorSockets(enabledTrafficTypes); } catch (Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, (int)ReflectorEventLog.ID.Error); throw; } regServer = new RegistrarServer(enabledTrafficTypes, timeoutPeriod); UMforwarder = new UCtoUCMC(enabledTrafficTypes); MUforwarder = new MCtoUC(enabledTrafficTypes); }
private async Task ProcessTrafficResult(MonitoredPort port, long octets, TrafficType trafficType) { if (port.FirstTimeScanned == null) { port.FirstTimeScanned = DateTime.Now; port.LastInOctets = 0; port.LastOutOctets = 0; port.AllInOctets = 0; port.AllOutOctets = 0; switch (trafficType) { case TrafficType.Inbound: { port.LastInOctets = octets; port.AllInOctets = octets; break; } case TrafficType.Outbound: { port.LastOutOctets = octets; port.LastInOctets = octets; break; } } } long lastOctets = 0; long overallOctets = 0; switch (trafficType) { case TrafficType.Inbound: lastOctets = port.LastInOctets; overallOctets = port.AllInOctets; break; case TrafficType.Outbound: lastOctets = port.LastOutOctets; overallOctets = port.AllOutOctets; break; } if ((lastOctets - octets) > 10) { overallOctets += octets; lastOctets = octets; } else { overallOctets += (octets - lastOctets); lastOctets = octets; } switch (trafficType) { case TrafficType.Inbound: port.LastInOctets = lastOctets; port.AllInOctets = overallOctets; break; case TrafficType.Outbound: port.LastOutOctets = lastOctets; port.AllOutOctets = overallOctets; break; } port.LastTimeScanned = DateTime.Now; MonitoredPorts.Update(port); await WriteTrafficData(port, octets, trafficType); }
/// <summary> /// Initalizes all sockets /// </summary> /// <param name="IPv4Support">Boolean indicating whether to initalize IPv4 Sockets</param> /// <param name="IPv6Support">Boolean indicating whether to initalize IPv6 Sockets</param> public ReflectorSockets(TrafficType traffTypes) { InitAll(traffTypes); }
/// <summary> /// Intitalizes one socket based on the given parameters. /// </summary> /// <param name="sock">The socket class to be initalized</param> /// <param name="addrFamily">The address family for the socket to be initalized to (InterNetwork/InterNetworkV6)</param> /// <param name="isUnicast">Wether this socket is to be used for Multicast or Unicast</param> /// <param name="traffType">Wether this socket is to be used for RTP traffic or RTCP</param> private static void InitSocket(out Socket sock, TrafficType traffTypes) { int bindPort = 0; SocketOptionLevel sOL = 0; AddressFamily addrFamily = AddressFamily.InterNetwork; IPAddress bindInterface = null; #region initalizing bindPort, sOL, addrFamily and BindInterface based on function prarameters switch (traffTypes) { case TrafficType.UCv4RTP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.UCv4RTCP: bindInterface = ReflectorMgr.UnicastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.UCv6RTCP: bindInterface = ReflectorMgr.IPv6UnicastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorUnicastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; case TrafficType.MCv4RTCP: bindInterface = ReflectorMgr.MulticastInterfaceIP; sOL = SocketOptionLevel.IP; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetwork; break; case TrafficType.MCv6RTCP: bindInterface = ReflectorMgr.IPv6MulticastInterfaceIP; sOL = SocketOptionLevel.IPv6; bindPort = ReflectorMgr.ReflectorMulticastRTPListenPort + 1; addrFamily = AddressFamily.InterNetworkV6; break; default: Debug.Assert(false); throw new ArgumentException("Invalid traffic type combination"); } #endregion sock = new Socket(addrFamily, SocketType.Dgram, ProtocolType.Udp); sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 1500 * 160); // Multicast receive only if ((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) { sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, -1); } // Unicast socket sends multicast data, so set some multicast sending properties on it if ((traffTypes & TrafficType.Unicast) == TrafficType.Unicast) { sock.SetSocketOption(sOL, SocketOptionName.MulticastTimeToLive, 128); // Only set this value if it is other than the default if (ReflectorMgr.MulticastInterfaceRouteIndex > 0) { sock.SetSocketOption(sOL, SocketOptionName.MulticastInterface, (int)IPAddress.HostToNetworkOrder(ReflectorMgr.MulticastInterfaceRouteIndex)); } } sock.Bind(new IPEndPoint(bindInterface, bindPort)); if (((traffTypes & TrafficType.Multicast) == TrafficType.Multicast) && (!ReflectorMgr.MCLoopbackOff)) { sock.SetSocketOption(sOL, SocketOptionName.MulticastLoopback, 1); } }
/** * Construct a SessionOpts with specific parameters. * * @param trafficType Type of traffic. * @param isMultipoint true iff session supports multipoint (greater than two endpoints). * @param proximity Proximity constraint bitmask. * @param transports Allowed transport types bitmask. */ public SessionOpts(TrafficType trafficType, bool isMultipoint, ProximityType proximity, TransportMask transports) { _sessionOpts = alljoyn_sessionopts_create((byte)trafficType, isMultipoint ? 1 : 0, (byte)proximity, (ushort)transports); }
/// <summary> /// The constructor which reads config setting and calls the constructor for the sockets and three servers. /// </summary> public ReflectorMgr() { string setting; if ( (setting = ConfigurationManager.AppSettings[AppConfig.JoinPort]) != null ) { registrarServerPort = int.Parse(setting); } if ( (setting = ConfigurationManager.AppSettings[AppConfig.UnicastPort] ) != null ) { reflectorUnicastRTPListenPort = int.Parse(setting); } TimeSpan timeoutPeriod = TimeSpan.Zero; if ( (setting = ConfigurationManager.AppSettings[AppConfig.TimeOutMinutes] ) != null ) { // Minutes timeoutPeriod = new TimeSpan(0, int.Parse(setting), 0); } if ((setting = ConfigurationManager.AppSettings[AppConfig.MultipleInterfaceSupport] ) != null) { multipleInterfaceSupport = bool.Parse(setting); } if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv4Support] ) != null) { if(bool.Parse(setting)) { enabledTrafficTypes |= TrafficType.IPv4; } } if ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6Support] ) != null) { if(bool.Parse(setting)) { if (Socket.OSSupportsIPv6) { enabledTrafficTypes |= TrafficType.IPv6; } else { eventLog.WriteEntry("IPv6 not enabled in OS. Ignoring IPv6 from app.config.", EventLogEntryType.Warning, ReflectorEventLog.ID.Error); } } } // If the user has set both IPv6 support and IPv4 support to false, we go to default // config: IPv4Support only. if (enabledTrafficTypes < TrafficType.IPv4) { enabledTrafficTypes = TrafficType.IPv4; } if ((setting = ConfigurationManager.AppSettings[AppConfig.MCLoopbackOff] ) != null) { mcLoopbackOff = bool.Parse(setting); } if ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceRouteIndex] ) != null) { // Route print produces a hexadecimal number mcInterfaceRouteIndex = Convert.ToInt32(setting, 16); } if ((enabledTrafficTypes & TrafficType.IPv4) == TrafficType.IPv4) { if ( ((setting = ConfigurationManager.AppSettings[AppConfig.MulticastInterfaceIP] ) != null) && multipleInterfaceSupport) { multicastInterfaceIP = IPAddress.Parse(setting); } else { //Workaround: Pass a generic IPv4 multicast IP. multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("233.4.5.6")); } if (((setting = ConfigurationManager.AppSettings[AppConfig.UnicastInterfaceIP] ) != null) && multipleInterfaceSupport) { unicastInterfaceIP = IPAddress.Parse(setting); } else { // The interface which is routed toward the Root name servers unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("198.41.0.4")); } } if ((enabledTrafficTypes & TrafficType.IPv6) == TrafficType.IPv6) { if ( ((setting = ConfigurationManager.AppSettings[AppConfig.IPv6MulticastInterfaceIP] ) != null) && multipleInterfaceSupport) { IPv6multicastInterfaceIP = IPAddress.Parse(setting); } else { //Workaround: Pass a generic IPv6 multicast IP. IPv6multicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("ff1e::1")); } if (((setting = ConfigurationManager.AppSettings[AppConfig.IPv6UnicastInterfaceIP] ) != null) && multipleInterfaceSupport) { IPv6unicastInterfaceIP = IPAddress.Parse(setting); } else { // The interface which is routed toward 6bone.net IPv6unicastInterfaceIP = Utility.GetLocalRoutingInterface(IPAddress.Parse("2001:5c0:0:2::24")); } } try { sockets = new ReflectorSockets(enabledTrafficTypes); } catch(Exception e) { eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, (int)ReflectorEventLog.ID.Error); throw; } regServer = new RegistrarServer(enabledTrafficTypes, timeoutPeriod); UMforwarder = new UCtoUCMC(enabledTrafficTypes); MUforwarder = new MCtoUC(enabledTrafficTypes); }
/// <summary> /// Initalizes all sockets /// </summary> /// <param name="traffTypes">TrafficType indicating whether to initalize IPv6/IPv4 Sockets</param> public void InitAll(TrafficType traffTypes) { try { lock(this) { if (!IsInitalized) { if ( (traffTypes & TrafficType.IPv6) == TrafficType.IPv6) { InitSocket(out sockMCv6RTP, TrafficType.MCv6RTP); InitSocket(out sockUCv6RTP, TrafficType.UCv6RTP); InitSocket(out sockMCv6RTCP, TrafficType.MCv6RTCP); InitSocket(out sockUCv6RTCP, TrafficType.UCv6RTCP); } if ( (traffTypes & TrafficType.IPv4) == TrafficType.IPv4) { InitSocket(out sockMCv4RTP, TrafficType.MCv4RTP); InitSocket(out sockUCv4RTP, TrafficType.UCv4RTP); InitSocket(out sockMCv4RTCP, TrafficType.MCv4RTCP); InitSocket(out sockUCv4RTCP, TrafficType.UCv4RTCP); } IsInitalized = true; } } } catch(Exception e) { throw new Exception("Socket Initialization Error",e); } }
public AirportTrafficMVVM(Airport destination, long value, TrafficType type) { Destination = destination; Value = value; Type = type; }