//private functions private void ParsePstatex(string pstatex) { var reader = new StringReader(pstatex); while (true) { var line = reader.ReadLine(); if (line != null) { var array = line.Split(':'); switch (array[0]) { case "Bearer1 Downstream payload rate": var dsCurrentBitRate = array[1].Replace("kbps", "").Trim(); DownstreamCurrentBitRate = Convert.ToInt32(dsCurrentBitRate); break; case "Bearer1 Upstream payload rate": var usCurrentBitRate = array[1].Replace("kbps", "").Trim(); UpstreamCurrentBitRate = Convert.ToInt32(usCurrentBitRate); break; case "Downstream attainable payload rate": var dsMaxBitRate = array[1].Replace("kbps", "").Trim(); DownstreamMaxBitRate = Convert.ToInt32(dsMaxBitRate); break; /*case "Upstream line rate": * var usMaxBitRate = array[1].Replace("kbps", "").Trim(); * UpstreamMaxBitRate = Convert.ToInt32(usMaxBitRate); * break;*/ case "Downstream Training Margin": var dsNoiseMargin = array[1].Trim().Replace(" dB", ""); DownstreamNoiseMargin = Convert.ToDecimal(dsNoiseMargin, CultureInfo.InvariantCulture); break; case "Bandplan Type...........": _vdslProfile = VDSL2Profile.p8d; if (array[1].Trim().Equals("0")) { _vdslProfile = VDSL2Profile.p17a; } break; case "VDSL Estimated Loop Length ": var loopLength = array[1].Trim().Replace("ft", "").Trim(); Distance = Convert.ToDecimal(loopLength, CultureInfo.InvariantCulture) * 0.3048m; break; case "Far-end ITU Vendor Id": VectoringROPCapable = FromHexString(array[1]).Contains("BDCM"); //0xb5004244434da45f break; } } else { break; } } }
public void GetLineData() { try { //get vdsl stats //-------------- _tc.WriteLine("vdsl pstatex"); var pstatexReply = _tc.Read(2000); if (pstatexReply.Contains("Far-end ITU Vendor Id")) { //vdsl command successfull, so line obviously vdsl2 DSLStandard = DSLStandard.VDSL2; Annex = Annex.unknown; // Parse results ParsePstatex(pstatexReply); } else { throw new Exception("Unable to read extended port status."); } //get SNR and ATTN //---------------- _tc.WriteLine("vdsl getsnr"); var getsnrReply = _tc.Read(2000); if (getsnrReply.Contains("Attenuation")) { // Parse results ParseVdslSnr(getsnrReply); } } //vdsl pstatex connection failed --> adsl line catch { DownstreamCurrentBitRate = 0; UpstreamCurrentBitRate = 0; DownstreamMaxBitRate = 0; UpstreamMaxBitRate = 0; DownstreamNoiseMargin = 0; UpstreamNoiseMargin = 0; DownstreamAttenuation = 0; UpstreamAttenuation = 0; Distance = 0; DSLStandard = DSLStandard.unknown; Annex = Annex.unknown; _vdslProfile = VDSL2Profile.unknown; //TODO read adsl stats from telnet //_tc.WriteLine("adslstat"); } }
private void ParsePortStatus(string extendedPortStatus) { var reader = new StringReader(extendedPortStatus); while (true) { var line = reader.ReadLine(); if (line != null) { var array = line.Split(':'); switch (array[0]) { case "Bearer1 Downstream payload rate": var dsCurrentBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamCurrentBitRate = Convert.ToInt32(dsCurrentBitRate); break; case "Bearer1 Upstream payload rate": var usCurrentBitRate = array[1].Trim().Replace(" kbps", ""); UpstreamCurrentBitRate = Convert.ToInt32(usCurrentBitRate); break; case "Downstream attainable payload rate": var dsMaxBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamMaxBitRate = Convert.ToInt32(dsMaxBitRate); break; case "Downstream Training Margin": var dsAttenuation = array[1].Trim().Replace(" dB", ""); DownstreamAttenuation = Convert.ToDecimal(dsAttenuation, CultureInfo.InvariantCulture); break; case "Bandplan Type...........": _vdslProfile = VDSL2Profile.p8d; if (array[1].Trim().Equals("0")) { _vdslProfile = VDSL2Profile.p17a; } break; case "Far-end ITU Vendor Id": break; } } else { break; } } }
/// <summary> /// Proximus line profile Constructor /// </summary> /// <param name="name"></param> /// <param name="downloadSpeed">Downloadspeed in kbps</param> /// <param name="uploadSpeed">Uploadspeed in kbps</param> /// <param name="provisioning">Indicated if this is a provisioning profile or not</param> /// <param name="dlm">Indicated if this is a DLM profile or not</param> /// <param name="repair">Indicated if this is a repair profile or not</param> /// <param name="vectoring">Indicated if this is a vectoring profile or not</param> /// <param name="profile">VDSL2 profile (17a or 8d)</param> /// <param name="confirmedDownloadSpeeds">List of confirmed download speeds (feedback from users)</param> /// <param name="confirmedUploadSpeeds">List of confirmed upload speeds (feedback from users)</param> public ProximusLineProfile(string name, int downloadSpeed, int uploadSpeed, bool? provisioning, bool? dlm, bool? repair, bool? vectoring, VDSL2Profile profile, List<int> confirmedDownloadSpeeds, List<int> confirmedUploadSpeeds, decimal distanceMin, decimal distanceMax) { _name = name; _downloadSpeed =downloadSpeed; _uploadSpeed = uploadSpeed; _dlmProfile = dlm; _repairProfile = repair; _provisioningProfile = provisioning; _vectoringEnabled = vectoring; _profileVDSL2 = profile; _confirmedDownloadSpeeds = confirmedDownloadSpeeds; _confirmedUploadSpeeds = confirmedUploadSpeeds; _distanceMin = distanceMin; _distanceMax = distanceMax; }
/// <summary> /// Default constructor /// </summary> public ProximusLineProfile() { _name = string.Empty; _downloadSpeed = 0; _uploadSpeed = 0; _dlmProfile = false; _repairProfile = false; _provisioningProfile = false; _vectoringEnabled = false; _confirmedDownloadSpeeds = new List<int>(); _confirmedUploadSpeeds = new List<int>(); _profileVDSL2 = VDSL2Profile.unknown; _distanceMax = 0; _distanceMin = 0; }
/// <summary> /// Proximus line profile Constructor /// </summary> /// <param name="lpName">Line Profile number (LPXXX)</param> /// <param name="speedName">Profile speedname (100/20)</param> /// <param name="downloadSpeed">Downloadspeed in kbps</param> /// <param name="uploadSpeed">Uploadspeed in kbps</param> /// <param name="provisioning">Indicated if this is a provisioning profile or not</param> /// <param name="dlm">Indicated if this is a DLM profile or not</param> /// <param name="repair">Indicated if this is a repair profile or not</param> /// <param name="vectoringDown">Indicate if vectoring down is enabled or not</param> /// <param name="vectoringUp">Indicate if vectoring up is enabled or not</param> /// <param name="profile">VDSL2 profile (17a or 8d)</param> /// <param name="confirmedDownloadSpeeds">List of confirmed download speeds (feedback from users)</param> /// <param name="confirmedUploadSpeeds">List of confirmed upload speeds (feedback from users)</param> /// <param name="distanceMin">Minimim distance for this profile</param> /// <param name="distanceMax">Maximum distance for this profile</param> public ProximusLineProfile(string lpName, string speedName, int downloadSpeed, int uploadSpeed, bool?provisioning, bool?dlm, bool?repair, bool?vectoringDown, bool?vectoringUp, VDSL2Profile profile, List <int> confirmedDownloadSpeeds, List <int> confirmedUploadSpeeds, decimal distanceMin, decimal distanceMax) { LpName = lpName; SpeedName = speedName; DownloadSpeed = downloadSpeed; UploadSpeed = uploadSpeed; DlmProfile = dlm; RepairProfile = repair; ProvisioningProfile = provisioning; VectoringDownDownEnabled = vectoringDown; VectoringUpEnabled = vectoringUp; ProfileVDSL2 = profile; ConfirmedDownloadSpeeds = confirmedDownloadSpeeds; ConfirmedUploadSpeeds = confirmedUploadSpeeds; DistanceMin = distanceMin; DistanceMax = distanceMax; }
/// <summary> /// Get Proximus line profile /// </summary> /// <param name="profiles">Proximus line profiles to choose from</param> /// <param name="uploadSpeed">Upload speed of current session</param> /// <param name="downloadSpeed">Download speed of current session</param> /// <param name="vectoringDownEnabled">Vectoring down enabled/disabled or null for Unknown</param>ยต /// <param name="vectoringUpEnabled">Vectoring up enabled/disabled or null for Unknown</param> /// <param name="distance">Distance or null for Unknown</param> /// <returns>Proximus line profile of the current session</returns> public static ProximusLineProfile GetProfile(List <ProximusLineProfile> profiles, int uploadSpeed, int downloadSpeed, bool vectoringDownEnabled, bool vectoringUpEnabled, decimal?distance) { lock (profiles) { //check if speed matches with confirmed speeds /*List<ProximusLineProfile> confirmedMatches = _profiles.Where(x => x.ConfirmedDownloadSpeeds.Contains(downloadSpeed) && x.ConfirmedUploadSpeeds.Contains(uploadSpeed)).ToList(); * * //if vectoringstatus could be determined, filter on vectoring * if (vectoringEnabled != null) * confirmedMatches = confirmedMatches.Where(x => x.VectoringEnabled == vectoringEnabled).ToList(); * * //1 match found * if (confirmedMatches.Count == 1) * return confirmedMatches.First(); * * //multiple matches found * if (confirmedMatches.Count > 1) * { * //get profile with closest distance * if (distance != null) * { * return confirmedMatches * .Select(x => new { x, diffDistance = (distance - x.DistanceMin), diffSpeed = Math.Abs(x.DownloadSpeed - downloadSpeed) }) * .OrderBy(p => p.diffDistance < 0) * .ThenBy(p => p.diffDistance) * .ThenBy(p => p.diffSpeed) * .First().x; * } * //get profile with closest official download speed * else * return confirmedMatches.Select(x => new { x, diff = Math.Abs(x.DownloadSpeed - downloadSpeed) }) * .OrderBy(p => p.diff) * .First().x; * }*/ //get profiles with closest speeds in range of 512kb List <ProximusLineProfile> rangeMatches = profiles.Select(x => new { x, diffDownload = Math.Abs(x.DownloadSpeed - downloadSpeed), diffUpload = Math.Abs(x.UploadSpeed - uploadSpeed) }) .Where(x => x.diffDownload <= 512 && x.diffUpload <= 512) .OrderBy(p => p.diffDownload) .ThenBy(p => p.diffUpload) .Select(y => y.x) .ToList(); //check on vectoring rangeMatches = rangeMatches .Where(x => x.VectoringDownDownEnabled == vectoringDownEnabled) .OrderBy(x => x.VectoringUpEnabled == vectoringUpEnabled).ToList(); //check on distance if (distance != null) { rangeMatches = rangeMatches .Select(x => new { x, diffDistance = (distance - x.DistanceMin), diffSpeed = Math.Abs(x.DownloadSpeed - downloadSpeed) }) .OrderBy(p => p.diffDistance < 0) .ThenBy(p => p.diffDistance) .Select(y => y.x) .ToList(); } //check matches found if (rangeMatches.Count > 0) { if (rangeMatches.Count == 1) { return(rangeMatches.First()); } else { //multiple found, check which values are certain //provisioning bool?provisioning = null; if (rangeMatches.GroupBy(x => x.ProvisioningProfile).Count() == 1) { provisioning = rangeMatches.First().ProvisioningProfile; } //dlm bool?dlm = null; if (rangeMatches.GroupBy(x => x.DlmProfile).Count() == 1) { dlm = rangeMatches.First().DlmProfile; } //repair bool?repair = null; if (rangeMatches.GroupBy(x => x.RepairProfile).Count() == 1) { repair = rangeMatches.First().RepairProfile; } //vectoring bool?vectoring = null; if (rangeMatches.GroupBy(x => x.VectoringDownDownEnabled).Count() == 1) { vectoring = rangeMatches.First().VectoringDownDownEnabled; } bool?vectoringUp = null; if (rangeMatches.GroupBy(x => x.VectoringUpEnabled).Count() == 1) { vectoringUp = rangeMatches.First().VectoringUpEnabled; } //vdsl profile VDSL2Profile vdsl2Profile = VDSL2Profile.unknown; if (rangeMatches.GroupBy(x => x.ProfileVDSL2).Count() == 1) { vdsl2Profile = rangeMatches.First().ProfileVDSL2; } //LPXXX string lp = "unknown"; if (rangeMatches.GroupBy(x => x.LpName).Count() == 1) { lp = rangeMatches.First().LpName; } //Name (100/20) string name = "unknown"; if (rangeMatches.GroupBy(x => x.SpeedName).Count() == 1) { name = rangeMatches.First().SpeedName; } return(new ProximusLineProfile(lp, name, downloadSpeed, uploadSpeed, provisioning, dlm, repair, vectoring, vectoringUp, vdsl2Profile, new List <int>(), new List <int>(), 0, 0)); } } } //no matches found return(null); }
private void ParsePortStatus(String extendedPortStatus) { var reader = new StringReader(extendedPortStatus); while (true) { var line = reader.ReadLine(); if (line != null) { var array = line.Split(':'); switch (array[0]) { case "Bearer1 Downstream payload rate": var dsCurrentBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamCurrentBitRate = Convert.ToInt32(dsCurrentBitRate); break; case "Bearer1 Upstream payload rate": var usCurrentBitRate = array[1].Trim().Replace(" kbps", ""); UpstreamCurrentBitRate = Convert.ToInt32(usCurrentBitRate); break; case "Downstream attainable payload rate": var dsMaxBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamMaxBitRate = Convert.ToInt32(dsMaxBitRate); break; case "Downstream Training Margin": var dsAttenuation = array[1].Trim().Replace(" dB", ""); DownstreamAttenuation = Convert.ToDecimal(dsAttenuation, CultureInfo.InvariantCulture); break; case "Bandplan Type...........": _vdslProfile = VDSL2Profile.p8d; if (array[1].Trim().Equals("0")) { _vdslProfile = VDSL2Profile.p17a; } break; case "Far-end ITU Vendor Id": break; } } else { break; } } }
private void ParsePstatex(String pstatex) { var reader = new StringReader(pstatex); while (true) { var line = reader.ReadLine(); if (line != null) { var array = line.Split(':'); switch (array[0]) { case "Bearer1 Downstream payload rate": var dsCurrentBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamCurrentBitRate = Convert.ToInt32(dsCurrentBitRate); break; case "Bearer1 Upstream payload rate": var usCurrentBitRate = array[1].Trim().Replace(" kbps", ""); UpstreamCurrentBitRate = Convert.ToInt32(usCurrentBitRate); break; case "Downstream attainable payload rate": var dsMaxBitRate = array[1].Trim().Replace(" kbps", ""); DownstreamMaxBitRate = Convert.ToInt32(dsMaxBitRate); break; case "Downstream Training Margin": var dsNoiseMargin = array[1].Trim().Replace(" dB", ""); DownstreamNoiseMargin = Convert.ToDecimal(dsNoiseMargin, CultureInfo.InvariantCulture); break; case "Bandplan Type...........": _vdslProfile = VDSL2Profile.p8d; if (array[1].Trim().Equals("0")) { _vdslProfile = VDSL2Profile.p17a; } break; case "VDSL Estimated Loop Length ": var loopLength = array[1].Trim().Replace("ft", "").Trim(); Distance = Convert.ToDecimal(loopLength, CultureInfo.InvariantCulture) * 0.3048m; break; case "Line Type": if (array[1].Trim() == "0x00800000#" || array[1].Trim() == "0x04000000#") DSLStandard = DSLStandard.VDSL2; else DSLStandard = DSLStandard.unknown; break; case "Far-end ITU Vendor Id": break; } } else { break; } } }
public void GetLineData() { try { // Exec 'shell' command tc.WriteLine("shell"); // Wait for shell prompt if (tc.Read(1000).EndsWith("# ")) { // Send 'vdsl pstatex' command tc.WriteLine("vdsl pstatex"); } // Read reply var pstatexReply = tc.Read(1000); if (pstatexReply.Contains("Far-end ITU Vendor Id")) { // Parse results ParsePstatex(pstatexReply); } else { throw new Exception("Unable to read extended port status."); } // Wait for shell prompt if (pstatexReply.EndsWith("# ")) { // Send 'vdsl getsnr' command tc.WriteLine("vdsl getsnr"); } // Read reply var getsnrReply = tc.Read(1000); if (getsnrReply.Contains("Attenuation")) { // Parse results ParseVdslSnr(getsnrReply); } } //vdsl pstatex connection failed --> adsl line catch { DownstreamCurrentBitRate = 0; UpstreamCurrentBitRate = 0; DownstreamMaxBitRate = 0; UpstreamMaxBitRate = 0; DownstreamNoiseMargin = 0; UpstreamNoiseMargin = 0; DownstreamAttenuation = 0; UpstreamAttenuation = 0; Distance = 0; DSLStandard = DSLStandard.unknown; _vdslProfile = VDSL2Profile.unknown; //TODO read adsl stats from telnet //tc.WriteLine("adslstat"); } }