/*Converts the red message to display it's information on the screen */ private void processRedMessage() { //Red Message processing txtShortestPathRed.Text = ""; initializeGraphRed(); djikstra(); //Builds a string indicating the path taken by the red message and displays it. Vertex v = R4; String pathRed = R4.vertID; while (v.previousVertex != R1) { pathRed = (v.previousVertex.vertID + "->") + pathRed; v = v.previousVertex; } pathRed = (R1.vertID + "->") + pathRed; txtShortestPathRed.Text = pathRed; txtDistanceRed.Text = R4.minDistance.ToString(); //Begins message conversion pathCollectionRed.Clear(); startX1Red = 0; messageRed = ""; crcStringRed = Convert.ToString(Convert.ToInt64(h1Address, 16), 2) + Convert.ToString(Convert.ToInt64(r1Address, 16), 2) + Convert.ToString(Convert.ToInt64("0802", 16), 2) + SupportClasses.binPrint(messageRed); Console.WriteLine(crcStringRed); binaryRepresentation1Red = ""; binaryRepresentation2Red = ""; messageRed = txtInput1.Text; message1LengthRed = messageRed.Length; binaryRepresentation1Red += SupportClasses.buildFrame(h1Address, r1Address) + SupportClasses.binPrint(messageRed); binaryRepresentation2Red += SupportClasses.buildFrame(r1Address, r2Address) + SupportClasses.binPrint(messageRed); byte[] b1Red = System.Text.Encoding.ASCII.GetBytes(crcStringRed); byte[] b2Red = System.Text.Encoding.ASCII.GetBytes(crcStringRed); binaryRepresentation1Red += Convert.ToString(Convert.ToInt64(calcCRC(b1Red), 10), 2); binaryRepresentation2Red += Convert.ToString(Convert.ToInt64(calcCRC(b2Red), 10), 2); crc32Red = new CRCCalc(); crc32Red.ComputeHash(b2Red); crcValueRed = crc32Red.CrcValue.ToString("X"); buildSinePathRed(); frameTextBlockRed.Text = "Red Ethernet Frame Contents:\nPreamble: AAAAAAAAAAAAAA\nStart Frame Delimeter: AB\n" + "Destination: " + h1Address + "\nSource: " + r1Address + "\nType: 0802\n" + "Data: " + messageRed + "\nCRC: " + crcValueRed; //Determines which animation to play for the red message switch (txtShortestPathRed.Text) { case "R1->R2->R3->R4": animationRed1234.Begin(); break; case "R1->R7->R8->R4": animationRed1784.Begin(); break; case "R1->R2->R5->R6->R8->R4": animationRed25684.Begin(); break; case "R1->R7->R5->R6->R3->R4": animationRed75634.Begin(); break; case "R1->R7->R5->R6->R8->R4": animationRed75684.Begin(); break; case "R1->R7->R5->R2->R3->R4": animationRed75234.Begin(); break; case "R1->R2->R5->R7->R8->R4": animationRed25784.Begin(); break; case "R1->R2->R3->R6->R8->R4": animationRed23684.Begin(); break; case "R1->R7->R8->R6->R3->R4": animationRed78634.Begin(); break; case "R1->R2->R5->R6->R3->R4": animationRed25634.Begin(); break; default: break; } }
private String calcCRC(byte[] input) { CRCCalc calc = new CRCCalc(); calc.ComputeHash(input); uint crc = calc.CrcValue; return crc.ToString(); }