Networks Lab Part A INDEX PART –A Sl.N o. Date Program Staff Signature 1. Simulate a three nodes point – to – point network with duplex links between them. 2. Simulate a four node point-to-point network 3. Simulate the different types of Internet traffic such as FTP and TELNET over a network and analyze the throughput. 4. Simulate the transmission of ping messages over a network topology consisting of 6 nodes and find the number of packets dropped due to congestion. 5. Simulate an Ethernet LAN using n nodes (6-10), change error rate and data rate and compare throughput 6. Simulate an Ethernet LAN using n nodes and set multiple traffic nodes and determine collision across different nodes 7. Simulate an Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion window for different source / destination. 8. Simulate simple ESS and with transmitting nodes in wire-less LAN by simulation and determine the performance with respect to transmission of packets PART –B 1. Write a program for error detecting code using CRC-CCITT (16- bits). 2. Write a program for frame sorting technique used in buffers. Dept. Of CSE/ISE 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Networks Lab Part A
PROGRAM 1
Dept. Of CSE/ISE 1
INDEXPART –A
Sl.No. Date Program Staff Signature
1. Simulate a three nodes point – to – point network with duplex links between them.
2. Simulate a four node point-to-point network
3. Simulate the different types of Internet traffic such as FTP and TELNET over a network and analyze the throughput.
4. Simulate the transmission of ping messages over a network topology consisting of 6 nodes and find the number of packets dropped due to congestion.
5. Simulate an Ethernet LAN using n nodes (6-10), change error rate and data rate and compare throughput
6. Simulate an Ethernet LAN using n nodes and set multiple traffic nodes and determine collision across different nodes
7. Simulate an Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion window for different source / destination.
8. Simulate simple ESS and with transmitting nodes in wire-less LAN by simulation and determine the performance with respect to transmission of packets
PART –B1. Write a program for error detecting code using CRC-
CCITT (16- bits).2. Write a program for frame sorting technique used in
buffers.3. Write a program for distance vector algorithm to find
suitable path for transmission.4. Using TCP/IP sockets, write a client – server program
to make the client send the file name and to make the server send back the contents of the requested file if present.
5. Implement the above program using as message queues or FIFOs as IPC channels.
6. Write a program for simple RSA algorithm to encrypt and decrypt the data.
7. Write a program for Hamming code generation for error diction and correction.
8. Write a program for congestion control using leaky bucket algorithm.
Networks Lab Part A
Simulate a three nodes point-to-point network with duplex links between them. Set the queue size vary the bandwidth and find the number of packets dropped.
Procedure:
Step1: Select the hub icon on the toolbar and drag it onto the working window.
Step 2: Select the host icon on the toolbar and drag it onto the working window. Repeat this for another host icon.
Step 3: Select the link icon on the toolbar and drag it on the screen from host (node 1) to the hub and again from host(node 2) to the hub. Here the hub acts as node 3 in the point-to-point network. This leads to the creation of the 3-node point-to-point network topology. Save this topology as a .tpl file.
Step 4: Double-click on host(node 1), a host dialog box will open up. Click on Node editor and you can see the different layers- interface, ARP,FIFO, MAC, TCPDUMP, Physical layers. Select MAC and then select full-duplex for switches and routers and half duplex for hubs, and in log Statistics, select Number of Drop Packets, Number of Collisions,Throughput of incoming packets and Throughput of outgoing packets.Select FIFO and set the queue size to 50 and press OK. Then click on Add. Another dialog box pops up. Click on the Command box and type the Command according to the following syntax: stg [-t duration(sec)] [-p port number] HostIPaddrand click OK.
Step 5: Double-click on host (node 2), and follow the same step as above with only change in command according to the following syntax: rtg [-t] [-w log] [-p port number] and click OK.
Step 6: Double click on the link between node 1 and the hub to set the bandwidth to some initial value say, 10 Mbps. Repeat the same for the other node.
Step 7: Click on the E button (Edit Property) present on the toolbar in order to save the changes made to the topology. Now click on the R button (Run Simulation). By doing so a user can run/pause/continue/stop/abort/disconnect/reconnect/submit a simulation. No simulation settings can be changed in this mode.
Dept. Of CSE/ISE 2
Networks Lab Part A
Step 8: Now go to Menu->Simulation->Run. Executing this command will submit the current simulation job to one available simulation server managed by the Dispatcher. When the simulation server is executing, the user will see the time knot at the bottom of the screen move. The time knot reflects the current virtual time (progress) of the simulation case.
Step 9: To start the playback, the user can left-click the start icon( |>) of the time located at the bottom. The animation player will then start playing the recorded packet animation.
Step 10: Change the bandwidth say, 9 Mbps, and run the simulation and compare the two results.
Step 11: To view the results, go to the filename. Results folder
Dept. Of CSE/ISE 3
Networks Lab Part A
Sender : stcp –p 1500 –l 1024 1.0.1.2
Receiver : rtcp –p 1500 –l 1024
Parameter : Number of packets dropped.
Output: No packets dropped.
PROGRAM 2Simulate a four node point-to-point network, and connect the links as follows: n0-n2, n1-n2 and n2-n3. Apply TCP agent between n0-n3 and UDP n1-n3. Apply relevant applications over TCP and UDP agents changing the parameter and determine the number of packets by TCP/UDP.
Procedure:
Step 1: Create the topology as specified in the question, in the draw mode of the simulator.
Step 2: Go to edit mode and save the topology.
Step 3: Setup a TCP connection between node 1 and node 3 using the following commands:
PROGRAM 4Simulate the transmission of ping messaged over a network topology consisting of 6 nodes and find the number of packets dropped due to congestion.
Procedure:Step 1: Click on the subnet icon on the toolbar and then click on the screen of the
working window.
Step 2: Select the required number of hosts and a suitable radius between the host and the switch.
Step 3: In the edit mode, get the IP address of one of the hosts say, host 1 and then for the other host say, host2 set the drop packet and no: of collisions statistics.
Step 4: Now run the simulation.
Step 5: Now click on any one of the hosts and click on command console and ping the destination node.
Dept. Of CSE/ISE 8
Networks Lab Part A
Sender 1 : stcp –p 1500 –l 1024 1.0.1.3
Receiver : rtcp –p 1500 –l 1024
Parameter : Number of Packets Dropped.
Output: No packets dropped.
Dept. Of CSE/ISE 9
Networks Lab Part A
PROGRAM 5Simulate an Ethernet LAN using N- nodes(6-10), change error rate and data rate and compare the throughput.
Procedure:
Step 1: Connect one set of hosts with a hub and another set of hosts also through a hub and connect these two hubs through a switch. This forms an Ethernet LAN.
Step 2: Setup a TCP connection between a host on one hub and host on another hub using the following command:
PROGRAM 6Simulate an Ethernet LAN using N nodes and set multiple traffic nodes and determine collision across different nodes.
Procedure:
Step 1: Connect one set of hosts with a hub and another set of hosts also through a hub and connect these two hubs through a switch. This forms an Ethernet LAN.
Step 2: Setup multiple traffic connections between the hosts on one hub and hosts on another hub using the following command:
Step 3: Setup the collision log at the destination hosts in the MAC layer.
Step 4: View the results in the filename.results.
Dept. Of CSE/ISE 12
Networks Lab Part A
Sender 1 : stcp –p 1500 –l 1024 1.0.1.3
Receiver : rtcp –p 1500 –l 1024
Parameter : Number of Collision Packets.
Output:
Sender Receiver
Initial Error Rate: 0.0 Initial Error Rate: 0.0Initial Data Rate:10.0 Initial Data Rate: 5.0
Number of collisions : 290-1062
Initial Error Rate: 5.0 Initial Error Rate: 5.0Initial Data Rate:10.0 Initial Data Rate: 5.0
Number of collisions : 284-1080
Dept. Of CSE/ISE 13
Networks Lab Part A
PROGRAM 7Simulate an Ethernet LAN using N nodes and set multiple traffic nodes and plot congestion window for different source/destination.
Procedure:Step 1: Connect one set of hosts with a hub and another set of hosts also through a hub and connect these two hubs through a switch. This forms an Ethernet LAN.
Step 2: Setup multiple traffic connections between the hosts on one hub and hosts on another hub using the following command:
Parameter : Number of Collision Packets and Packets Dropped.
Output:
Collision Packets for sender: 6- 384Collision Packets for receiver: 522-1068
Packets Dropped for sender: 6-384Packets Dropped for receiver: 522-1068
Dept. Of CSE/ISE 15
Networks Lab Part A
PROGRAM 8Simulate simple ESS and with transmitting nodes in wireless LAN simulation and determine the performance with respect to transmission of packets.
Procedure:
Step 1: In the Draw mode, Select a Host/node and place it on the top.Step 2: Place a router below it.Step 3: Place two access points to the left and right of the router.Step 4: Connect these with point-to-point networkStep 5: Select Mobile Nodes and place them in all four directions of the access points.Step 6: Connect these with multipoint network.Step 7: Select Subnet Node option and click on each access points and mobile nodes such that we have two subnets for two parts. Step 8: In the edit mode, select Host -> add and insert the command rtcp –r –u –s -p [port]Step 9: Select each mobile node ->application -> add and insert the command ttcp –t –u –s –p [port] [receiver’s IP]Step 10: Click on Link between router and access point, Select delay=10000 and click CIAL.Step 11: In Run mode, Go to Simulation and select RunStep 12: To start the playback, the user can left-click the start icon ( |>) of the time located at the bottom. The animation player will then start playing the recorded packet animation.
PROGRAM 1Write a program for error detecting code using CRC-CCITT (16- bits).
Program:#include<stdio.h>#include<string.h>#include<conio.h>#define N strlen(g)char t[128], cs[128], g[]="10001000000100001";int a, e, c;void xor() { for(c=1;c<N;c++) cs[c]=((cs[c]==g[c])?'0':'1');}void crc() { for(e=0;e<N;e++) cs[e]=t[e]; do { if(cs[0]=='1') xor(); for(c=0;c<N-1;c++) cs[c]=cs[c+1]; cs[c]=t[e++]; }while(e<=a+N-1);}void main() { clrscr(); printf("\nEnter poly : "); scanf("%s",t); printf("\nGenerating Polynomial is : %s",g); a=strlen(t); for(e=a;e<a+N-1;e++) t[e]='0'; printf("\nModified t[u] is : %s",t); crc(); printf("\nChecksum is : %s",cs); for(e=a;e<a+N-1;e++) t[e]=cs[e-a]; printf("\nFinal Codeword is : %s",t); printf("\nTest Error detection 0(yes) 1(no) ? : "); scanf("%d",&e); if(e==0) { printf("Enter position where error is to inserted : "); scanf("%d",&e); t[e]=(t[e]=='0')?'1':'0'; printf("Errorneous data : %s\n",t); } crc(); for (e=0;(e<N-1)&&(cs[e]!='1');e++); if(e<N-1) printf("Error detected."); else printf("No Error Detected."); getch(); }
Dept. Of CSE/ISE 18
Networks Lab Part B
OUTPUT
Enter poly : 1011101Generating Polynomial is : 10001000000100001Modified t[u] is : 10111010000000000000000Checksum is : 1000101101011000Final Codeword is : 10111011000101101011000Test Error detection 0(yes) 1(no) ? : 0Enter position where you want to insert error : 3Errorneous data : 10101011000101101011000Error detected.Enter poly : 1011101Generating Polynomial is : 10001000000100001Modified t[u] is : 10111010000000000000000Checksum is : 1000101101011000Final Codeword is : 10111011000101101011000Test Error detection 0(yes) 1(no) ? : 1No Error Detected.
Dept. Of CSE/ISE 19
Networks Lab Part B
PROGRAM 2Write a program for frame sorting technique used in buffers.
Program:
#include<stdio.h>struct frame{
char info[15];int fno;
};struct frame arr[10];int n;void sort(){
int i,j;struct frame temp;for(i=0;i<n-1;i++){
for(j=0;j<n-i-1;j++)if(arr[j].fno>arr[j+1].fno){
temp=arr[j];arr[j]=arr[j+1];arr[j+1]=temp;
}}
}int main(){
int i,j;printf("Enter the no.of frames\n");scanf("%d",&n);printf("Enter the frame no and data into the frame\n");for(i=0;i<n;i++)scanf("%d %s",&arr[i].fno,arr[i].info);sort();printf("sorted frame and data are:\n");for(i=0;i<n;i++)printf("%d\t%s\n",arr[i].fno,arr[i].info);return 0;
}
Dept. Of CSE/ISE 20
Networks Lab Part B
OUTPUT
Enter the no.of frames 4Enter the frame no and data into the frame4 ise 1 we 3 to 4 belongSorted frame and data are:Webelongtoise1 we2 belong3 to4 ise
Dept. Of CSE/ISE 21
Networks Lab Part B
PROGRAM 3Write a program for distance vector algorithm to find suitable path for transmission.
Program:
#include<stdio.h>#include<stdlib.h>
int a[8][8],n;
void floid(){
int i,j,k;
for(k=1;k<=n;k++){
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
a[i][j]=min(a[i][j],a[i][k]+a[k][j]);}
}}
}
int min(int a,int b){
return a<b?a:b;}
int main(){
int i,j;
printf("\n Enter the number of routers:");scanf("%d",&n);
printf("\n Enter the distance matrix values \n");for(i=1;i<=n;i++)
Enter the number of routers:4Enter the distance matrix values0 1 3 9991 0 999 13 999 0 2999 1 2 0Distance vector matrix: 0 1 3 21 0 3 13 3 0 22 1 2 0
Dept. Of CSE/ISE 24
Networks Lab Part B
PROGRAM 4Using TCP/IP sockets, write a client – server program to make the client send the file name and to make the server send back the contents of the requested file if present.
if(bind(sockfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr))<0)perror("error binding");listen(sockfd,5);clilen=sizeof(cli_addr);printf("SERVER waiting for the CLIENT------\n");
printf("SERVER:Transferring the content:%s",p);num2=write(fd2,c,5000);
}}
}printf("\n Transfer completed");return 1;
}
Dept. Of CSE/ISE 31
Networks Lab Part B
OUTPUT
Server:
[root@localhost CN Lab] ./s.oWaiting for connection Request..Connection Established..Client has requested file alpha[root@localhost CN Lab]
Client:[root@localhost CN Lab] ./c.oTrying to Connect to Server..Connected..Enter the filename to request from server: alphaWaiting for Server to reply..This a demo of client server using SocketsJust for trial.Now End of file[root@localhost CN Lab]
Dept. Of CSE/ISE 32
Networks Lab Part B
PROGRAM 6Write a program for simple RSA algorithm to encrypt and decrypt the data.
Program:
#include <stdio.h>#include <string.h>#include <conio.h>#include <math.h>int mult(unsigned int x, unsigned int y, unsigned int n) { unsigned long int k=1; int j; for (j=1; j<=y; j++) k = (k * x) % n; return (unsigned int) k;} void main () { char msg[100]; unsigned int pt[100], ct[100], n, d, e, p, q, i; printf("Enter message : "); gets(msg); //strcpy(pt, msg); for(i=0;i<strlen(msg);i++) pt[i]=msg[i]; n = 253; d = 17; e = 13; printf("\nCT = "); for(i=0; i<strlen(msg); i++) ct[i] = mult(pt[i], e,n); for(i=0; i<strlen(msg); i++) printf("%d ", ct[i]); printf("\nPT = "); for(i=0; i<strlen(msg); i++) printf("%c", pt[i]); for(i=0; i<strlen(msg); i++) pt[i] = mult(ct[i], d,n) ;}
Dept. Of CSE/ISE 33
Networks Lab Part B
OUTPUT
Enter message: alpha
CT = 113 3 129 213 113
PT = alpha
Dept. Of CSE/ISE 34
Networks Lab Part B
PROGRAM 7Write a program for Hamming code generation for error detection and correction.
0,0,1,1,1,0,1};char gmatrix[4][8]={ "0111000", "1010100", "1100010", "1110001"};void main() { int i,j; clrscr(); cout<<"Hamming Code --- Encoding\n"; cout<<"Enter 4 bit data : "; cin>>data; cout<<"Generator Matrix\n"; for(i=0;i<4;i++) cout<<"\t"<<gmatrix[i]<<"\n"; cout<<"Encoded Data : "; for(i=0;i<7;i++) { for(j=0;j<4;j++) encoded[i]+=((data[j]- '0')*(gmatrix[j][i]- '0')); encoded[i]=encoded[i]%2; cout<<encoded[i]<<" "; } cout<<"\nHamming code --- Decoding\n"; cout<<"Enter Encoded bits as received : "; for(i=0;i<7;i++) cin>>edata[i]; for(i=0;i<3;i++) { for(j=0;j<7;j++) syndrome[i]=syndrome[i]+(edata[j]*hmatrix[i][j]); syndrome[i]=syndrome[i]%2; } for(j=0;j<7;j++) if ((syndrome[0]==hmatrix[0][j])&&(syndrome[1]==hmatrix[1][j])&&
(syndrome[2]==hmatrix[2][j])) break;
Dept. Of CSE/ISE 35
Networks Lab Part B
if(j==7) cout<<"Data is error free!!\n"; else { cout<<"Error received at bit number "<<j+1<<" of the data\n"; edata[j]=!edata[j]; cout<<"The Correct data Should be : "; for(i=0;i<7;i++) cout<<edata[i]<<" ";} } }
Dept. Of CSE/ISE 36
Networks Lab Part B
OUTPUT
Hamming Code --- EncodingEnter 4 bit data : 1 0 1 0Generator Matrix 0111000 1010100 1100010 1110001Encoded Data : 1 0 1 1 0 1 0Hamming code --- DecodingEnter Encoded bits as received : 1 0 1 1 0 1 1Error received at bit number 7 of the dataThe Correct data Should be : 1 0 1 1 0 1 0