/// <summary> /// Generates the BIP checksum from content. /// </summary> /// <param name="content">The content.</param> /// <param name="blockCount">The block count.</param> /// <param name="level">The level.</param> /// <returns></returns> public static string GenerateBIP(List <IContent> content, int blockCount, StmLevel level) { Frame bipFrame = new Frame(level); bipFrame.Content = new List <IContent>(content); return(BinaryInterleavedParity.GenerateBIP(bipFrame, blockCount)); }
/// <summary> /// Evaluates the header. /// </summary> /// <param name="sdhFrame">The SDH frame.</param> /// <returns></returns> public bool evaluateHeader(IFrame sdhFrame) { Frame tempFrame = new Frame((Frame)sdhFrame); tempFrame.Msoh = null; if (sdhFrame.Msoh != null && (sdhFrame.Msoh.Checksum == BinaryInterleavedParity.GenerateBIP(((Frame)sdhFrame).Content, 21, ((Frame)sdhFrame).Level))) { return(true); } else { return(false); } }
/// <summary> /// Evaluates the header. /// </summary> /// <param name="sdhFrame">The SDH frame.</param> /// <returns></returns> public bool evaluateHeader(IFrame sdhFrame) { //Remove RSOH header from tempFrame Frame tempFrame = new Frame((Frame)sdhFrame); tempFrame.Rsoh = null; //Check BIP if (sdhFrame.Rsoh != null && sdhFrame.Rsoh.Checksum == BinaryInterleavedParity.GenerateBIP(((Frame)tempFrame), 8)) { return(true); } else { return(false); } }
/// <summary> /// Generates the MSOH header. /// </summary> /// <param name="sdhFrame">The SDH frame.</param> public void generateHeader(IFrame sdhFrame) { Frame tempFrame = (Frame)sdhFrame; if (sdhFrame.Msoh != null) { sdhFrame.Msoh.Checksum = BinaryInterleavedParity.GenerateBIP(((Frame)sdhFrame).Content, 21, ((Frame)sdhFrame).Level); } else { sdhFrame.Msoh = new Header(BinaryInterleavedParity.GenerateBIP(((Frame)sdhFrame).Content, 21, ((Frame)sdhFrame).Level), null, null); } if (nextData.Count > 0) { ((SDHFrame.Frame)sdhFrame).Rsoh.DCC = nextData[0]; nextData.RemoveAt(0); } }
/// <summary> /// Generates the BIP checksum /// </summary> /// <param name="sdhFrame">The SDH frame.</param> /// <param name="block">The block.</param> /// <returns></returns> public static string GenerateBIP(IFrame sdhFrame, int blockCount) { FrameBuilder fmb = new FrameBuilder(); String checksum = String.Empty; byte[] bitFrame = BinaryInterleavedParity.ObjectToByteArray(fmb.BuildLiteral(sdhFrame)); int hopSize = bitFrame.Length / blockCount; for (int z = 0; z < blockCount; z++) { byte block = 0; for (int x = z; x < z * hopSize && x < bitFrame.Length; x++) { block = (byte)(block + bitFrame[x]); } block = (byte)(block % 2); checksum += block.ToString(); } return(checksum); }