· 7 years ago · Apr 23, 2018, 02:58 PM
1EXPERIMENT NO.-1
2
3Network Commands on Linux / Unix
4
5Some basic commands
6
7C:\Documents and Settings\student>ipconfig
8Windows IP Configuration
9Ethernet adapter Local Area Connection:
10
11 Connection-specific DNS Suffix . :
12 IP Address. . . . . . . . . . . . : 192.168.1.11
13 Subnet Mask . . . . . . . . . . . : 255.255.255.0
14 Default Gateway . . . . . . . . . :
15
16C:\Documents and Settings\student>hostname
17FUNCTION- The hostname command is used to show or set a computer's host name and domain name i.e. displays system identity name. It is one of the most basic of the network administrative utilities.
18OUTPUT
19E1-CSLAB8-12
20
21C:\Documents and Settings\student>ping 192.168.1.12
22FUNCTION- The PING command is used to test the connection and latency between two network connections. These connections can be either in a local area network or a wide area network or the internet as a whole. The PING command sends packets of information to a specified IP Address and then measures the time it takes to get a response from the specified computer or device.
23OUTPUT
24Pinging 192.168.1.12 with 32 bytes of data:
25
26Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
27Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
28Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
29Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
30
31Ping statistics for 192.168.1.12:
32 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
33Approximate round trip times in milli-seconds:
34 Minimum = 0ms, Maximum = 0ms, Average = 0ms
35
36
37C:\Documents and Settings\student>tracert 192.168.1.12
38FUNCTION- Traceroute, also called tracepath, tracert or trace route, is a network tool used to determine the "path" packets take from one IP address to another. It provides the hostname, IP address, and the response time to a ping. Our visual traceroute also includes a map displaying each of the hops.
39OUTPUT
40Tracing route to 192.168.1.12 over a maximum of 30 hops
411 <1 ms <1 ms <1 ms 192.168.1.12
42Trace complete.
43
44
45C:\Documents and Settings\student>pathping 192.168.1.12
46FUNCTION- It combines the functionality of Ping with that of Traceroute, by providing details of the path between two hosts and Ping-like statistics for each node in the path based on samples taken over a time period, depending on how many nodes are between the start and end host.
47OUTPUT
48Tracing route to 192.168.1.12 over a maximum of 30 hops
49 0 192.168.1.11
50 1 192.168.1.12
51
52Computing statistics for 25 seconds...
53 Source to Here This Node/Link
54Hop RTT Lost/Sent = Pct Lost/Sent = Pct Address
55 0 192.168.1.11
56 0/ 100 = 0% |
57 1 0ms 0/ 100 = 0% 0/ 100 = 0% 192.168.1.12
58
59Trace complete.
60
61
62C:\Documents and Settings\student>arp -a
63FUNCTION- ARP is used to perform IP address resolution which is the linking of IP addresses to MAC (Media Access Control) hardware addresses. ARP uses a broadcast to do this by asking the host that has the given IP address to respond to the broadcast with its MAC address.
64OUTPUT
65Interface: 192.168.1.11 --- 0x2
66 Internet Address Physical Address Type
67 192.168.1.12 00-16-e6-1a-aa-df dynamic
68 192.168.1.131 00-16-e6-19-c4-27 dynamic
69
70
71C:\Documents and Settings\student>netstat 192.168.1.12
72FUNCTION- It is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics.It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement.
73OUTPUT
74Active Connections
75Proto Local Address Foreign Address State
76Active Connections
77 Proto Local Address Foreign Address State
78
79
80C:\Documents and Settings\student>ping
81Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
82 [-r count] [-s count] [[-j host-list] | [-k host-list]]
83 [-w timeout] target_name
84
85Options:
86 -t Ping the specified host until stopped.
87 To see statistics and continue - type Control-Break;
88 To stop - type Control-C.
89 -a Resolve addresses to hostnames.
90 -n count Number of echo requests to send.
91 -l size Send buffer size.
92 -f Set Don't Fragment flag in packet.
93 -i TTL Time To Live.
94 -v TOS Type Of Service.
95 -r count Record route for count hops.
96 -s count Timestamp for count hops.
97 -j host-list Loose source route along host-list.
98 -k host-list Strict source route along host-list.
99 -w timeout Timeout in milliseconds to wait for each reply.
100
101C:\Documents and Settings\student>ping -a 192.168.1.12
102
103Pinging 192.168.1.12 with 32 bytes of data:
104
105Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
106Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
107Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
108Reply from 192.168.1.12: bytes=32 time<1ms TTL=128
109
110Ping statistics for 192.168.1.12:
111 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
112Approximate round trip times in milli-seconds:
113 Minimum = 0ms, Maximum = 0ms, Average = 0ms
114
115C:\Documents and Settings\student>ping –l size 192.168.1.12
116
117Pinging 192.168.1.12 with 0 bytes of data:
118
119Reply from 192.168.1.12: bytes=0 time<1ms TTL=128
120Reply from 192.168.1.12: bytes=0 time<1ms TTL=128
121Reply from 192.168.1.12: bytes=0 time<1ms TTL=128
122Reply from 192.168.1.12: bytes=0 time<1ms TTL=128
123
124Ping statistics for 192.168.1.12:
125 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
126Approximate round trip times in milli-seconds:
127 Minimum = 0ms, Maximum = 0ms, Average = 0ms
128
129
130C:\Documents and Settings\student>finger
131
132Displays information about a user on a specified system running the
133Finger service. Output varies based on the remote system.
134
135FINGER [-l] [user]@host [...]
136
137 -l Displays information in long list format.
138 user Specifies the user you want information about. Omit the user
139 parameter to display information about all users on the
140 specifed host.
141 @host Specifies the server on the remote system whose users you
142 want information about.
143
144$ finger
145OUTPUT
146Login Name Tty Idle Login Time Where
147root Superuser *02 344d Thu Sep 3 10:24
148root Superuser p0 12d Thu Sep 3 10:24
149student *p1 2 Tue Sep 15 11:55 10.0.13.241
150student *p2 2 Tue Sep 15 12:32 10.0.12.65
151student *p3 Tue Sep 15 12:38 10.0.13.142
152student *p4 1 Tue Sep 15 11:55 10.0.13.179
153student *p5 Tue Sep 15 12:37 10.0.12.152
154student *p6 Tue Sep 15 12:29 10.0.12.122
155student *p7 Tue Sep 15 12:27 10.0.13.228
156student *p8 1 Tue Sep 15 12:24 10.0.13.248
157student *p9 7 Tue Sep 15 12:27 10.0.13.206
158student *p11 Tue Sep 15 11:56 10.0.13.199
159student *p12 13 Tue Sep 15 12:05 10.0.13.157
160student *p13 3 Tue Sep 15 12:25 10.0.13.151
161student *p14 1 Tue Sep 15 11:55 10.0.12.96
162student *p15 2 Tue Sep 15 12:33 10.0.12.240
163student *p16 1 Tue Sep 15 12:26 10.0.13.231
164student *p17 8 Tue Sep 15 11:56 10.0.12.82
165student *p18 Tue Sep 15 12:08 10.0.13.54
166student *p19 Tue Sep 15 12:34 10.0.12.81
167student *p20 Tue Sep 15 12:25 10.0.13.249
168
169$ who am i
170FUNCTION- It is a command found on most Unix-like operating systems. It prints the effective userid (username) of the current user when invoked.
171OUTPUT
172student ttyp23 Sep 15 12:38
173
174
175$ who
176FUNCTION- displays information about all the users currently logged onto the system. The user name, terminal number and the date and time that each user logged onto the system.
177OUTPUT
178root tty02 Sep 3 10:24
179root ttyp0 Sep 3 10:24
180student ttyp1 Sep 15 11:55
181student ttyp2 Sep 15 12:32
182student ttyp3 Sep 15 12:39
183student ttyp4 Sep 15 11:55
184student ttyp5 Sep 15 12:37
185student ttyp7 Sep 15 12:27
186student ttyp8 Sep 15 12:24
187student ttyp9 Sep 15 12:27
188student ttyp10 Sep 15 12:39
189student ttyp11 Sep 15 11:56
190student ttyp13 Sep 15 12:25
191student ttyp14 Sep 15 11:55
192student ttyp15 Sep 15 12:33
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214EXPERIMENT NO.-2
215PROBLEM: Write a C++ program to perform bit stuffing and de-stuffing.
216OBJECTIVE: To perform bit stuffing and de-stuffing.
217SOFTWARE USED: Turbo C++.
218THEORY: In data transmission and telecommunication, bit stuffing (also known—uncommonly—as positive justification) is the insertion of non information bits into data. Stuffed bits should not be confused with overhead bits. De-stuffing is opposite of bit-stuffing.
219SOLUTION:
220#include<iostream.h>
221#include<conio.h>
222#include<stdio.h>
223void main()
224 {
225 clrscr();
226 int a[20],i=0,k=0,count=0; //count is a variable to count the number of 1's.
227 cout<<"Enter the elements of the array(in 1's and 0's form)";
228 for(i=0;i<10;i++)
229 cin>>a[i];
230 cout<<"\n The array entered is";
231 for(i=0;i<10;i++)
232 cout<<a[i];
233 i=0;
234 while(i!=9) // Performing Bit-Stuffing.
235 {
236 if(a[i]==1)
237 {
238 i++;
239 count++;
240 if(count==5)
241 {
242 for(k=11;k>i;k--)
243 a[k]=a[k-1];
244 a[i]=0;
245 }
246 }
247 else
248 {
249 i++;
250 count=0;
251 }
252 }
253 cout<<"\n"<<"The array after stuffing is: ";
254
255 for(i=0;i<=10;i++)
256 cout<<a[i];
257 cout<<"\n"<<"The array after destuffing is: ";
258 i=0;
259 while (i<10) // Performing Destuffing.
260 {
261 if(a[i]==1)
262 {
263 i++;
264 count++;
265 if(count==5)
266 {
267 for(k=i;k<11;k++)
268 a[k]=a[k+1];
269 }
270 }
271 else
272 {
273 i++;
274 count=0;
275 }
276 }
277 for(i=0;i<10;i++)
278 cout<<a[i];
279 getch();
280 }
281OUTPUT:-
282Enter the elements of the array(in 1’s and 0’s form)1
2831
2841
2851
2861
2871
2880
2890
2901
2910
292The array entered is 1111110010
293
294The array after stuffing is: 11111010010
295
296The array after destuffing is: 1111110010
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321EXPERIMENT NO.-3
322
323PROBLEM: Write a C++ program to determine if the IP address is in Class A, B, C, D, or E.
324OBJECTIVE: To determine if the IP address is in Class A, B, C, D, or E.
325SOFTWARE USED: Turbo C++.
326THEORY: An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. An IP address serves two principal functions: host or network interface identification and location addressing. Its role has been characterized as follows: "A name indicates what we seek. An address indicates where it is. A route indicates how to get there."
327The designers of the Internet Protocol defined an IP address as a 32-bit number and this system, known as Internet Protocol Version 4 (IPv4), is still in use today. However, due to the enormous growth of the Internet and the predicted depletion of available addresses, a new addressing system (IPv6), using 128 bits for the address, was developed in 1995.
328SOLUTION:
329// To determine if the IP address is in Class A, B, C, D or E.
330#include<iostream.h>
331#include<conio.h>
332#include<stdio.h>
333void main()
334 {
335 clrscr();
336 int a[4],i=0;
337 cout<<"Enter The IP address";
338 for(i=0;i<4;i++)
339 cin>>a[i];
340 cout<<"\n IP ADDRESS:"<<a[0]<<"."<<a[1]<<"."<<a[2]<<"."<<a[3]<<"\n";
341 cout<<"The IP address is in Class: ";
342 if(a[0]>=0 && a[0]<=127)
343 cout<<"Class A";
344 if(a[0]>127 && a[0]<191)
345 cout<<"Class B";
346 if(a[0]>191 && a[0]<224)
347 cout<<"Class C";
348 if(a[0]>224 && a[0]<=239)
349 cout<<"Class D";
350 if(a[0]>239)
351 cout<<"Class E";
352 getch();
353 }
354OUTPUT:
355Enter The IP address128
35665
35796
358215
359IP ADDRESS: 128.65.96.215
360The IP address is in Class: Class B
361
362
363
364
365
366
367EXPERIMENT NO.-4
368
369PROBLEM: Write a C++ program to determine if the IP address is in Class A, B, or C.
370OBJECTIVE: To determine if the IP address is in Class A, B, or C.
371SOFTWARE USED: Turbo C++.
372THEORY: An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. An IP address serves two principal functions: host or network interface identification and location addressing.
373SOLUTION:
374// To determine if the IP adress is in Class A, B, or C.
375#include<iostream.h>
376#include<conio.h>
377#include<stdio.h>
378void main()
379 {
380 clrscr();
381 int a[4],i=0;
382 cout<<"Enter The IP adress";
383 for(i=0;i<4;i++)
384 cin>>a[i];
385 if(a[0]>=0 && a[0]<=127)
386 cout<<"Class A";
387 if(a[0]>127 && a[0]<191)
388 cout<<"Class B";
389 if(a[0]>191)
390 cout<<"Class C";
391
392 cout<<"\nIP ADRESS:"<<a[0]<<"."<<a[1]<<"."<<a[2]<<"."<<a[3];
393 getch();
394 }
395OUTPUT:
396Enter The IP address12
39765
39896
399215
400IP ADDRESS: 12.65.96.215
401The IP address is in Class: Class A
402
403
404
405
406
407
408
409
410
411
412
413EXPERIMENT NO.-5
414
415PROBLEM: Write a C++ program to translate dotted decimal IP address into 32 bit address.
416OBJECTIVE: To translate dotted decimal IP address into 32 bit address.
417SOFTWARE USED: Turbo C++.
418THEORY: An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. An IP address serves two principal functions: host or network interface identification and location addressing.
419The designers of the Internet Protocol defined an IP address as a 32-bit number and this system, known as Internet Protocol Version 4 (IPv4), is still in use today. However, due to the enormous growth of the Internet and the predicted depletion of available addresses, a new addressing system (IPv6), using 128 bits for the address, was developed in 1995.
420SOLUTION:
421//Write a program to translate dotted decimal IP address into 32 bit address
422#include<iostream.h>
423#include<conio.h>
424void main()
425 {
426 clrscr();
427 int i,j,a[4],bin[8]={128,64,32,16,8,4,2,1};
428 cout<<"Enter the ip address";
429 for(i=0;i<4;i++)
430 cin>>a[i];
431 cout<<"The ip address is:-"<<a[0]<<"."<<a[1]<<"."<<a[2]<<"."<<a[3]<<endl;
432 for(i=0;i<4;i++)
433 {
434 for(j=0;j<8;j++)
435 {
436 if (a[i]&bin[j])
437 cout<<1;
438 else
439 cout<<0;
440 }
441 cout<<".";
442 }
443 getch();
444 }
445OUTPUT:
446Enter the ip address123
44732
44868
4497
450The ip address is:-123.32.68.7
451The IP address in binary form is:-
45201111011.00100000.01000100.00000111.
453
454
455
456
457
458
459EXPERIMENT NO.-6
460
461PROBLEM: To establish straight configuration for LAN.
462OBJECTIVE: To establish straight configuration for LAN.
463EQUIPMENTS REQUIRED:-
4641) 2 RJ -45 connectors
4652) Twisted pair cable
4663) Gripping or Crimping tool
4674) SLT-Tool
468Colour Coding:-
4691. Orange white
4702. Orange
4713. Green white
4724. Blue
4735. Blue white
4746. Green
4757. Brown white
4768. Brown
477Straight Configuration:- 1---------------------------------------------1
4782---------------------------------------------2
479 3---------------------------------------------3
480 4---------------------------------------------4
481 5---------------------------------------------5
482 6---------------------------------------------6
483 7---------------------------------------------7
484 8---------------------------------------------8
485
486
487THEORY: A local area network (LAN) is a computer network that connects computers and devices in a limited geographical area such as home, school, computer laboratory or office building. The defining characteristics of LANs, in contrast to wide area networks (WANs), include their usually higher data-transfer rates, smaller geographic area, and lack of a need for leased telecommunication lines.
488ARCNET, Token Ring and other technology standards have been used in the past, but Ethernet over twisted pair cabling, and Wi-Fi are the two most common technologies currently in use.
489PROCEDURE:-
490The outer covering of the wire is peeled off and according to requirement the wires are inserted in RJ-45 connector and punched with the help of punching tool after punching the wire is tested with SLT( Side locator tool).
491RESULT:-
492The straight wiring for the LAN has been established and tested using SLT tool.
493USE:-
494This type of wiring is used for connecting to PC or Hub.
495
496
497
498
499
500
501
502EXPERIMENT NO.-7
503
504PROBLEM: To establish rollover configuration for LAN.
505OBJECTIVE: To establish rollover configuration for LAN.
506EQUIPMENTS REQUIRED:-
5071) 2 RJ -45 connectors
5082) Twisted pair cable
5093) Gripping or Crimping tool
5104) SLT-Tool
511Colour Coding:-
5121. Orange white
5132. Orange
5143. Green white
5154. Blue
5165. Blue white
5176. Green
5187. Brown white
5198. Brown
520Rollover Configuration:- 1---------------------------------------------8
5212---------------------------------------------7
5223---------------------------------------------6
5234---------------------------------------------5
5245---------------------------------------------4
5256---------------------------------------------3
5267---------------------------------------------2
5278---------------------------------------------1
528
529THEORY: A local area network (LAN) is a computer network that connects computers and devices in a limited geographical area such as home, school, computer laboratory or office building. The defining characteristics of LANs, in contrast to wide area networks (WANs), include their usually higher data-transfer rates, smaller geographic area, and lack of a need for leased telecommunication lines.
530ARCNET, Token Ring and other technology standards have been used in the past, but Ethernet over twisted pair cabling, and Wi-Fi are the two most common technologies currently in use.
531PROCEDURE:-
532The outer covering of the wire is peeled off and according to requirement the wires are inserted in RJ-45 connector and punched with the help of punching tool after punching the wire is tested with SLT( Side locator tool).
533RESULT:-
534The rollover wiring for the LAN has been established and tested using SLT tool.
535USE:-
536This type of wiring is used for configuration of the router.
537
538
539
540
541
542
543
544
545
546
547
548
549
550EXPERIMENT NO.-8
551
552PROBLEM: To establish crossover configuration for LAN.
553OBJECTIVE: To establish crossover configuration for LAN.
554EQUIPMENTS REQUIRED:-
5551) 2 RJ -45 connectors
5562) Twisted pair cable
5573) Gripping or Crimping tool
5584) SLT-Tool
559Colour Coding:-
5601. Orange white
5612. Orange
5623. Green white
5634. Blue
5645. Blue white
5656. Green
5667. Brown white
5678. Brown
568Crossover Configuration:- 1---------------------------------------------3
5692---------------------------------------------6
5703---------------------------------------------1
5714---------------------------------------------4
5725---------------------------------------------5
5736---------------------------------------------2
5747---------------------------------------------7
5758---------------------------------------------8
576
577THEORY: A local area network (LAN) is a computer network that connects computers and devices in a limited geographical area such as home, school, computer laboratory or office building. The defining characteristics of LANs, in contrast to wide area networks (WANs), include their usually higher data-transfer rates, smaller geographic area, and lack of a need for leased telecommunication lines.
578ARCNET, Token Ring and other technology standards have been used in the past, but Ethernet over twisted pair cabling, and Wi-Fi are the two most common technologies currently in use.
579PROCEDURE:-
580The outer covering of the wire is peeled off and according to requirement the wires are inserted in RJ-45 connector and punched with the help of punching tool after punching the wire is tested with SLT (Side locator tool).
581RESULT:-
582The crossover wiring for the LAN has been established and tested using SLT tool.
583USES:
584This type of wiring is used for connecting PC to another PC.
585
586
587
588
589
590
591
592
593
594
595
596
597
598EXPERIMENT NO.-9
599
600PROBLEM: To generate hamming code.
601OBJECTIVE: To generate hamming code.
602SOFTWARE USED: Turbo C++.
603THEORY: In telecommunication, a Hamming code is a linear error-correcting code named after its inventor, Richard Hamming. Hamming codes can detect up to two simultaneous bit errors, and correct single-bit errors; thus, reliable communication is possible when the Hamming distance between the transmitted and received bit patterns is less than or equal to one. By contrast, the simple parity code cannot correct errors, and can only detect an odd number of errors.
604In mathematical terms, Hamming codes are a class of binary linear codes. For each integer there is a code with m parity bits and 2m − m − 1 data bits. The parity-check matrix of a Hamming code is constructed by listing all columns of length m that are pairwise independent. Hamming codes are an example of perfect codes, codes that exactly match the theoretical upper bound on the number of distinct code words for a given number of bits and ability to correct errors.
605Because of the simplicity of Hamming codes, they are widely used in computer memory (RAM). In particular, a single-error-correcting and double-error-detecting variant commonly referred to as SECDED.
606SOLUTION:
607#include <iostream.h>
608#include<conio.h>
609void main ( )
610 {
611 int a0, a1, a2, a3, b0, b1, b2, b3, r0, r1, r2, s0, s1, s2, q0, q1, q2, q3;
612 cout<< "Enter the word\n";
613 cin>>a3>>a2>>a1>>a0;
614 r0= (a0+a1+a2) %2;
615 r1= (a1+a2+a3) %2;
616 r2= (a0+a1+a3) %2;
617 cout <<"The code at sender is: "<<a3<<a2<<a1<<a0<<r2<<r1<<r0;
618 cout<<"\n Enter the code at receiver:\n";
619 cin>>b3>>b2>>b1>>b0>>q2>>q1>>q0;
620cout<<"b3="<<b3<<",b2="<<b2<<",b1="<<b1<<",b0="<<b0<<",q2="<<q2<<",q1="<<q1<<",q0="<<q0;
621s0= (b2+b1+b0+q0) %2;
622s1= (b3+b2+b1+q1) %2;
623s2= (b1+b0+b3+q2) %2;
624 cout<<"\n"<<"s2="<<s2<<",s1="<<s1<<",s0="<<s0;
625 if ( s2==0 && s1==0 && s0==0 )
626 cout << "\n No Error";
627 else if ( s2==0 && s1==0 && s0==1 )
628 cout << "\n Error at q0";
629 else if ( s2==0 && s1==1 && s0==0 )
630 cout << "\n Error at q1";
631 else if ( s2==0 && s1==1 && s0==1 )
632 cout << "\n Error at b2";
633 else if ( s2==1 && s1==0 && s0==0 )
634 cout << "\n Error at q2";
635 else if ( s2==1 && s1==0 && s0==1 )
636 cout << "\n Error at b0";
637 else if ( s2==1 && s1==1 && s0==0 )
638 cout << "\n Error at b3";
639 else if ( s2==1 && s1==1 && s0==1 )
640 cout << "\n Error at b1";
641 getch();
642 clrscr();
643 }
644OUTPUT:
645Enter the word
6461
6471
6480
6491
650The code at sender is: 1101000
651Enter the code at receiver:1
6520
6531
6541
6550
6561
6570
658b3=1,b2=0,b1=1,b0=1,q2=0,q1=1,q0=0
659s2=1,s1=1,s0=0
660Error at b3
661
662
663
664
665
666
667
668
669
670
671EXPERIMENT NO.-10
672
673PROBLEM: Write a C++ program to implement the Dijkstra Algorithm to find shortest path.
674OBJECTIVE: To implement the Dijkstra Algorithm to find shortest path.
675SOFTWARE USED: Turbo C++.
676THEORY: Dijkstra's algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1956 and published in 1959,[1][2] is a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree. This algorithm is often used in routing and as a subroutine in other graph algorithms.
677For a given source vertex (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. It can also be used for finding costs of shortest paths from a single vertex to a single destination vertex by stopping the algorithm once the shortest path to the destination vertex has been determined.
678For example, if the vertices of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities. As a result, the shortest path first is widely used in network routing protocols, most notably IS-IS and OSPF (Open Shortest Path First).
679SOLUTION:
680// To implement Dijkstra’s Algorithm.
681#include<stdio.h>
682#include<conio.h>
683#include<process.h>
684#include<string.h>
685#include<math.h>
686#define IN 99
687#define N 6
688int dijkstra(int cost[][N],int source,int target);
689void main()
690 {
691 int cost[N][N],i,j,w,ch,co;
692 int source,target,x,y;
693 clrscr();
694 printf("Shortest path algorithm DIJKSTRA'S ALGORITHM \n\n");
695 for(i=1;i<N;i++)
696 {
697 for(j=1;j<N;j++)
698 {
699 cost[i][j]=IN;
700 }
701 }
702 for(x=1;x<N;x++)
703 {
704 for(y=x+1;y<N;y++)
705 {
706 printf("Enter the weight of the path between node %d and %d:",x,y);
707 scanf("%d",&w);
708 cost[x][y]=cost[y][x]=w;
709 }
710 printf("\n");
711 }
712 printf("\n Enter the source:");
713 scanf("%d",&source);
714 printf("\n Enter the target");
715 scanf("%d",&target);
716 co=dijsktra(cost,source,target);
717 printf("\n shortest path:%d",co);
718 getch();
719 }
720 int dijsktra(int cost[][N],int source,int target)
721 {
722 int dist[N],prev[N],selected[N]={0},i,m,min,start,d,j;
723 char path[N];
724 for(i=1;i<N;i++)
725 {
726 dist[i]=IN;
727 prev[i]=-1;
728 }
729 start=source;
730 selected[start]=1;
731 dist[start]=0;
732 while(selected[target]==0)
733 {
734 min=IN;m=0;
735 for(i=1;i<N;i++)
736 {
737 d=dist[start]+cost[start][i];
738 if(d<dist[i] && selected[i]==0)
739 {
740 dist[i]=d;
741 prev[i]=start;
742 }
743 if(min>dist[i] && selected[i]==0)
744 {
745 min=dist[i];
746 m=i;
747 }
748 }
749 start=m;
750 selected[start]=1;
751 }
752 start=target;
753 j=0;
754 while(start!=-1)
755 {
756 path[j++]=start+65;
757 start=prev[start];
758 }
759 path[j]='\0';
760 strrev(path);
761 printf("%s",path);
762 return dist[target];
763 }
764OUTPUT:
765Shortest path algorithm DIJKSTRA'S ALGORITHM
766Enter weight of the path between node 1 and 2:2
767Enter weight of the path between node 1 and 3:1
768Enter weight of the path between node 1 and 4:4
769Enter weight of the path between node 1 and 5:5
770Enter weight of the path between node 2 and 3:5
771Enter weight of the path between node 2 and 4:2
772Enter weight of the path between node 2 and 5:3
773Enter weight of the path between node 3 and 4:1
774Enter weight of the path between node 3 and 4:4
775Enter weight of the path between node 4 and 5:5
776Enter the source:2
777Enter the target:4
778CE
779Shortest path:2
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800EXPERIMENT NO.-11
801LAN TRAINER KIT
802
803
804Fig 1:Interface of LAN TKIT
805
806
807Fig 2: Configuration Interface of LAN TKIT
808
809System Requirements & Packing List
810
811System Requirements
812
813PC : Pentium II or higher
814One PCI slot (32-bit) required.
815(For Star related experiments that may be
816developed by user, 2 slots are required in one of the PCs)
817Minimum RAM as recommended by OS or by VC++ if installed
818Operating System : Windows 98 2nd Edition, Windows 2000 Professional
819Number of PCs : 2 – 3
820VC++ compiler : Version 6.0 or above
821(Optional – for programming/modifying experiments, to do suggested exercises etc.,)
822
823 Packing List
824
825Description Qty
826Network Emulator Unit (NEU) 1 No
827Network Interface Unit (NIU) 3 Nos
828LAN-T Power Supply (LAN-T PS) 1 No
8295-pin DIN cable (# 9915001) 1 No
830NIU-NEU Interface cable (# 9915002)
831(D37 – D37 flat cable) 3 Nos
832Patch chords (# 9915003) 1 Set
833Manuals
834(Installation manual, Programmer’s manual,
835User manual) 1 Set
836Software CD 1 No
837
838The LAN-T CD contains self-installable software. It also contains device driver files for the NIU card that required while installing them. A setup screen appears when the CD is inserted in the CD ROM drive. Follow the instructions and complete the installation. If the setup screen does not appear, try one of the following:
8391) Double click “My Computer†icon in the desktop and double click on the CD drive icon.
8402) Type “D:\Setup†in the Run command. Substitute the actual CD drive letter in place of D.
841
842The installation drive and path is defined to be C:\Lantrain by default. Leave this as such and proceed with the installation.
843This installation creates Lantrain directory under C drive and copies all the software and necessary DLLs. It also creates LAN-T folder and shortcuts under Start-Programs menu and on the desktop.
844The Lantrain directory contains all of the sub-directories and the files as given in the user manual (Introduction chapter). The BIN sub-directory contains some of the executable experiments that can be used to start those experiments. All other sub-directories and files are used while using with VC++.
845The complete installation will take about 140MB of hard disk space. This includes the intermediate files generated by VC++ in “Debug†directory under each project (experiment). These intermediate files are created while compiling the source code in VC++. If the VC++ is not used then these intermediate files may be removed to save hard disk space.
846Following experiment and diagnostics shortcuts are created on the desktop for easy accessing after installation:
847 PKT
848 MAC
849 Token Bus
850 Token Ring
851 Stop Wait
852 Sliding Window
853 FTP
854 Diagnostics
855Softcopy of LAN-T manual in CHM format is available under the Start-Programs-LAN-T menu. All the LAN-T manuals are given here.
856NIU card Installation
857One 32-bit PCI slot is required in the PC to install each NIU card. Switch off the PC and plug-in the NIU card in a free PCI slot.
858Connect one end of the NIU-NEU interface cable (Part# 9915002) to the NIU card. The other end has to be connected to the NEU either at “Node1 & 2†or “Node 2 & 3†or “Node 3 & 4†connector (at the rear of the NEU)
859Switch on the PC. It will detect the card automatically and initiates driver installation wizard. Follow the steps and complete the installation. LAN-T CD contains the NIU device driver files. Keep this CD in the CR-ROM drive while installing the driver. Following are the steps that the wizard passes through and the recommended selections to install NIU successfully:
860Step 1: The system detects the NIU PCI card as PCI Bridge. Click "Next".
861Step 2: Select the Option "Search for the best driver for your device (recommended)" and click "Next".
862Step 3: select CD-ROM check box and click "Next". Wizard will look for the *.inf file and the driver files in the LAN-T CD
863Step 4: "Benchmark LANT_NIU: Device Driver" will be displayed along with the location of the INF file. Click "Next".
864Step 5: Click "Finish" to complete the device driver installation.
865After installing the software as given in chapter 2, run “Activate NIU†from the LAN-T program folder created under the Start-Program menu. This activates the NIU by adding and registering the driver files to the list of drivers that Windows 98 or Windows 2000 loads when it starts. Reboot the system when this program prompts to do so.
866Install other NIUs in other PCs and connect to the NEU as said above.
867
868NEU Installation
8691. Connect the power supply to the NEU using the 5-pin DIN cable (part# 9915001) provided with the Trainer. Connect the power supply to the AC outlet using a standard power cord. LAN-T power supply has an IEC type power socket for AC input and accepts universal supply voltages. Switch on the power supply.
870
8712. Connect the NIUs to the NEU through the NIU-NEU flat Interface cable (part# 9915002).
872
8733. Switch on the power to the NEU. The switch is at the rear panel of NEU.
874LEDs will glow as follows:
875Data Rate = 8Kbps
876Topology = BUS
877BER = 0
878FER = 0
879Delay = 0 bit
880This is the default NEU condition while power-on or while reset.
8814. To Emulate BUS/RING/STAR topology, press the Topology switch until the corresponding LED glows. During Power-on, the NEU emulates BUS topology.
882
8835. To introduce Bit Errors, press the BER switch until the corresponding LED glows.
884Similarly press
885- FER switch to introduce Frame errors,
886- Delay switch to introduce bit delays (0 to 15 bits) between the nodes and
887- Data Rate switch to set the data rate between 8Kbps and 1Mbps.
888Bit errors and Frame errors are introduced between nodes 2 & 3 only. Delay can be introduced between the nodes and it depends on how the nodes are interconnected.
8896. Use patch cords (part# 9915003) to interconnect various elements like nodes, delay blocks, error generating blocks etc., in the NEU. Each node (with transceiver) in NEU has an Input, an Output, a Tx port and Rx port. Each delay has an input and output port.
890Patch cord connections to setup a BUS network:
891To connect nodes to the medium (BUS):
892Connect posts N1 to T11, N2 – T21, N3 – T31, N4 – T41, N5 – T51, N6 – T61
893To connect node output to its next delay input:
894Connect posts T13 – D11, T23 – D21, T33 – D31, T43 – D41, T53 – D51, T63 – D61
895To connect delay output to the its next node input:
896Connect posts D12 – T22, D22 – T32, D32 – T42, D42 – T52, D52 – T62
897Patch cord connections to setup a RING network:
898Connect posts to emulate BUS network. Connect D62 – T12. This closes the loop and forms a Ring network.
899Patch cord connections to setup a STAR network:
900To connect nodes to the medium (BUS):
901Connect posts N1 to T11, N2 – T21, N3 – T31, N4 – T41, N5 – T51, N6 – T61
902To connect node output to its next delay input:
903Connect posts T13 – D11, T23 – D21, T33 – D31, T43 – D41, T53 – D51, T63 – D61
904To connect delay output to the Star master:
905Connect posts D12 – S1, D22 – S2, D32 – S3, D42 – S4
906
907 Fig 3:Check LAN TKIT
908Introduction
909
910The Benchmark LAN-T LAN Trainer consists of a Network Emulator Unit (NEU), PC Plug-in Network Interface Units (NIU) and Win95 based experiment software. The software contains a series of experiments in the form of stand-alone applications; ‘C’ source code for the experiments, and a NIU Library.
911The NEU emulates 6 nodes, which can be configured to Bus, Ring or Star topologies. It also has error generators and delay generators between nodes.
912Each NIU card emulates two independent network nodes supporting various MAC layers, on a single PC.
913The NIU library provides a programming interface similar to that provided by typical Ethernet and other network adapters. This is register based, with command, data and status registers. These can be accessed via a set of C functions: NIU_Data(), NIU_Statistics etc.,
914Frame Format
915The format of the data frames used in the LAN-T is shown in Figure 1.1
9161 Byte 1 Byte 0-998 Bytes 2 Bytes 2 Bytes
917DA SA DATA Checksum Delimiter
918
919Figure 4: LAN Trainer Frame Format
920DA Destination Address
921SA Source Address
922DATA Data portion can be from 0 - 998 bytes
923Checksum Checksum field is generated internally by the NIU library. The Library interface will generate the checksum while transmission, and also strip the checksum on reception. As far as the student is concerned this field is insignificant.
924Delimiter Used internally for detecting the end of frame.
925Guide to the LAN Trainer
926To successfully use the LAN Trainer, a number of hardware and software components must be properly used together (see Fig. 1.1). Each PC acts as two nodes in the network. Both are connected to the Network Emulator Unit via the same cable. Thus, with 3 PCs, you can experiment with a 6-node network. On the software side, the screen is divided into 2 windows, one for each node. This is accomplished using the LAN Trainer control panel running under Windows - 95
927.NIU Card
928Each PC that is part of the LAN Trainer setup must have an NIU Card plugged into it. This card has two independent full-duplex serial channels each of which can operate at data rates between 8 Kb/s and 1 Mb/s. The card supports DMA as well as programmed I/O data transfers. With one such card, a PC acts as two independent network nodes.
929Once it is properly installed, the Serial Card should not require further attention. The data rate is set from the Network Emulator Unit, and all other parameters can be set by software.
930Network Emulator Unit
931The Network Emulator Unit acts as a network interconnecting upto 6 network nodes (3 NIU Cards in 3 PCs). Each card is connected to the Network Emulator Unit via a cable with DB-37 connectors. Once properly installed, these should not normally be disturbed. The Network Emulator Unit has a number of jumpers that must be properly wired-up depending on the type of network one wants - a bus, a ring, or a star. This must correspond to the setting of the Topology selector switch. The Network Emulator Unit also has selector switches for Data Rate, Bit Delay, Error Rate and Frame Error Rate. These should be set in accordance with the instructions of each experiment. In addition, there is a Reset switch which should be used before every experiment, and in case of trouble.
932NIU Library
933Above the hardware is a library of C functions that provides a programming interface to the LAN Trainer, similar to that provided by typical Ethernet and other network adapters. This emulated NIU is register-based, with command, data and status registers. These can be accessed via a set of C functions: NIU_Cmd(), NIU_Data() and NIU_Status(). The NIU library also provides a comprehensive set of interrupts.
934Application Software
935The final component in any experiment is the application software. This uses the facilities of the NIU library to accomplish some communication task, such as transferring a message from one node to another. Each of the two nodes on each PC can have its independent application software. Your programs will be at this level.
936The Physical Links
937The simplest network connecting two computers A and B is an electrical link directly from one to the other. Each computer has a network interface unit (NIU) with a transmitter and a receiver. A packet is transmitted by one computer as a sequence of bits and received by the other in the same order. Depending on the time it takes to transmit one bit, the link has a capacity or bandwidth of C b/s (bits per second).
938We can extend this network to accommodate a third computer, C, by adding a second NIU in each computer and two more links (Fig. 2.4 b). Each computer can send a packet to either of the others at any time by transmitting it on the appropriate link. This type of interconnection, referred to as a complete mesh topology, can be extended to connect N computers. Every computer must have (N-1) NIUs and the total number of links is N(N-1)/2 (Fig. 2.5 a). Thus, the benefit of never having to wait to transmit is outweighed by the large number of NIUs and links except when the number of computers, N, is small, say 3 or 4.
939 To reduce the number of links, every node is connected to one central node in the star topology (Fig. 2.5 b). A packet between any two nodes may need two hops via the central node. If the central node is the source or the destination, only one hop is required. The central node is a single point whose failure renders the entire network inoperative. In cases where most communication is between one server and its clients, the star topology is especially useful.
940The single point of failure can be avoided by using the ring or bus topology (Fig. 2.5 c and d). In the ring, every computer is attached to a circular cable. As a packet circulates around the ring, it can be received by every node. To avoid the packet circulating indefinitely, it is removed by the transmitting node after one round. In order to handle these functions, the attachment is via an electronic circuit called a transceiver. The transceiver is a complex device and may fail unless carefully designed.
941In the bus topology, the network is a single cable, with no active devices. Each node is connected to it via a simple tap. This can be very reliable and inexpensive. Owing to its simplicity and reliability, the bus is the most popular topology for local area networks. Ethernet, the most widely used LAN uses the bus topology.
942Like the ring, the bus also has the broadcast property, i.e., as a packet propagates down the bus to its ends it can be received by every node. In the mesh and star topologies, sending the same packet to every node requires that N-1 copies of the packet be separately transmitted.
943Making Sense
944A network allows one computer to send electrical signals to another computer. These signals have to be somehow interpreted as a stream of bits. The stream of bits has different meanings depending on the application. If one computer sends a binary file, and the other expects to receive an e-mail message, clearly proper communication will not take place. This is analogous to a Central Government official speaking in Hindi to a villager who knows only Tamil.
945In order for communication to take place, both parties, be they human or computer, must agree on a set of conventions such as what signals constitute a 1 and a 0, where are the byte-boundaries in a stream of bits, how is a binary file differentiated from an e-mail message. Such a set of conventions is a protocol.
946A network may include computers manufactured by different vendors with software from various sources. For these to be able to communicate, the protocols used must be agreed upon by all the manufacturers, i.e., standards are required. For example, RS-232C is a standard protocol for transmission of a stream of bytes that is widely used for sending data between computers and peripherals such as printers and modems. TCP is a standard protocol used for reliable transmission of arbitrary data between computers in the Internet.
947
948
949
950EXPERIMENT NO.-12
951To implement a routing protocol and check its connectivity in a variable length subnet masked network
952Objective: To be able to implement RIP(Routing Information Protocol) in the VLSM(Variable Length Subnet Masking) network so as to know about subnetting and dynamic configuration protocol and implement it in a real time scenario.
953Software used:
954CISCO Packet Tracer
955Version 5.3.0.0088
956Topology:
9574 Routers connecting different networks connected through serial cables
9583 End devices (P.C) or workstations to check the connectivity between different networks.
959
960
961
962Fig 5:Packet Tracer
963
964Router0: Se0/0/0-172.1.1.5/30 Router1: Se0/0/0-172.1.1.6/30
965F0/0-192.168.1.1/25 Se0/1/0-172.1.1.1/30
966F0/0-172.1.1.9/30
967Router2: Se0/0/0- 172.1.1.2/30 Router3: F0/0-172.1.1.10/30
968F0/0-192.168.1.129/25 F0/1-172.16.1.1/16
969PC1: IP Add 192.168.1.2
970Default Gateway 192.168.1.1
971PC2: IP Add 172.16.1.2
972Default Gateway 172.16.1.1
973PC3: IP Add 192.168.1.130
974Default Gateway 192.168.1.129
975Theory & Implementation on the above taken Topology
976IP Address: An IP address consists of 32 bits of information. These bits are divided into four sections, referred to as octets or bytes, each containing 1 byte (8 bits). You can depict an IP address using one of three methods:
977Dotted-decimal, as in 172.16.30.56
978Binary, as in 10101100.00010000.00011110.00111000
979Hexadecimal, as in AC.10.1E.38
980Summary of the three classes of networks
981 8 bits 8 bits 8 bits 8 bits
982Class A: Network Host Host Host
983Class B: Network Network Host Host
984Class C: Network Network Network Host
985Class D: Multicast
986Class E: Reserved for future
987Classfull IP address
988 Is divided into 5 major groups
989 Class A
990 Class B
991 Class C
992 Class D
993 Class E
994Class A, B and C are used in networking
995Class D is used for broadcasting
996Class E is reserved for the future
997The following table shows the range of IPv4 addresses for all classfull type
998Class A (0-127).(0-255).(0-255).(0-255)
999Class B (128-191).(0-255).(0-255).(0-255)
1000Class C (192-223).(0-255).(0-255).(0-255)
1001Class D (224-239).(0-255).(0-255).(0-255)
1002Class E (240-255).(0-255).(0-255).(0-255)
1003Note : 127.0.0.0 is reserved for loopback testing.
1004IMPORTANT NOTE: Subnetting :Subnetting is essentially the modification of a single IP network to create two or more logically visible sub-sections. It entails changing the subnet mask of the local network number to produce an even number of smaller network numbers, each with a corresponding range of IP addresses.
1005Subnetting is required when one network number needs to be distributed across multiple LAN segments. This may be the case in instances when:
1006 Two network segments are restricted by distance limitations (for example, remote offices linked via point-to-point circuit).
1007 Segments need to be localized for network management reasons (accounting segment, sales segment, etc.).
1008 Hosts which dominate most of the LAN bandwidth need to be isolated.
1009
1010RIP (Routing Information Protocol)
1011The key characteristics of RIP include the following:
1012• ï€ RIP is a distance vector routing protocol.
1013• ï€ Hop count is used as the metric for path selection.
1014• ï€ The maximum allowable hop count is 15.
1015• ï€ Routing updates are broadcast every 30 seconds by default.
1016• ï€ RIP is capable of load-balancing over as many as sixteen equal-cost paths. (Four paths is the default.)
1017To enable a dynamic routing protocol, you must complete the following steps:
1018Step 1 Select a routing protocol: RIP, EIGRP, or OSPF.
1019Step 2 Assign IP network numbers without specifying subnet values (except for OSPF).
1020IMPORTANT NOTE: You must also assign network or subnet addresses and the appropriate subnet mask to the interfaces.
1021RIP Configuration
1022The router rip command selects RIP as the routing protocol.
1023© 2007 Cisco Systems, Inc. All rights reserved. ICND1 v1.0—5-13
1024RouterX(config)# router rip
1025Starts the RIP routing process
1026
1027RouterX(config-router)# version 2
1028Enables RIP version 2
1029
1030RouterX(config-router)# network network-number
1031Selects participating attached networks
1032Requires a major classful network number
1033
1034The network command assigns a major network number that the router is directly connected
1035to. The RIP routing process associates interface addresses with the advertised network number
1036and will begin RIP packet processing on the specified interfaces.
1037
1038Fig 6:Interface
1039Verifying the RIP Configuration
1040The show ip protocols command displays values about routing protocols and the routing
1041protocol timer information that is associated with the router.
1042The table describes the significant fields shown in the display.
1043Field Description
1044Routing Protocol is "rip" Specifies the routing protocol used
1045
1046Sending updates every 30 Specifies the time between sending updates
1047seconds
1048
1049next due in 6 seconds Specifies when the next update is due to be sent
1050
1051Invalid after 180 seconds Specifies the value of the invalid parameter
1052
1053hold down 180 Specifies the current value of the hold-down parameter
1054flushed after 240 Specifies the time (in seconds) after which the individual routing information will be thrown (flushed) out
1055
1056Outgoing update Specifies whether the outgoing filtering list has been set
1057
1058Incoming update Specifies whether the incoming filtering list has been set
1059
1060Redistributing Lists the protocol that is being redistributed
1061
1062Default version control Specifies the version of RIP packets that are sent and received
1063
1064Routing Specifies the networks for which the routing process is currently injecting routes
1065
1066Routing Information Sources Lists all the routing sources that the Cisco IOS Software is using to build its routing table. For each source, you will see the following displayed:
1067â– IP address
1068â– Administrative distance
1069â– Time the last update was received from this source
1070
1071
1072Fig 7:Interface
1073Displaying the IP Routing Table
1074The show ip route command displays the contents of the IP routing table.
1075The routing table contains entries for all known networks and subnetworks, and a code that
1076indicates how that information was learned. The output and function of key fields from the
1077show ip route command are explained in the table.
1078Output Description
1079R or C Identifies the source of the route. For example, a “C†indicates that the route came from a direct connection of the route to a router interface. An “R†indicates that RIP is the protocol that determined the route.
1080
1081192.1.1.0 Indicates the address of the remote network.
1082172.1.1.8
1083192.168.1.128
1084120/1 The first number in the brackets is the administrative distance of the information source; the second number is the metric for the route (here, 1 hop).
1085
1086via 10.1.1.2 Specifies the address of the next-hop router to the remote network.
1087
108800:00:07 Specifies the amount of time since the route was updated (here, 7 seconds).
1089
1090Serial0/0/2 Specifies the interface through which the specified network can be reached.
1091
1092If routing information is not being exchanged (that is, if the output of the show ip route
1093command shows no entries that were learned from a routing protocol), use the show runningconfig
1094or show ip protocols privileged EXEC commands on the router to check for a possible
1095misconfigured routing protocol.
1096
1097RIP Configuration Troubleshooting
1098Use the debug ip rip command to display RIP routing updates as they are sent and received.
1099The no debug all command turns off all debugging.
1100The following output indicates the source address from which updates were received:
1101RIP: received v1 update from 10.1.1.2 on Serial0/0/2
1102The following output indicates the destination addresses to which updates were sent:
1103RIP: sending v1 update to 255.255.255.255 via FastEthernet0/0
1104(172.16.1.1)
1105RIP: sending v1 update to 255.255.255.255 via Serial0/0/2
1106(10.1.1.1)