LAB MANUAL Sub Code :- CS2307 Sub Name :- Network Lab Branch :- COMPUTER SCIENCE AND ENGINEERING Semester :- 05 LIST OF EXPERIMENTS CS2307 - NETWORK LAB 1. Study of Network Commands 2a. Using TCP SOCKETS ( DATE TIME SERVER & CLIENT ) 2b. Using TCP SOCKETS ( ECHO SERVER & CLIENT) 2c.Using TCP SOCKETS ( TCP CHAT ) 3a. Using UDP SOCKETS ( RESOLVING THE DNS SERVER USING UDP ) 3b.USING SOCKETS ( DOMAIN NAME SERVER ) 4. Using RAW Sockets ( Packet Capturing And Filtering) 5. Programs Using RPC 6. Simulation of Sliding Window Protocols ( NS2 simulators) 7. Implementing Routing Protocols (OSPF ,DSDV) 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
LAB MANUAL
Sub Code :- CS2307
Sub Name :- Network Lab
Branch :- COMPUTER SCIENCE AND ENGINEERING
Semester :- 05
LIST OF EXPERIMENTS
CS2307 - NETWORK LAB
1. Study of Network Commands
2a. Using TCP SOCKETS ( DATE TIME SERVER & CLIENT )
2b. Using TCP SOCKETS ( ECHO SERVER & CLIENT)
2c.Using TCP SOCKETS ( TCP CHAT )
3a. Using UDP SOCKETS ( RESOLVING THE DNS SERVER USING UDP )
3b.USING SOCKETS ( DOMAIN NAME SERVER )
4. Using RAW Sockets ( Packet Capturing And Filtering)
5. Programs Using RPC
6. Simulation of Sliding Window Protocols ( NS2 simulators)
7. Implementing Routing Protocols (OSPF ,DSDV)
8. Performance Comparison of MAC protocols
9. Performance comparison of Routing Protocols
10. Study of UDP performance
11. Study of TCP Performance
1
REQUIREMENTS
1. SOFTWARE
C++ Compiler J2SDK (freeware) Linux NS2/Glomosim/OPNET
(Freeware)
2. HARDWARE
PCs
2
INDEX
S.NO EXPRIMENT NAME
1. Study of Network Commands
2a. Using TCP SOCKETS ( DATE TIME SERVER & CLIENT )
2b. Using TCP SOCKETS ( ECHO SERVER & CLIENT)
2c. Using TCP SOCKETS ( TCP CHAT )
3a. Using UDP SOCKETS ( RESOLVING THE DNS SERVER USING UDP )
3b. USING SOCKETS ( DOMAIN NAME SERVER )
4. Using RAW Sockets ( Packet Capturing And Filtering)
5. Programs Using RPC
6. Simulation of Sliding Window Protocols ( NS2 simulators)
7. Implementing Routing Protocols (OSPF ,DSDV)
8. Performance Comparison of MAC protocols
9. Performance comparison of Routing Protocols
10. Study of UDP performance
11. Study of TCP Performance
3
EX.No:1 STUDY OF NETWORK COMMANDS
1. SOCKET FUNCTION
Int Socket(int family , int type , int protocol);
It returns non negative value if ok, -1 on error.
FAMILY DESCRIPTION
AF_INET
AF_INET6
Ipv4 Protocol
Ipv6 Protocol
TYPE DESCRIPTION
Sock_STREAM
Sock_DGRAM
Sock_RAW
Stream socket- TCP
Datagram socket-UDP
Raw socket-Ipv4, Ipv6
2. CONNECT FUNCTION:
Int connect(int sockfd, const struct sockaddr * sockaddr, socklen_t addrlen);
Returns 0 if ok, -1 on error.
- It is used to client to establish a connection with a TCP server.
4
3. BIND FUNCTION
Int bind(int sockfd, const struct sockaddr *myaddr, socklen_t_addrlen);
Returns 0 if ok, -1 on error.
- It assigns a local protocol address to a socket
- second argument is a pointer to a protocol specific address
- third argument is the size of this address structure
- calling bind let us specify a port number an IP address, both or
neither.
4. LISTEN FUNCTION It will called only by a TCP server.
Int listen(int sockfd, int backlog);
- When a socket is created by the socket function, a client socket
will issue a connect. The listen function converts an
unconnected socket in to passive socket.
- The second argument to this function specifies the maximum
number of connections that the kernel should queue for this
socket.
5. CLOSE FUNCTION:Int close(int sockfd)
- The default action of close with a TCP socket is to mark the
socket as closed and return to the process immediately.
5
EX.NO:- 2a DAY AND TIME OF SERVER
AIM:
To display the day and time of the server using Telnet.
ALGORITHM:
SERVER:
1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM family
and default protocol.3) Initialise the socket and set its attributes and assign a specific port number as
desired4) Bind the server to the socket using Bind function.5) Wait for the client requests . On request establish a connection using accept
function.6) Send the day and time to the client.7) Repeat the steps until the connection is terminated.8) Stop the program.
CLIENT:
1) Start the program.
2) Create a socket with address family AF_INET type SOCK_STREAM family and default protocol.
3) Initialise the socket and set its attributes and assign a specific port number as desired
4) Connect to the server using connect function to initialise the request.5) Receive day and time from the server.6) Repeat the steps until the connection is terminated.7) Stop the program.
6
CLIENT PROGRAM:-
#include<stdio.h>#include<stdlib.h>#include<sys/socket.h>#include<sys/types.h>#include<netdb.h>int main(){int sd,c;char msg[50],sip[15];struct sockaddr_in caddr;struct hostent *he;printf("enter server IP address");scanf("%s",sip);he=gethostbyname(sip);sd=socket(AF_INET,SOCK_STREAM,0);if(sd!=-1)printf("socket is created\n");elseprintf("socket is no created\n");caddr.sin_family=AF_INET;caddr.sin_port=htons(5666);c=connect(sd,(struct sockaddr *)&caddr,sizeof(caddr));if(c==0)printf("connected to server");elseprintf("not connected");recv(sd,msg,sizeof(msg),0);printf(" the day and time of the server is %s",msg);close(sd);return 0;}
7
SERVER PROGRAM:-
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<sys/socket.h>#include<sys/types.h>#include<netinet/in.h>#include<unistd.h>int main(){int sd,b,cd;char msg[50];struct sockaddr_in caddr,saddr;socklen_t clen=sizeof(caddr);time_t tick;sd=socket(AF_INET,SOCK_STREAM,0);if(sd!=-1)printf("socket is created\n");elseprintf("socket is not created\n");saddr.sin_family=AF_INET;saddr.sin_addr.s_addr=htonl(INADDR_ANY);saddr.sin_port=htons(5666);b=bind(sd,(struct sockaddr *)&saddr,sizeof(saddr));if(b==0)printf(“bind to client:\n”);elseprintf(“not bind to client:\n”);listen(sd,5);while(1){cd=accept(sd,(struct sockaddr *)&caddr,&clen);tick=time(NULL);printf("system day and time %s",ctime(&tick));strcpy(msg,ctime(&tick));send(cd,msg,sizeof(msg),0);}close(sd);close(cd);return 0;
}
8
OUTPUT:-SERVER:-
[vt4862@localhost ~]$ cc sday.c [vt4862@localhost ~]$ ./a.out socket is created binded to client system day and time:Fri Mar 6 15:17:26 2009
CLIENT:-
[vt4862@localhost ~]$ cc cday.c[vt4862@localhost ~]$ ./a.out
enter ip address:100.30.20.10
9
socket is created connected to server the day and time erver is Fri Mar 6 15:17:26 2009[vt4862@localhost ~]$
RESULT:- Thus the day time server is executed and the output is verified.
EX.NO:- 2b TCP – SIMPLE MESSAGE PASSING
AIM: To enable a simple message passing between client and server.
ALGORITHM: SERVER:
1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM
family and default protocol.3) Initialise the socket and set its attributes and assign a specific port
number as desired4) Bind the server to the socket using Bind function.5) Wait for the client requests . On request establish a connection using
accept function.6) Fork a child process perform steps 7-10 for each process.7) Read the message from the client through the connection.8) Display the client’s message9) Send an acknowledgement message to the client.10) Exit the child process and close the connection.
CLIENT:1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM
family and default protocol.3) Initialise the socket and set its attributes and assign a specific port
number as desired4) Connect to the server using connect function to initialise the request.5) Send the message to the server.6) Receive an acknowledgement from the server.7) Stop the program.
#include<stdio.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>#include<netdb.h>#define SERV_PORT 5001int main(int argc,char* argv[]){int sockfd;struct sockaddr_in serv_addr;struct hostent *server;char buffer[4096];sockfd=socket(AF_INET,SOCK_STREAM,0);serv_addr.sin_family=AF_INET;serv_addr.sin_addr.s_addr=inet_addr("30.29.28.200");serv_addr.sin_port=htons(SERV_PORT);connect(sockfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr));printf("\nEnter your message to send....\n");bzero(buffer,4096);printf("\nclient:");fgets(buffer,4096,stdin);write(sockfd,buffer,4096);bzero(buffer,4096);read(sockfd,buffer,4069);printf("\n Server message :%s",buffer);printf("\n");close(sockfd);return(0);}
12
OUTPUT
SERVER SIDE:
[vt4802@localhost ~]$ ./a.out
client:hai
CLIENT SIDE:
[vt4802@localhost ~]$ ./a.out
enter ur msg to send.......
13
client:hai server msg:hai
RESULT:
Thus the program for Simple message passing using TCP was successfully executed and verified.
EX.NO:- 2c TCP – SIMPLE CHAT (HALF DUPLEX)
AIM: To enable chatting between the client and server.
ALGORITHM:
SERVER:1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM family
and default protocol.3) Initialise the socket and set its attributes and assign a specific port number as
desired4) Bind the server to the socket using Bind function.5) Establish the listen queue using the listen function.6) Wait for the client requests . On request establish a connection using accept
function.7) Repeat the steps 8-10 until the server sends “bye”.8) Read the message from the client through the connection using read function
and display the client’s message9) If the client message is “bye” goto step 11.10) Accept the server message and write it to the client using write function.11) Close the connection.12) Goto step 6.
CLIENT:1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM family
and default protocol.3) Initialise the socket and set its attributes and assign a specific port number as
desired4) Connect to the server using connect function to initialise the request.5) Repeat the steps 6-8 until the server sends “bye”6) Accept the client message and write it to the server using write function.
14
7) If the client message is “bye” goto step 9.8) Read the message using read function and display the message9) Stop the program.
int sockfd;struct sockaddr_in serv_addr;struct hostent *server;char buffer[4096];sockfd=socket(AF_INET,SOCK_STREAM,0);serv_addr.sin_family=AF_INET;serv_addr.sin_addr.s_addr=inet_addr("30.29.28.200");serv_addr.sin_port=htons(SERV_PORT);connect(sockfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr));do{
bzero(buffer,4096);printf("\nClient Message:");fgets(buffer,4096,stdin);write(sockfd,buffer,4096);bzero(buffer,4096);read(sockfd,buffer,4096);printf("\n Server Message :%s",buffer);
client message:hi server:hello how are youclient message:am fine server:ok take careclient message:bye server:bye
[vt4862@localhost ~]$
CLIENT SIDE:
[vt4862@localhost ~]$ ./a.out
client:hi server message:hello how are you
17
client:am fineserver message:ok take care client:byeserver message:bye
[vt4862@localhost ~]$
RESULT:Thus the program for TCP Simple chat is executed and output is verified.
EX.NO:- 3a) UDP SOCKETS ( RESOLVING THE DNS SERVER USING UDP)
AIM: To implement the resolving of hostname by a DNS server.
ALGORITHM:
1) Start the program.2) Obtain the service name and protocol.3) Enter the port number and address type.4) Similarly follow the above step once again.5) The subsequent steps makes the required output to be displayed on the output
screen.6) The output is verified after executing the program.7) Stop the program.
PROGRAM:
#include<netdb.h>main(){
struct servent *sptr;int port;char pro[100],name[100];printf("Enter the ser name:");scanf("%s",name);printf("\n Enter the protocol(UDP/TCP):");scanf("%s",pro);sptr=getservbyname(name,pro);printf("\n port no:%d",sptr->s_port);printf("\n address:%s",sptr->s_name);printf("enter the service port no");scanf("%d",&port);printf("Enter the protocol(UDP/TCP):");
18
scanf("%s",pro);sptr=getservbyport(htons(port),pro);printf("\n port no:%d",sptr->s_port);printf("\n addr:%s",sptr->s_name);printf("\n protocol:%s",sptr->s_proto);
}
Output:
[vt4862@localhost ~]$ cc adns.c[vt4862@localhost ~]$ ./a.out a.txt enter service namehttp enter the protocol (UDP/TCP)tcp portno:20480 address:http enter the service port no80
19
enter protocol (UDP/TCP)tcp port no:20480 address:http protocol:tcp[vt4862@localhost ~]$
Result:
Thus the resolver server using domain name space is executed and the output is verified.
EX.NO:- 3b) DOMAIN NAME SERVER USING UDP
AIM: To implement Domain Name Server using UDP client- server program.
ALGORITHM: SERVER:
1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM
family and default protocol.3) Assign IP address, port number and protocol family to the members.4) Bind the IP address, port number and protocol family to the socket.5) Listen for requests from client.6) Obtain the hostname and retrieve address using gethostbyname
function.7) Write the host address to the client side.8) Close the socket.
CLIENT: 1) Start the program.2) Create a socket with address family AF_INET type SOCK_STREAM
family and default protocol.
20
3) Initialize the socket and its attributes.4) Enter the hostname and write it to the server.5) Read the IP address and display it.6) Close the socket.
{len=sizeof(cliaddr);n=recvfrom(sockfd,msg,100,0,(struct sockaddr*)&cliaddr,&len);msg[n]='\0';printf("%s\n",msg);if(n<0){perror("Send error");}if((hp=gethostbyname(msg))==NULL){printf("cant get address");}if(inet_ntop(AF_INET,hp->h_addr_list[0],buf,sizeof(buf))<=0)printf("Host address not available\n");printf("%s",buf);sendto(sockfd,buf,sizeof(buf),0,(struct sockaddr*)&cliaddr,len);}}
Thus the Domain name server using UDP is executed and output is verified.
EX.NO:- 4 RAW SOCKETS
4a)
Aim :- To implement Socket Creation
Algorithm:
Step1: Start the program Step2:Declare two integers socket fd1,fd2Step3:Define sockfd socket which transmit data as stream of bytes.Step4:-Define sockfd2 as socket which transmit data as datagramStep5: If socket fd is -1 then display socket 1 is not created Step6: If sockfd2 is -1 then display socket 2 is not created else obtain file descriptorStep7:Stop the Program.
{printf(“\n Socket Creation”);int sockfd1,sockfd2;sockfd1=socket(AF_INET,SOCK_STREAM,0);sockfd2=socket(AF_INET,SOCK_STREAM,0);if(sockfd1==-1){ printf(”\nSocket is not created”);}
else{
prints(“\nSocket1 is not created”);printf(“\n socket1 file descriptor is “ %d,sockfd1);
}if(sockfd2==-1){
printf(“\n cokcet1 is not created”);}
else{
printf(“\n socket is created”);printf(“\n socket2 file descriptor is :%d,sockfd2);
}}
OUTPUT
SOCKET CREATION
Socket1 is created
Socket1 file descriptor is :3
Socket2 is created
Socket2 file descriptor is :3
27
Result :- Thus Socket has been created successfully
Ex.No :- 4b SOCKET BINDING
Aim: To implement Socket Binding
Algorithm:
Step1: Start the program Step2: Define the portno globally as 2000Step3:Declare the initial variable sockfd1Step4:Define the structure for both client and serverStep5:If sockfd is transmitted as stream of bytes it is equal to -1 then display “ Error Message”Step6:Using the member fun access the structure value such as sin_family,sin_port,sin_addrStep7:If size of bind value is not -1 then display socket bounded portno else display Bind errorStep8: Stop the Program.
printf(“\nsocket is binded to port number %d”,i);}else{printf(“\n binding error”);}}
OUTPUT
Socket binding
Socket bounded to port number 2000
29
Result :- Thus Socket has been Binding successfully
EX.NO:-5 RPC
AIM :-
To implement Remote Procedure Call.
ALGORITHM:-
Step1:Start the programStep2:create a remote interfaceStep3:create implementation for remote methods.Step4:Generating stub abd skeleton classes using rmi complierStep5:The client classfile,the stub classfile and the interface class files are placed on client machine.Step6:The server classfile,interface classfile and the skeleton classfile placed on server machine.Step7:Create an instance of Remote object Step8:Create an instance of Remote object.Step9:Register the Remote objectStep10:Invoke the Remote Methods
30
Step11:Stop the program
PROGRAM:-
/* INTERFACE PROGRAM*/
import java.rmi.*;
public interface SerInt extends Remote{double add(double d1,double d2)throwa RemoteExecution;}
import java..rmi.*;import java.rmi.registry.*;public class AddServer
{
public static void main(String arg[]){
31
try{
AddServerimpl asim=new AddServerimpl();Registry reg=LocateRegistry.createRegistry(5000);Reg.rebind(“AddServer”,asim);System.out.println(“Server start…”);String ab[]=reg.list();System.out.println(“the remote object available are “);For(int i=0;i<ab.length;i++)System.out.println(ab[i]);}catch(Exception e){System.out.println(“Exception “ +e);
} }}
/* ADDCLIENT PROGRAM */
import java.rmi.*;public class AddClient
public static void main(String args[]){try{SerInt adInt=(SerInt)Naming.lookup(“rmi://localhost:5000/AddServer”);System.out.println(“The first number is”+args[0]);Double d1=Double.valueOf(args[0].doubleValue();System.out.println(:the second number is : “+args[1]);double d2=double.ValueOf(args[1].doubleValue();System.out.println(“The sum is :”+adint.add(d1,d2));}catch(Exception e){System.out.println(“Exception : “+e);}
The First number is : 1The Second number is : 2The Sumis : 3.0
RESULT:Thus the program for implementing RMI/RPC executes successfully.
EX.NO:- 6 SLIDING WINDOW PROTOCOL
AIM : To avoid congestion and to ensure reliable data transfer.
ALGORITHM: 1) Start the program 2) Sender keeps track of outstanding frames and updates the variables and window as acknowledgements arrive. 3) Receiver sliding window waits for a specific frame to arrive in a specific order and frame arriving out of order is discarded and needs to be resent . 4) Commence transmission. 5) Deal with damaged or lost frame. 6) Deal with damaged or lost acknowledgement. 7) Deal with delayed acknowledgement. 8) Update sender window size. 9) Stop the program. PROGRAM:#include<stdio.h>
33
#include<conio.h>#include<stdlib.h>void main(){int temp1,temp2,temp3,temp4;int winsize=8;int noframes,moreframes,i;int receiver(int);int simulate(int);temp1=0;temp2=0;temp3=0;temp4=0;clrscr();for(i=0;i<200;i++)rand();noframes=5;printf("\nNo. of frames is %d",noframes);getch();moreframes=noframes;while(moreframes>0){temp1=simulate(winsize);winsize=temp1;temp4+=temp1;if(temp4>noframes)temp4=noframes;for(i=temp3+1;i<=temp4;i++)printf("\nSending frame %d",i);getch();temp2=receiver(temp1);temp3+=temp2;if(temp3>noframes)temp3=noframes;printf("\nAcknowledgement for the frames upto %d",temp3);getch();moreframes-=temp2;temp4=temp3;if(winsize<=0)winsize=8;}printf("\nEnd of SLIDING WINDOW PROTOCOL");getch();}int receiver(int temp1){
34
int i;for(i=0;i<100;i++)rand();i=rand()%temp1;return 1;}int simulate(int winsize){int temp1,i;for(i=0;i<50;i++)temp1=rand();if(temp1==0)temp1=simulate(winsize);i=temp1%winsize;if(i==0)return winsize;elsereturn temp1%winsize;}
Thus the program to do the SLIDING WINDOW PROTOCOL was executed and output was verified.
EX.NO:-7a ROUTING PROTOCOL (OSPF)
AIM: To find the shortest path on interior routing protocol based on link state routing Update table inside autonomous systems.
ALGORITHM: 1) Start the program. 2) Use the link state routing to update the routing table area. 3) Each router sends the state of its neighbourhood to every other router it does so by flooding. 4) Each neighbour sends the packet to all its neighbours. 5) Each router shares the state of its neighbourhood only when there is a change. 6) From this router calculate the shortest path between itself and each in the network. 7) Stop the program.
typedef struct edge{int wt;}edge;edge connection[10][10];int n;void main(){int perm[10];int source,dest,i,j;int shortest(int,int);clrscr();printf("\nEnter the no. of routers:");scanf("%d",&n);printf("\nEnter the connection matrix of routers:\n");for(i=1;i<=n;i++)for(j=1;j<=n;j++)scanf("%d",&connection[i][j].wt);for(i=1;i<=n;i++)
for(j=1;j<=n;j++)if(connection[i][j].wt!=INFIN)printf("\npath found between %d and %d with cost : %d",i,j,connection[i][j]);printf("\nEnter the source router:");scanf("%d",&source);printf("\nEnter the destination router :");scanf("%d",&dest);printf("\nSHORTEST PATH : %d",shortest(source,dest));printf("\nPress any key");getch();}int shortest(int source,int dest){int small,perm[10],current,new1,start,temp,i,dist[10],k=1;for(i=1;i<=n;i++){perm[i]=0;dist[i]=INFIN;erm[source]=1;dist[source]=0;current=source;//printf("%d",current);while(current!=dest){small=INFINITY;start=dist[current];
path found between 1 and 1 with cost : 10path found between 1 and 2 with cost : 15path found between 2 and 1 with cost : 7path found between 2 and 2 with cost : 12Enter the source router: 2
Enter the destination router: 1
SHORTEST PATH: 7Press any key
38
RESULT
Thus the program to find the shortest path using OSPF routing protocol was executed and output was verified.
EX.NO:-7b DISTANCE VECTOR ROUTING PROTOCOL
PROGRAM
#include<stdio.h>main(){int a[50],hc[20],d[20],n,i,h[50],m,d1[50],flag,j,k,flag1,ch;char r[10][20],nn,ht;printf("Enter the number in routing table");scanf("%d",&n);j=0;for(i=0;i<n;i++){printf("Enter the Destination:Net");scanf("%d",&d[i]);printf("Enter the Hop Count:");scanf("%d",&hc[i]);printf("Enter the Next Router:");scanf("%s",&r[j][i]);}do{printf("Old routing Table");printf("\ndestination\thopcount\trouter\n");
printf("\nEnter the Router Name");scanf("%s",&nn);r[0][0]=ht;
printf("\nEnter the number in message table\n");scanf("%d",&m);for(i=0;i<m;i++){printf("Enter the Destination:Net");scanf("%d",&d1[i]);printf("Enter the HopCount:");scanf("%d",&h[i]);}
printf("Message from %c",nn);for(i=0;i<m;i++){printf("\nNet%d\t%d",d1[i],h[i]);}for(i=0;i<m;i++){h[i]=h[i]+1;}printf("\nMessage from %c after increment",nn);for(i=0;i<m;i++){printf("\n%d\t%d",d1[i],h[i]);}flag=0;for(i=0;i<n;i++){for(j=0;j<m;j++){if(d[i]==d1[j]){flag=1;k=j;}}if(flag==1)
printf("\nNew routing Table\n");printf("destination\thopcount\trouter\n");for(i=0;i<n;i++){printf("\nNet%d\t\t%d\t\t%c",d[i],hc[i],r[0][i]);}printf("\nDo u want to send message from another router");scanf("%d",&ch);}while(ch!=0);}
OUTPUT
Enter the number in routing table3
Enter the Destination:Net10
Enter the Hop Count:1
Enter the Next Router:a
Enter the Destination:Net11
Enter the Hop Count:2
Enter the Next Router:b
Enter the Destination:Net12
Enter the Hop Count:3
Enter the Next Router:c
Old routing Table
destination hopcount router
42
Net10 1 aNet11 2 bNet12 3 c
Enter the Router Name a
Enter the number in message table
2
Enter the Destination:Net11
Enter the HopCount:3
Enter the Destination:Net12
Enter the HopCount:3
Message from a
Net11 3
Net12 3
Message from a after increment
11 4
12 4
New routing Table
destination hopcount router
et10 1 aNet11 2Net12 0 a
43
Do u want to send message from another router0
RESULT
Thus the program to find the shortest path using DSDV routing protocol was executed and output was verified.
EX.NO:- 8 PERFORMANCE COMPARISION OF MAC PROTOCOLS
AIM: To compare the performance of MAC protocols
ALGORTHIM:-
Step1: create a new simulatorStep2: open the network animator file which is the namfile outmanStep3:set the agent trace and the router trace in the ON state and then get the MAC trace as OFF state.Step4: Construct four nodes namely n0,n1,n2 and n3 and the color for trandfering the packets is set as green and red.Step5:The delay time for each nodes and the node agent for each nodes are set.Step6:The droptail queues are used to transfer the packets by capturing them in a queue as specified.
$cbr set packet_size_1000$cbr set rate_1mb$cbr set random_false$ns at 0.1 “$cbr start”$ns at 1.0 “$ftp start”$ns at 4.0 “$ftp stopt”$ns at 4.5 “$cbr stop”$ns at 4.5 “$ns detach-agent $n0 $tcp;$nsdetach-agent $n3 $sink”$ns at 5.0 “finish”Puts “CBR packet size=[$cbr set packet_size_]”Puts “CBR interval=[$cbr set interval_]”$ns run
RESULT :
Thus the program for comparision of MAC protocols using NS-2 simulators has been executed successfully.
EX.NO:- 9 PERFORMANCE COMPARISION OF ROUTING PROTOCOLS
AIM: To compare the performance of Routing protocols
PROGRAM:-
AODV
Set val(mn) 10 ; # number of mobilenodesSer val(rp) AODV ;#routing protocolSet Val(x) 800Set Val(y) 800