27
P. E. S. INSTITUTE OF TECHNOLOGY Department of Electronics and Communication (Session: Aug ’08– Dec ’08) CCN LABORATORY MANUAL CCN Programming using C/C++ (3 Lab Sessions) 1. Simulate bit/character stuffing and de-stuffing in HDLC 2. Simulate the Shortest Path Algorithm 3. Encryption and Decryption of a given message 4. Find Minimum Spanning Tree of a Subnet 5. Compute Polynomial Code Checksum for CRC-CCITT CCN Experiments using Hardware (1 Lab Session) 6. Asynchronous and Synchronous Communication using RS232 / Optical Fiber / Twisted Pair / RJ45

ccn labview

Embed Size (px)

DESCRIPTION

lab view

Citation preview

  • P. E. S. INSTITUTE OF TECHNOLOGY Department of Electronics and Communication

    (Session: Aug 08 Dec 08)

    CCN LABORATORY MANUAL

    CCN Programming using C/C++ (3 Lab Sessions)

    1. Simulate bit/character stuffing and de-stuffing in HDLC 2. Simulate the Shortest Path Algorithm 3. Encryption and Decryption of a given message 4. Find Minimum Spanning Tree of a Subnet 5. Compute Polynomial Code Checksum for CRC-CCITT

    CCN Experiments using Hardware (1 Lab Session)

    6. Asynchronous and Synchronous Communication using RS232 / Optical Fiber / Twisted Pair / RJ45

  • CCN Lab Manual

    2/27

    Dept of ECE

    CYCLE OF EXPERIMENTS

    Cycle I [CCN programming]

    1. Simulate bit/character stuffing & de-stuffing using HDLC 2. Simulate the Shortest Path 3. Algorithm

    4. Encryption and Decryption of a given message 5. Find Minimum Spanning Tree of a Subset 6. Compute Polynomial Code Checksum for CRC-CCITT

    Cycle II [CCN Hardware]

    7. Asynchronous and Synchronous Communication using RS232 / Optical Fiber / Twisted Pair / RJ45

  • CCN Lab Manual

    3/27

    Dept of ECE

    CCN Programming using C/C++ 1. Simulate bit/character stuffing and de-stuffing in HDLC Framing involves identifying the beginning and end of a block of information within a digital stream. Framing assumes that there is enough synchronization at the physical layer to at least identify an individual bit or byte.In asynchronous data transmission , since transmissions do not occur at regular intervals , the receiver resynchronizes at the start of each eight bit character by the use of a start bit that precedes and a stop bit that ends each character . In synchronous data transmission bits are transmitted at regular intervals and the receiver has the circuitry that recovers and tracks the frequency and bit transitions of the received data Framing may involve delineating the boundaries between frames that are of fixed length or it may involve delineating between frames that are of variable length. Variable length frames need more information to delineate . The methods available include :

    Special characters to identify beginning and end of frame Special bit patterns-flags to identify the beginning and end of frames and

    character counts

    Bit Stuffing: Flag based synchronization was developed to transfer an arbitrary number of bits within a frame. The figure below shows the structure of an HDLC frame . The beginning and end of an HDLC frame is indicated by the presence of an eight bit flag. The flag in HDLC consists of the byte 01111110 that is HEX 7E . Bit stuffing prevents the occurrence of the flag inside the frame. The transmitter examines the contents of the frame and inserts an extra 0 after each instance of five consecutive 1s. The transmitter then attaches the flag at the beginning and end of the resulting bit stuffed frame. The receiver looks for five consecutive 1s in the received sequence. Five 1s followed by a 0 indicate that the 0 is a stuffing bit and so the bit is removed. Five consecutive 1s followed by 10 indicate a flag. Five 1 s followed by 11 indicate an error The example below show bit stuffing in HDLC

  • CCN Lab Manual

    4/27

    Dept of ECE

    HDLC Frame The high level data link control protocol is a bit oriented protocol which uses bit stuffing for data transparency. HDLC frame is as shown.

    The Control field is used for sequence numbers and acknowledgements and other purposes. The Data field may contain arbitrary information. The Checksum field is a minor variation of the CRC code using CRC-CCITT as the generator. Frames are delimited by 0111 1110 and this sequence is not allowed in the data field.

    Algorithm for Bit Stuffing 1. Input data sequence 2. Add start of frame to output sequence 3. For every bit in input

    a. Append bit to output sequence b. Is bit a 1?

    Yes: Increment count If count is 5, append 0 to output sequence and reset count

  • CCN Lab Manual

    5/27

    Dept of ECE

    No: Set count to 0

    4. Add stop of frame bits to output sequence

    /* Program to simulate bit stuffing where the flag byte is 01111110 */ # include # include void main() { /* Array is already initialised to 01111110 which is the flag byte. Hence a counter 'i' /* has to point to the eight location in the same array */ char ch, array[50]={"01111110"},recd_array[50]; int counter=0,i=8,j,k; clrscr(); /* Only the data portion of the frame is inputted */ printf("Enter the original data stream for bit stuffing : \n"); while((ch=getche())!='\r') { if (ch=='1') ++counter; else counter=0; array[i++]=ch; if (counter==5) /* If 5 ones are encountered append a zero */ { array[i++]='0'; counter=0; } } strcat(array,"01111110"); /* Appending the flag byte at the end of the stream */ /* i now has the value of the flag byte length + data stream length */ printf("\nThe stuffed data stream is : \n"); for (j=0;j

  • CCN Lab Manual

    6/27

    Dept of ECE

    } } for (j=0;j

  • CCN Lab Manual

    7/27

    Dept of ECE

    Algorithm for Character Stuffing 1. Input data sequence 2. Add start of frame to output sequence (DLE STX) 3. For every character in input

    a. Append character to output sequence b. Is character DLE?

    Yes: Add DLE to output sequence

    4. Add stop of frame chars to output sequence

    /* Program to demonstrate character stuffing */ # include # include # define DLE 16 # define STX 2 # define ETX 3 void main() { char ch; char array[100]={DLE,STX}; /* Initialise the array to have */ int i=2,j; /* the frame delimiter bytes initially */ clrscr(); /* Inputting the data stream alone */ printf("Enter the data stream (Ctrl+B->STX, Ctrl+C->ETX, Ctrl+P->DLE) : \n"); while ((ch=getch())!='\r')

  • CCN Lab Manual

    8/27

    Dept of ECE

    { if (ch==DLE) /* Checking for DLE */ { array[i++]=DLE; printf("DLE "); } else if (ch==STX) printf("STX "); else if (ch==ETX) printf("ETX "); else printf("%c ",ch); array[i++]=ch; } array[i++]=DLE; array[i++]=ETX; printf("\nThe stuffed stream is \n"); for (j=0;jETX, Ctrl+P->DLE) : A DLE B The stuffed stream is DLE STX A DLE DLE B DLE ETX The destuffed data stream is : A DLE B

  • CCN Lab Manual

    9/27

    Dept of ECE

    2. To Simulate the Shortest Path Algorithm In order to transfer packets from a source host to the destination host , the network layer must determine the path or route that the packets are to follow. This is the job of the network layer routing protocol.At the heart of any routing protocol is the routing algorithm that determines the path for a packet from source router to destination router. Given a set of routers, with links connecting the routers, a routing algorithm finds a good path from source router to destination router, according to some cost criterion. These can be

    1. Hop count : 1/ capacity: The cost is inversely proportional to the link capacity . One assigns higher costs to lower capacity links . The objective is to send a packet through a path through a path with the highest capacity. If each link has equal capacity , then the shortest path is the path with the minimum number of hops

    2. Transmission speed: The speed at which the various links operate is an important part of a routes efficiency. Faster links obviously take precedence over slow ones.

    3. Congestion : Network congestion caused by the current traffic pattern is considered when evaluating a route and links that are overly congested are bypassed

    4. Route cost : The route cost is a metric assigned by the network administrator used to rate the relative usability of various routes . The cost can refer to the literal financial expense incurred by the link or any other pertinent factor.

    5. Packet delay: The cost is proportional to an average packet delay which includes queuing delay in the switch buffer ad propagation delay in the link. The shortest path represents the fastest path to reach the destination

    Dijkstras algorithm:

    Dijkstras algorithm progressively identifies the closest nodes from the source node in order of increasing path cost. The algorithm is iterative. . The Dijkstras algorithm calculates the shortest path between two points on a network using a graph made up of nodes and edges The algorithm divides the nodes into two sets : tentative and permanent . It chooses nodes, makes them tentative, examines them and if they pass the criteria makes them permanent. The algorithm has the following steps 1. Start with the local node (router): the root of the tree 2. Assign a cost of 0 to this node and make it the first permanent node 3. Examine each neighbour of the node that was the last permanent node 4. Assign a cumulative cost to each node and make it tentative 5. Among the list of tentative nodes

    (i) Find the node with the smallest cumulative cost and make it permanent

    (ii) If a node can be reached from more than one direction Select the direction with the shortest cumulative cost

    6. Repeat steps 3 to 5 until every node becomes permanent

  • CCN Lab Manual

    10/27

    Dept of ECE

    Algorithm 1. Input graph data 2. Make all nodes TENTATIVE. 2. Input source, destination 3. Make source, the working node 4. Make the working node PERMANENT. 5. Check all tentative nodes, which are connected to working node. Update weight if required. 6. Find TENTATIVE node with smallest weight. Make this the new working node. 7. If working node is destination, go to step 8 else go to step 4 8. Trace back from destination to source.

    /* Program to calculate one Shortest Path Tanenbaum approach*/ # include # include /*Total number of nodes in network*/ # define NUM_OF_NODES 10 /*State of each node*/ # define PERMANENT 1 # define TENTATIVE 0 struct node { unsigned int weight; /*weight of node therefore -1 is max value*/ int prev; /*previous node or is connected to*/ int state; /*state of the node*/ }; void main() { int table[NUM_OF_NODES][NUM_OF_NODES] = { /* A B C D E F G H I J*/ /*A*/ {0,1,0,0,0,4,0,0,0,0}, /*B*/ {1,0,4,0,0,0,0,1,0,0}, /*C*/ {0,4,0,3,2,0,0,0,3,0}, /*D*/ {0,0,3,0,1,0,0,0,0,0}, /*E*/ {0,0,2,1,0,3,0,0,0,1}, /*F*/ {4,0,0,0,3,0,1,0,0,0}, /*G*/ {0,0,0,0,0,1,0,2,0,2}, /*H*/ {0,1,0,0,0,0,2,0,1,0}, /*I*/ {0,0,3,0,0,0,0,1,0,2}, /*J*/ {0,0,0,0,1,0,2,0,2,0} };/* A B C D E F G H I J*/ /*interpret as A is connected to B at a weight of 1 as table[A][B]=table[B][A]=1*/ int src,dest,i,working_node; /*src is source, dest is destination*/ unsigned int min; struct node nodes[NUM_OF_NODES];

  • CCN Lab Manual

    11/27

    Dept of ECE

    /*initialize all nodes as tentative and having weight of -1 or maximum*/ for(i=0;i

  • CCN Lab Manual

    12/27

    Dept of ECE

    { working_node=nodes[working_node].prev; printf("

  • CCN Lab Manual

    13/27

    Dept of ECE

    3. Encryption and Decryption of a given message

    The science and art of manipulating messages to make them secure is called cryptography. An original message to be transformed is called the plain text and the resulting message after the transformation is called the cipher text . The process of converting the plain text into cipher text is called encryption. The reverse process is called decryption. The algorithm used for encryption and decryption is often called a cipher

    Substitution ciphers are a common technique for altering messages in games and puzzles. Each letter of the alphabet is mapped into another letter. The cipher text is obtained by applying the substitution defined by the mapping to the plain text

    Transposition ciphers are an other type of encryption scheme . Here the order in which the letters appear is altered. The letters may be written into an array in one order and read out in a different order.

    Substitution and transposition techniques are easily broken In cryptography, the messages to be encrypted; known as plaintext, are

    transformed by a function that is parameterized by a key. The output of the encryption process, known as cipher text, is then transmitted, often by messenger or radio. We assume that the enemy or intruder, hears and accurately copies down the complete cipher text. However, unlike the intended recipient, he does not know what the decryption key is and so cannot decrypt the cipher text easily. Sometimes the intruder cannot only listen to the communication channel (passive intruder) but can also record messages and play them later, inject his own messages, or modify legitimate messages before they get to the receiver (active intruder). The art of breaking ciphers is called cryptanalysis. The art of devising ciphers (cryptography) and breaking them (cryptanalysis) is collectively known as cryptology. It will often be useful to have a notation for relating plaintext, ciphertext and keys. We will use C=EK(P) to mean that the encryption of the plaintext P using key K gives the ciphertext C. Similarly, P=DK(C) represents decryption of C to get the plaintext again. It then follows that DK(EK(P)) = P Fundamental rule of cryptography is that one must assume that the cryptoanalyst knows the general method of encryption used. Encryption methods are historically divided into two categories: substitution ciphers and transposition ciphers. Encryption Method

    Cipher C=Ek(P ) Decryption Method

    Encryption key-Ek, Decryption key-Dk, Plaintext-P, Plaintext P=DK(EK(P))

    Substitution Ciphers In a substitution cipher, each letter or group of letters is replaced by another letter

    or group of letters to disguise it. A way to do this is to have each of the symbols in the plaintext, say the 26 letters for simplicity, map onto some other letter. For example, Plaintext: a b c d e f g h i j k l m n o p q r s t u v w x y z Ciphertext: Q W E R T Y U I O P A S D F G H K L Z X C V B N M

  • CCN Lab Manual

    14/27

    Dept of ECE

    This general system is called a mono-alphabetic substitution, with the key being the 26-letter string corresponding to the full alphabet. For the key above, the plaintext attack would be transformed into the ciphertext QZZQEA. Algorithm for Encryption by Substitution Method 1. Read data to be encoded 2. For every character of data

    a. If data is between 'a' and 'z' set encoded data to uppercase character from key b. If data is between 'A' and 'Z' set encoded data to lowercase character from key c. If data between '0' and'9' set encoded data to digit from key d. else copy data into encoded datas array.

    3. Print encoded data.

    /* Encryption by Substitution method */ /* Program to encrypt given data even numbers sequence is a key on which you change data change all small letters to big and vice versa*/ # include # include # include void main() { const char sequence[36]="qwertyuiopasdfghjklzxcvbnm4852630791"; char data[100]; /*input data*/ char encoded[100]; /*encoded data*/ int i,len; printf("\nEnter data to be encoded:"); gets(data); len=strlen(data); for(i=0;i='a' && data[i]='A' && data[i]='0' && data[i]

  • CCN Lab Manual

    15/27

    Dept of ECE

    Algorithm for Decryption by Substitution Method 1. Read encrypted data 2. For every character of data

    a. Scan through key to see if data is present (i) If present get index of character add it to 'a' if data is uppercase else 'A' if it is in lowercase else '0' if it is a digit. (ii) If not present copy data into decoded datas array.

    3. Print decoded data.

    /* Decryption by Substitution method */ /* Find the given character in key find the location and add that to 'a' or 'A' or '0' as per requirements */ # include # include # include void main() { char sequence[36]="qwertyuiopasdfghjklzxcvbnm4852630791"; char data[100]; /*input data*/ char decoded[100]; /*decoded data*/ int i,j,len,present=0; printf("\nEnter data:"); gets(data); len=strlen(data); for(i=0;i

  • CCN Lab Manual

    16/27

    Dept of ECE

    printf("\nDecoded string is : %s",decoded); }

    Output: Enter data: iTSSG vGKSR! Decoded string is : Hello World!

    Transposition Ciphers Substitution ciphers preserve the order of the plaintext symbols but disguise them.

    Transposition ciphers, in contrast, reorder the letters but do not disguise them. The figure below depicts a common transposition cipher, the columnar transposition. The cipher is keyed by a word or phrase not containing any repeated letters. In this example, MEGABUCK is the key. The purpose of the key is to number the columns, column 1 being under the letter closet to the start of the alphabet and so on. The plain text is written horizontally, in rows. The ciphertext is read out by columns, starting with the column whose key letter is the lowest. Plain text : pleasetransferonemilliondollarstomyswissbankaccountsixtwotwo M E G A B U C K 7 4 5 1 2 8 3 6 p l e a s e t r a n s f e r o n e m i l l i o n d o l l a r s t o m y s w i s s b a n k a c c o u n t s i x t w o t w o a b c d

    Ciphertext: AFLLSKSOSELAWAIATOOSSCTCLNMOMANTESILYNTWRNNTSOWDPAEDOBUOERIRICXB

    Algorithm for Encryption by Transposition Method 1. Get sequence of characters in Cipher i.e. MEGABUCK 2. Get data to be decoded. 3. Arrange data horizontally under MEGABUCK 4. Add '.' to make last row complete 5. For every column of MEGABUCK a. Find next column to send using sequence b. Send data under this letter i.e. print the data under this letter c. Jump back to 5 till all columns arent done

    /* Encryption by Transposition method */ # include # include void main() {

  • CCN Lab Manual

    17/27

    Dept of ECE

    char data[100]; char wrd[]="MEGABUCK"; char cipher[8][20]; /*cipher arranges characters under megabuck*/ int seq[8]; /*holds MEGABUCK in alphabetical weights ie M E G A B U C K 6 3 4 0 1 7 2 5*/ int i,j,cnt,c; /*to get 63401725*/ /*compare each character of word with every other char and keep count of number of characters is bigger than.. i.e. A will be greater than 0 characters B will be greater than 1 character i.e. A so 1 and so on...*/ for(i=0;i

  • CCN Lab Manual

    18/27

    Dept of ECE

    Algorithm for Decryption by Transposition Method 1. Get sequence of characters in word i.e. MEGABUCK 2. Get data to be decoded. 3. See if input has a multiple of length of word characters. If its not a multiple, print that it is an error and quit. 4. Find position of first character i.e. A 5. Put size of data/size of word characters underneath it. 6. Do 4-5 for all characters of MEGABUCK in alphabetical order. 7. Print all characters row wise starting from M to K.

    /* Decryption by Transposition method */ # include # include void main() { char wrd[]="MEGABUCK"; char data[100]; char cipher[8][20]; int seq[8]; int i,j,cnt,c; for(i=0;i

  • CCN Lab Manual

    19/27

    Dept of ECE

    if(cipher[j][cnt/strlen(wrd)-1]=='.') cipher[j][cnt/strlen(wrd)-1]=' '; } printf("\nDecrypted data : \n"); for(i=0;i

  • CCN Lab Manual

    20/27

    Dept of ECE

    4. Find Minimum Spanning Tree of a Subset In graph theory , a spanning tree is a graph in which there is no loop . In a bridged LAN , this means creating a topology in which each LAN can be reached from any other LAN through one path only(no loops). This is done by automatically disabling certain bridges. It is important that these bridges are not physically removed , since a topology change may require a different set of bridges to be disabled, thus reconfiguring the spanning tree dynamically

    A spanning tree is a graph is just a sub-graph that contains all the vertices and is a tree. A graph may have many spanning trees. For instance, a complete graph of 4 nodes can have 16 spanning trees. Suppose the edges of the graphs have weights or lengths, the weight of tree is the sum of its edges. Obviously, different trees have different lengths. A spanning tree includes all the routers but contains no loops. If each router knows which of its lines belong to the spanning tree, it can copy an incoming broadcast packet onto all the spanning tree lines except the one it arrived on. This method makes excellent use of bandwidth, generating the absolute minimum number of packets necessary to do the job. The only problem is that each router must have knowledge of some spanning tree for it to be applicable. Sometimes this information is available (e.g. with link state routing) but sometimes it is not (e.g. with distance vector routing).

    A spanning tree of a connected graph G is a connected subgraph of G having no cycles. Every connected graph has a spanning tree. For example, the following graph has four distinct spanning trees.

    Spanning Trees:

    In general a graph will have very many spanning trees. The weight of a subgraph to be sum of all the edge weights in the subgraph. Different spanning trees have different weights, the minimum spanning tree is the spanning tree with the minimum weight.

    Example: weights added to the graph above

    spanning tree S1 has weight 3+2+4 = 9 spanning tree S2 has weight 2+4+1 = 7 spanning tree S3 has weight 3+2+1 = 6

  • CCN Lab Manual

    21/27

    Dept of ECE

    spanning tree S4 has weight 3+4+1 = 8

    S3 is the minimum spanning tree of this graph.

    Finding the minimum spanning tree The easiest to understand and probably the best one for solving problems by hand is Kruskals algorithm. 1. Input number of vertices 2. Input the edge weights 3. Sort the edge weights in ascending order 4. Pick the lowest edge and join the corresponding vertices 5. Repeat till edges are marked making sure that there are no closed loops (number of vertices 1) 6. Display selected edges.

    NOTE: In the program given, the variable set is used to eliminate closed loops. Before joining two nodes, each nodes set is checked and if found to be the same, the join is not performed. If the nodes are of different sets then they are joined and then made of the same set.

    /* Program for finding the Minimum Spanning Tree of a network */ # include # include struct node { int set; /* Attribute to indicate which connection the node belongs to */ }node[100]; struct edge { int first_node,second_node; int distance; /* Distance between the nodes */ int selected; /* To denote whether edge is selected */ }e[100]; int edge_count=0;

    void getdata(int index,int total) /* Function to input the distances */ { int i; for (i=index;i

  • CCN Lab Manual

    22/27

    Dept of ECE

    } } void initialise(int total_nodes) { int i; for (i=0;i

  • CCN Lab Manual

    23/27

    Dept of ECE

    edges_selected++; /* Select the edge */ m=node[nodel].set; k=node[noder].set; for (n=0;n

  • CCN Lab Manual

    24/27

    Dept of ECE

    Edge : 10 First Node : A Second Node : D Distance : 6 Edge : 11 First Node : B Second Node : D Distance : 6 Edge : 12 First Node : B Second Node : F Distance : 6 Edge : 13 First Node : D Second Node : F Distance : 6 Edge : 14 First Node : C Second Node : F Distance : 7

    Minimal Spanning Tree : A B Distance : 2 A E Distance : 3 B C Distance : 3 A F Distance : 4 C D Distance : 4

  • CCN Lab Manual

    25/27

    Dept of ECE

    5. Compute Polynomial Code Checksum for CRC-CCITT Polynomial codes are extensively used in error detection and correction.

    Polynomial codes are readily implemented using shift register circuits and therefore are the most widely implemented error control codes. Polynomial codes involve generating check bits in the form of a cyclic redundancy check (CRC). They are also known as CRC codes.

    In polynomial codes the information symbols , the code words and the error vectors are represented by polynomials with binary coefficients. The k information bits (ik-1, ik-2 , .i1, i0) are used to form the information polynomial of degree (k-1)

    i(x) = ik-1 xk-1 + ik-2 xk-2 + + i1 x + i0 The encoding process takes i(x) and produces a codeword polynomial b(x) that

    contains the information bits and additional check bits and that satisfies a certain pattern. To detect errors , the receiver checks to see whether the pattern is satisfied

    The polynomial code (also known as a cyclic redundancy code or CRC code) is widely used. Polynomial codes are based upon treating bit strings as representations of polynomials with coefficients of 0 and 1 only. A k-bit frame is regarded as the coefficient list for a polynomial with k terms, ranging from xk-1 to x0. Such a polynomial is said to be of a degree k-1. The high-order (left most) bit is the coefficient of xk-1; the next bit is the coefficient of xk-2, and so on. For example, 110001 has 6 bits and thus represents a six-term polynomial with coefficients 1,1,0,0,0 and 1 : x5 + x4 + x0. When the polynomial code method is employed, the sender and receiver must agree upon a generator polynomial, G(x), in advance. Both the high and low-order bits of the generator must be 1. To compute the checksum for some frame with m bits, corresponding to the polynomial M(x), the frame must be longer than the generator polynomial. The idea is to append a checksum to the end of the frame in such a way that the polynomial represented by the checksummed frame is divisible by G (x). When the receiver gets the checksummed frame, it tries dividing it by G(x). If there is a remainder, there has been a transmission error.

    The algorithm for computing checksum is as follows: 1. Let r be the degree of G(x). Append r zero bits to the low-order end of the frame, so it now contains m+r bits and corresponds to the polynomial xr M(x). 2. Divide the bit string corresponding to G(X) into the bit string corresponding to xr M(x) using modulo-2 division. 3. Subtract the remainder (which is always r or fewer bits) from the bit string corresponding to xr M(x) using modulo-2 subtraction. The result is the checksummed frame to be transmitted. Call its polynomial T(x). The CRC-CCITT polynomial is x16 + x12 + x5 + 1

    /* C Program to compute polynomial code checksum */ # include # include # define DEGREE 16 /* Degree of the generator polynomial */ int result[30]; void calc_CRC(int length) { int ccitt[]={1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1}; /* Generator polnomial */

  • CCN Lab Manual

    26/27

    Dept of ECE

    int i=0,pos=0,newpos; while(pos

  • CCN Lab Manual

    27/27

    Dept of ECE

    /* Inputting the stream to be checked */ while((ch=getche())!='\r') array[i++]=ch-'0'; length=i; /* Duplicating the array */ for (i=0;i