Description

DATA COMMUNICATION AND COMPUTER NETWORKS PRACTICAL FILESubmitted by: Arpita Srivastava CS2 497 Btech CS & E INDEX S.No. PROGRAM REMARK PRACTICAL 1 AIM Write a program that reads an IP address in dotted decimal form and determine whether the address is of Class type A, B, C, D or E. THEORY An IP address is a 32 bit address that uniquely and universally defines the connection of a device to the internet. It is a logical address in the network layer of TCP/IP protocol suite. Classful Addressing: In Classful addressing, the address space is divided into five classes A, B, C, D and E. Each class occupies some part of the address space. Class A is identified by the leading bit of address which is always 0. Class A address has 8 bits of network number and 24 bits of host number. Class B addresses has 16 bits of network number and 16 bits of host number. It is identified by the first two bits of network number which are 10. Class C address has 24 bits of network and 8 bits of host number. It is identified by the first three bits of network number which are 110. Class D address is used for multicasting. It is identified by the first four bits which are 1110 .There is no host number. The rest 28 bits identifies the multicast group. Class E address is reserved for experimental use and is identified by 1111 as the first four bits of the address. We can find the class of an address when given the address in binary notation or dotted decimal notation. If the address is given in binary notation, the first few bits can immediately tell us the class of the address. If the address is given in dotted decimal notation, the first byte defines the class. BINARY NOTATION (first few bits) Class A 0 Class B 10 Class C 110 Class D 1110 Class E 1111 DOTTED DECIMAL (first byte) Class A 0 - 127 Class B 18 - 191 Class C 192 - 223 Class D 224 - 239 Class E 240 – 255 else if(p>=224 && p<=239) cout<<"\nThe IP address is of type CLASS D".h> #include<conio.h> #include<stdlib. gets(ip). p=atoi(a).h> #include<string.h> void main() { clrscr(). int p. cout<<"\nThe first byte of IP address is:"<<p<<”\n”.i=-1.CODING #include<iostream. cout<<"Enter the IP address: ".').j=-1. else if(p>=240 &&p<=255) cout<<"\nThe IP address is of type CLASS E". else if(p>=192 && p<=223) cout<<"\nThe IP address is of type CLASS C". else cout<<"\nInvalid IP address".a[15]. } .h> #include<stdio. getch(). do { a[++j]=ip[++i]. char ip[15]. }while(ip[i]!='. if(p>0 && p<=127) cout<<"\nThe IP address is of type CLASS A". else if(p>=128 && p<=191) cout<<"\nThe IP address is of type CLASS B". OUTPUT Enter the IP address: 129.87 The first byte of IP address is: 129 The IP address is of type CLASS B .34.42. q. int p.s.h> #include<process.j=-1.h> #include <stdio.').ddd.'). }while(ip[i]!='. do { c[++h]=ip[++i]. .h=-1.w=-1. r=atoi(c). p=atoi(a).a[15]. }while(ip[i]!='. q=atoi(b).bbb.h> #include<stdlib. cout<<"\nEnter the IP Address: ".d[15]. do { a[++j]=ip[++i].aaa.fla=0. CODING #include<iostream. }while(ip[i]!='.PRACTICAL 2 AIM Write a program that translates a 32 bit IP address to dotted decimal notation and a dotted decimal IP address to binary notation.h> #include<string.h> #include <conio.h> void decimal_to_binary() { char ip[15]. do { d[++w]=ip[++i].h> #include<math.ccc.i=-1.'). int k=-1.r.').t. }while(ip[i]!='. do { b[++k]=ip[++i].c[15]. s=atoi(d). gets(ip).b[15]. f--. cout<<"\nSecond byte: "<<q. do { aaa=p%2. cout<<" ". q=q/2. for(t=0.t++) cout<<aa[t].bb[7]. aa[e]=aaa.t++) bb[t]=0.dd[7].t<=7. if(fla==1) { cout<<"\n\nConverted IP address is\n\n". cout<<"\nFirst byte: "<<p. bb[f]=bbb. . do { bbb=q%2. e--.g=7. for(t=0.t<7. } int e=7.t++) aa[t]=0.f=7. cout<<"\nThird byte: "<<r. cout<<"\nFourth byte: "<<s<<"\n".cc[7]. int aa[7]. for(t=0. }while(p!=0).t<7. p=p/2. } } } } else { fla=0.v=7.if(p>=0 && p<=255) { if(q>=0 && q<=255) { if(r>=0 && r<=255) { if(s>=0 && s<=255) { fla=1. t++) dd[t]=0. v--. for(t=0.t++) cout<<dd[t].w=-1. s=s/2.k.t<7.}while(q!=0). cout<<" ". gets(ip). cout<<" ".t++) cout<<bb[t]. cout<<"\nEnter the IP address in binary form: \n". do { ccc=r%2. for(t=0. do { ddd=s%2. g--. cc[g]=ccc. return. .ipaddr[3]. }while(s!=0). for(t=0.ipad[4][8].j. char ip[32]. dd[v]=ddd.t<7.t<=7. for(t=0.t++) cout<<cc[t]. if(k!=32) { cout<<"\nInvalid IP address".t++) cc[t]=0. k=strlen(ip). for(t=0. } } void binary_to_decimal() { int i.t<=7. r=r/2. return. }while(r!=0).t<=7. } else { cout<<"\nInvalid IP address". i++) { ipaddr[i]=0.i++) { if(i==0) cout<<"\nFirst: "."<<ipaddr[1]<<". if(i==3) cout<<"\nFouth: ".i++) { for(j=0.j++) { cout<<ipad[i][j]. if(ipad[i][j]=='1') ipaddr[i]++. cout<<ipaddr[0]<<". } } for(i=0.i<4.j++) { ipad[i][j]=ip[++w]. return. } } for(i=0. if(i==2) cout<<"\nThird: ".} for(i=0.j++) { ipaddr[i]*=2.j<8.i<32. } } cout<<"\n\nConverted IP address is\n"."<<ipaddr[2]<<". } void main() . if(i==1) cout<<"\nSecond: ". for(j=0. for(j=0.i<4.i<4.j<8.j<8."<<ipaddr[3].i++) { if(ip[i]!='0' && ip[i]!='1') { cout<<"\nInvalid IP address". } } for(i=0. do { cout<<"\nMENU".{ clrscr(). char ch. case 3:exit(0). cin>>ch. case 2:decimal_to_binary(). cout<<"\n2. int choice. cout<<"\nEnter your choice: ". Convert IP Address from Dotted Decimal notation to Binary notation". cin>>choice. break. break. switch(choice) { case 1:binary_to_decimal(). Exit from the program". cout<<"\n1. Convert IP Address from Binary notation to Dotted Decimal notation". } cout<<"\n\nDo You Want To Continue(Y/N): ". cout<<"\n3. }while(ch=='Y'||ch=='y'). } . default: cout<<"\nWrong choice". 10 First byte: 170 Second byte: 255 Third byte: 85 Fourth byte: 10 Converted IP address is 10101010 11111111 01010101 00001010 Do You Want To Continue(Y/N): y MENU 1. Convert IP Address from Dotted Decimal notation to Binary notation 3. Convert IP Address from Binary notation to Dotted Decimal notation 2. Exit from the program Enter your choice: 3 . Convert IP Address from Binary notation to Dotted Decimal notation 2.OUTPUT MENU 1.255.255. Exit from the program Enter your choice: 1 Enter the IP address in binary form: 10101010111111110101010100001010 First byte: 10101010 Second byte: 11111111 Third byte: 01010101 Fourth: 00001010 Converted IP address is 170.85. Convert IP Address from Binary notation to Dotted Decimal notation 2.10 Do You Want To Continue(Y/N): y MENU 1. Convert IP Address from Dotted Decimal notation to Binary notation 3. Convert IP Address from Dotted Decimal notation to Binary notation 3.85. Exit from the program Enter your choice: 2 Enter the IP Address: 170. 11. Hamming codes can detect up to two simultaneous bit errors. THEORY In telecommunication.5.12… Firstly we place each bit of the original code in its appropriate position in the 12 bit unit.23.3.9.11… P2: 2.10. P is added in the D at the following positions: 20. Hamming code gives the exact position where the bits are toggled and then it can be corrected by toggling it again.6.7.22. In subsequent steps we calculate the even parities for various bit combinations. . a Hamming code is a linear error-correcting code named after its inventor.11… P3: 4.7.… The combination used to calculate each of the four P values for an 8 bit data stream are as follows: P1: 1. By contrast.7. and can only detect an odd number of errors.11.10. Then the P value is placed at the specified position. thus. the simple parity code cannot correct errors.9.9. and correct single-bit errors.5.21.PRACTICAL 3 AIM Write a program that reads an 8 bit string and generates its hamming code.7. reliable communication is possible when the Hamming distance between the transmitted and received bit patterns is less than or equal to one..6. Richard Hamming. Parity value for each combination is the value of the corresponding P value.5. Example: P1 value is such as to provide an even parity for a combination of bits 3.12… P4: 8.3. Hamming rule: D+P+1<=2p where D is data bit P is parity bit Hamming code = D+P. i<6. } for(i=0.q4[5].i<12.p2. db2[7]='2'.co=0. q2[1]=db2[2].p3.count=0.p4.j=-1. } if(c%2==0) db2[0]='0'. q2[3]=db2[6].i++) { db2[i]='0'.i++) { if(db2[i]=='0') db2[i]=db1[++j]. else db2[0]='1'.CODING #include<iostream. db2[3]='2'. char q1[7].i<12. q2[2]=db2[5]. q2[0]=db2[1]. .i++) { if(q1[i]=='1') c++. gets(db1).q3[5]. cout<<"\nEnter the 8 bit data stream: ". db2[1]='2'.i<6.i++) { q1[i]=db2[a1].c=0. for(i=0. char p1.db2[12]. } db2[0]='2'.h> #include<conio. int a1=0. for(i=0.q2[6].i. int bs[8].db1[8].h> #include<stdio. } for(i=0. a1+=2.h> void main() { clrscr().cou=0. q3[3]=db2[6].i<5. } if(co%2==0) db2[1]='0'.i<12. q4[2]=db2[9]. } if(count%2==0) db2[7]='0'. for(i=0.i<6. q3[0]=db2[3]. cou=0. q2[5]=db2[10]. else db2[1]='1'. } if(cou%2==0) db2[3]='0'. q4[4]=db2[11]. else db2[3]='1'.i++) cout<<db2[i]. q4[0]=db2[7]. q3[2]=db2[5]. q3[1]=db2[4]. else db2[7]='1'. cout<<"\nHamming code is:".i++) { if(q4[i]=='1') count++.i++) { if(q2[i]=='1') co++.i<5. for(i=0. q4[3]=db2[10]. q3[4]=db2[11]. q4[1]=db2[8].i++) { if(q3[i]=='1') cou++.q2[4]=db2[9]. } . for(i=0. getch(). for(i=0. OUTPUT Enter the 8 bit data stream: 01100111 Hamming code is: 010111010111 . It is done to ensure that the Flag byte doesn't incidentally appear in a data frame. such as for bringing bit streams that do not necessarily have the same or rationally related bit rates up to a common rate. The name relates to the insertion of only 0 bits.PRACTICAL 4 AIM Write a program that implements bit stuffing method for framing. a 0 bit is stuffed after every five 1 bits in the data. or to fill buffers or frames. Zero-bit insertion It is a particular type of bit stuffing (in the latter sense) used in some data transmission protocols. bit stuffing (also known as positive justification) is the insertion of no information bits into data. To ensure that this pattern never appears in normal data. . where these extra bits are removed to return the bit streams to their original bit rates or form. if necessary. Bit stuffing does not ensure that the payload is intact (i. the frame will be resent. it is merely a way of attempting to ensure that the transmission starts and ends at the correct places. No 1 bits are inserted to limit sequences of 0 bits. Stuffed bits should not be confused with overhead bits. THEORY In data transmission and telecommunication.e. Bit stuffing is used for various purposes. not corrupted by transmission errors). The location of the stuffing bits is communicated to the receiving end of the data links. Error detection and correction techniques are used to check the frame for corruption after its delivery and. Bit stuffing may be used to synchronize several channels before multiplexing or to rate-match two single channels to each other. The bit sequence "01111110" containing six adjacent 1 bits is commonly used as a "Flag byte". j>i. count++. count=0. cout<<"\nAfter bit stuffing: ". cout<<"Enter the data bit stream(max 50 bits): ".i=0.i++) cout<<db[i].l. db[i]='0'. gets(db). getch().h> #include<stdio.h> #include<string.h> void main() { clrscr(). } } for(i=0.count=0. if(count==5) { for(j=l. } .CODING #include<iostream. char db[50].j. while (i<l) { if(db[i]=='1') { i++.j--) db[j]=db[j-1].h> #include<conio. l=strlen(db). } } else { i++.i<l. OUTPUT Enter the data bit stream(max 50 bits): 0101111111110001 After bit stuffing: 01011111011110001 . Inspect each wire is flat. Test the Ethernet cable by tester through the following scheme: Straight through END 1 1. Brown Cross Over END 1 1. stripper. tester. Hold the RJ45 plug. Flatten the end between your thumb & forefinger. Blue-white 6. cable. Orange 7. Green 3. EQUIPMENTS USED RJ45.PRACTICAL 5 AIM To create Straight-through. Green . Spread. 4. crimper. Brown-white 8. then trim the ends of the wire so that they are even with one another leaving only halfinch in wire length. Blue 5. Start on one end and strip the cable jacket off (about 1 inch) using a stripper or a knife. Green-white 2. carefully hold the wire & firmly crimp the RJ45 with the crimper. 2. even at the front of the plug. knife. PROCEDURE 1. Orange-white END 2 Green-white Green Orange-white Blue Blue-white Orange Brown-white Brown END 2 Orange-white Orange 4. push the wires firmly into the plug. 3. Cross-over and Roll-over cables. untwist the pairs and arrange the wires in the order of the desired cable end. Pull the cable off the reel to the desired length and cut it. 5. Green-white 2. Green 3. Orange 7. Brown-white 8. Brown Green-white Blue Blue-white Green Brown-white Brown Roll over END 1 1.3. . Green-white 2. Ensure that wire does not have any cut. 3. While stripping don’t press the crimper too hard. 2. Blue 5. Take care of your fingers while cutting. Blue-white 6. Brown PRECAUTIONS 1. Orange-white END 2 Brown Brown-white Orange Blue-white Blue Orange-white Green Green-white 4. Blue 5. Blue-white 6. Orange 7. Orange-white 4. Brown-white 8. CONCLUSION The Ethernet cable was working perfectly. PRACTICAL 6 BASIC COMMANDS 1. . . . ipconfig It allows you to get the IP address information of a Windows computer. . It is one of the most basic of the network administrative utilities SYNTAX hostname Example: hostname OUTPUT: your-vm1nwo8bv9 2. It also allows some control over active TCP/IP connections.168.e. . hostname The hostname command is used to show or set a computer's host name and domain name i. . . displays system identity name. : IP Address .3 . : 192. . .1. . SYNTAX Ipconfig Example: ipconfig OUTPUT: Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . . 33:http phl-te.google. -n : Displays addresses and port numbers in numerical form.252.160:http 125.tacoda.above.com:http redirect.google. . This may be combined with the –s option.0 Default Gateway . will display sequence of components involved in creating the connection or listening port for all executables. . : 255. . routing tables.com:http ty-in-f113. .net:http ty-in-f148. . -r : Displays the routing table. . .226.com:http ty-in-f156. .google. -o : Displays the owning process ID associated with each connection.236.255.com:http ty-in-f19.It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement. . . . Example 1: netstat OUTPUT Active Connections Proto Local Address TCP your-vm1nwo8bv9:1302 TCP your-vm1nwo8bv9:1303 TCP your-vm1nwo8bv9:1311 TCP your-vm1nwo8bv9:1312 TCP your-vm1nwo8bv9:3133 TCP your-vm1nwo8bv9:3139 TCP your-vm1nwo8bv9:3160 TCP your-vm1nwo8bv9:3161 TCP your-vm1nwo8bv9:3162 TCP your-vm1nwo8bv9:3163 TCP your-vm1nwo8bv9:3164 TCP your-vm1nwo8bv9:3165 TCP your-vm1nwo8bv9:3170 TCP your-vm1nwo8bv9:3171 TCP your-vm1nwo8bv9:3172 TCP your-vm1nwo8bv9:3173 TCP your-vm1nwo8bv9:3174 TCP your-vm1nwo8bv9:3175 TCP your-vm1nwo8bv9:3176 TCP your-vm1nwo8bv9:3182 TCP your-vm1nwo8bv9:3186 Foreign Address localhost:1303 localhost:1302 localhost:1312 localhost:1311 ty-in-f19.google.google.funpic.com:http ty-in-f113.1 3.168.org:http State ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED TIME_WAIT ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED ESTABLISHED TIME_WAIT ESTABLISHED TIME_WAIT ESTABLISHED TIME_WAIT .google. SYNTAX netstat [-e] [-n] [-o] [-r] [-s] [-v] -e : Displays Ethernet statistics.com:http ty-in-f113.com:http ty-in-f113. : 192. and a number of network interface statistics.google. . netstat It is a command-line tool that displays network connections (both incoming and outgoing).google.google. .com:http ty-in-f113.google.google.google. . . .net:http ty-in-f139. -v : When used in conjunction with -b.com:http ty-in-f104.1.76.com:http 64.Subnet Mask .com:http ty-in-f148. .255. . -a : Displays all connections and listening ports.com:http available. 168.com [74.100] over a maximum of 30 hops: 1 2 <1 ms 32 ms 1 ms <1 ms 192.com:http 222.2 OUTPUT: Tracing route to your-vm1nwo8bv9 [192.com OUTPUT: Tracing route to google.2] Trace complete.Static 018.google.1. Example: tracert 192.com:http ty-in-f19. -h maximum_hops : Maximum number of hops to search for target.168.125.1 34 ms 32 ms ABTS-North.168. tracert Traceroute.2] over a maximum of 30 hops: 1 <1 ms <1 ms <1 ms your-vm1nwo8bv9 [192.1. -j host-list : Loose source route along host-list. and the response time to a ping.230. IP address.160.168.TCP TCP TCP TCP your-vm1nwo8bv9:3195 your-vm1nwo8bv9:3196 your-vm1nwo8bv9:3197 your-vm1nwo8bv9:3203 ty-in-f19. It provides the hostname. -w timeout : Wait timeout milliseconds for each reply.31. also called tracepath. .169:http ESTABLISHED ESTABLISHED ESTABLISHED SYN_SENT Example 2: netstat –e OUTPUT: Interface Statistics Bytes Unicast packets Non-unicast packets Discards Errors Unknown protocols Received 34037036 54278 1486 0 0 15 Sent 7113461 53911 246 0 8 4.google.186. Example 2: tracert google. SYNTAX tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name -d : Do not resolve addresses to hostnames. Our visual traceroute also includes a map displaying each of the hops.google.1. is a network tool used to determine the "path" packets take from one IP address to another.1.67. tracert or trace route.122.com:http ty-in-f19. in [122.112 9 369 ms 344 ms 343 ms 66.239. ARP is used to perform IP address resolution which is the linking of IP addresses to MAC (Media Access Control) hardware addresses.19. Example: arp –a OUTPUT: Interface: 192.131 Trace completed 5.239.25 7 84 ms 84 ms 84 ms 72.212 13 344 ms 341 ms 339 ms 216.2 00-aa-00-62-c6-09 192.43.230. SYNTAX: arp -a -a : Displays current ARP entries by interrogating the current protocol data.22.in [122. SYNTAX: ping [-t] [-a] [-i TTL] [-v TOS] [-r count] [-w timeout] target_name . 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.145 6 83 ms 82 ms 82 ms 125.232.90 15 339 ms 342 ms 346 ms 72.1.160.232.21.1.1.14. 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.255.196.94.3 00-40-2b-2c-4a-35 Type dynamic static static 6.168.160.168.115 11 345 ms 368 ms 346 ms 209.160.14. airtelbroadband.in [122.0x2 Internet Address Physical Address 192.168.14.2 --.43.230.160. arp -a Displays and modifies the IP-to-Physical address translation tables used by address resolution protocol (ARP).1 00-1e-40-53-65-1e 192.160.168.122.122.74 10 340 ms 340 ms 346 ms 72.230.18] 3 32 ms 32 ms 32 ms ABTS-North-Static-021.14.230.101 8 89 ms 89 ms 89 ms 72.37 12 337 ms 337 ms 342 ms 216. These connections can be either in a local area network or a wide area network or the internet as a whole.14.167.239.airtelbroadband. ping The PING command is used to test the connection and latency between two network connections.21] 4 32 ms 32 ms 32 ms ABTS-North-Static-158.158] 5 32 ms 31 ms 31 ms 125.249.1.230.81 14 343 ms 343 ms 384 ms 72.239.85. airtelbroadband. 168.1. SYNTAX: finger [-b] [-f] [-h] [-i] [-l] [-m] [-p] [-q] [-s] [-w] [username] -b : Suppress printing the user's home directory and shell in a long format printout.168. finger Displays information about a user on a specified system running the Finger service. Example: finger OUTPUT: Login Name root Superuser root Superuser student student student Tty *02 p0 *p1 *p2 *p3 Idle 344d 12d 2 2 Login Time Where Thu Sep 3 10:24 Thu Sep 3 10:24 Tue Sep 15 11:55 10.168.1.12.241 Tue Sep 15 12:32 10.1. -a : Resolve addresses to hostnames. which is similar to short format except that only the login name.12 with 32 bytes of data: Reply from 192. Maximum = 0ms. Output varies based on the remote system. Approximate round trip times in milli-seconds: Minimum = 0ms.1.12: Packets: Sent = 4.13. login time.1. -h : Suppress printing of the . Received = 4.1.13. -f : Suppress printing the header that is normally printed in a non-long format printout.0.12: bytes=32 time<1ms TTL=128 Reply from 192. Lost = 0 (0% loss).-t : Ping the specified host until stopped. terminal. -l : Force long output format. and idle time are printed.0.1.65 Tue Sep 15 12:38 10. -v TOS : Type Of Service.12: bytes=32 time<1ms TTL=128 Reply from 192.12: bytes=32 time<1ms TTL=128 Reply from 192.12 OUTPUT: Pinging 192.0.142 .168.168.168. -i : Force "idle" output format. 7.project file in a long format printout.168. -r count : Record route for count hops. Average = 0ms. -i TTL : Time To Live. Example : ping 192. -w timeout : Timeout in milliseconds to wait for each reply.12: bytes=32 time<1ms TTL=128 Ping statistics for 192. 12. SYNTAX: who .0.228 Tue Sep 15 12:24 10.0.13.13. who Displays information about all the users currently logged onto the system. terminal number and the date and time that each user logged onto the system. It prints the effective userid (username) of the current user when invoked.248 Tue Sep 15 12:27 10.0.13.0.0.206 Tue Sep 15 11:56 10.179 Tue Sep 15 12:37 10.0. who am i It is a command found on most Unix-like operating systems.13.0.199 Tue Sep 15 12:05 10.13.159 Example 2: finger -i student OUTPUT Login Tty Login Time student ttyp1 Tue Sep 15 11:55 student ttyp2 Tue Sep 15 12:39 student ttyp3 Tue Sep 15 12:39 student ttyp4 Tue Sep 15 11:55 student ttyp5 Tue Sep 15 12:43 student ttyp6 Tue Sep 15 12:43 student ttyp7 Tue Sep 15 12:27 student ttyp9 Tue Sep 15 12:46 student ttyp10 Tue Sep 15 12:39 student ttyp11 Tue Sep 15 11:56 student ttyp12 Tue Sep 15 12:41 student ttyp13 Tue Sep 15 12:25 student ttyp14 Tue Sep 15 11:55 student ttyp15 Tue Sep 15 12:33 Idle 6 minutes 15 seconds 4 minutes 17 seconds 2 minutes 55 seconds 5 minutes 25 seconds 6 minutes 1 second 2 minutes 55 seconds 30 seconds 2 minutes 37 seconds 3 minutes 24 seconds 8.12.0. SYNTAX: who am i Example: who am i OUTPUT: student ttyp23 Sep 15 12:38 9.152 Tue Sep 15 12:29 10.122 Tue Sep 15 12:27 10.13. The user name.student student student student student student student student *p4 *p5 *p6 *p7 *p8 *p9 *p11 *p12 1 1 7 13 Tue Sep 15 11:55 10. Essentially it allowed many stations to broadcast at any time. SLOTTED ALOHA . so be it.Example: who OUTPUT: root tty02 root ttyp0 student ttyp1 student ttyp2 student ttyp3 student ttyp4 student ttyp5 student ttyp7 student ttyp8 student ttyp9 student ttyp10 student ttyp11 student ttyp13 student ttyp14 student ttyp15 Sep 3 10:24 Sep 3 10:24 Sep 15 11:55 Sep 15 12:32 Sep 15 12:39 Sep 15 11:55 Sep 15 12:37 Sep 15 12:27 Sep 15 12:24 Sep 15 12:27 Sep 15 12:39 Sep 15 11:56 Sep 15 12:25 Sep 15 11:55 Sep 15 12:39 PRACTICAL 7 AIM Write a program for implementing pure and slotted ALOHA.4%. It was designed to establish communication among the ice lands using a packet radio system. Pure Aloha had a maximum throughput of about 18. if two signals collided. PURE ALOHA The pure Aloha is the basic protocol in the family of Aloha protocols. At the end of every transmission every user knows whether the transmission was successful or collision took place. The transmitted packet is received correctly while if two of more packet transmissions overlap in time. This means that about 81. THEORY The ALOHA protocol is an OSI layer 2 protocol for LAN networks with broadcast topology. It considers a single hop system with an infinite population generating packets of equal length.6% of the total available bandwidth was essentially wasted due to losses from packet detection. The channel is error free without capture: whenever a packet of transmission does not interfere with any other packet transmission. Each station would simply wait a random time and try again. a collision is caused and none of the colliding packets is received correctly and they have to be retransmitted. (440+s*500).3. putpixel(58+g*150. CODING #include<iostream.225. Obviously the limits imposed which govern the random retransmission of the packet will have an effect on the delay associated with successful packet delivery.452. Slotted Aloha. initgraph(&gd.432. In the event of a collision."c:\\tc\\bgi").215). line(65. .5).442). line(45.gm. line(55.001) { delay(2).s.h> #include<math.g+=0. which introduced discrete timeslots and increased the maximum throughput to 36. A station can send only at the beginning of a timeslot.442). outtextxy(52.8%. s=-g*exp(-2*g).442).215.442).444.55.MAGENTA). putpixel(58+g*150.215).442.The channel bandwidth is a continuous stream of slots whose length is the time necessary to transmit one packet.575. each station involved in the collision retransmits at some random time in order to reduce the possibility of recollision."0"). and thus collisions are reduced. float g.55.g<=3.225.CYAN).&gm.55. A station with a packet to send will transmit on the next available slot boundary.0. If the limit is too long the probability of recollision lessens but there is unnecessary delay in the retransmission.h> void main() { clrscr().575. the probability of recollision is high. for (g=0. } settextstyle(2.440+s*500. line(565. If the limit is too short.h> #include<graphics.h> #include<dos. line(55. s=-g*exp(-1*g).575. line(565.h> #include<conio. int gd=DETECT. line(208.460.1.444.5).442."Slotted ALOHA: S=Ge^-G")."3.5).20")."1. outtextxy(2.5"). outtextxy(357."0.290."0.444. setlinestyle(3. line(135.366. getch(). delay(200).410.135.2).0").256).255).210. outtextxy(35.235.40"). delay(200).0."0.345."2.0").348. line(135.300. outtextxy(35. delay(200).55.10"). outtextxy(35.442.442. outtextxy(400."1. settextstyle(2.1). outtextxy(400."S (throughput per frame time)"). outtextxy(278.0").444.400. outtextxy(537."G (attempts per packet time)"). line(208. setcolor(15). delay(200).256.208. outtextxy(35. delay(200).436).1).442. settextjustify(1. line(366. settextstyle(2.286."0. line(546.346). outtextxy(190."Pure ALOHA: S=Ge^-2G")."0.3.442.444. settextjustify(0.55. delay(200).5"). } .444. outtextxy(200.546. delay(200).436). line(286.outtextxy(126.348).436).30"). OUTPUT .
Copyright © 2024 DOKUMEN.SITE Inc.