CS9216       NETWORKING LAB(C/C++)LIST OF EXPERIMENTS1. Socket Programming      a. TCP Sockets     b. UDP Sockets     c. A...
HARDWARE REQUIREMENTSProcessor      :Pentium IVHard disk      :20 GBRAM            :256 MBMonitor        :VGA and high res...
Ex.no:1              CLIENT-SERVER CHAT PROGRAMDate:                               USING TCPAIM   To write a C program for...
CLIENT SERVER CHAT USING TCP                                     SERVER#include<stdio.h>#include<sys/types.h>#include<neti...
send(nsd,sendmsg,20,0);    wait(20);    }while(strcmp(sendmsg,"bye")!=0);}                                      CLIENT#inc...
OUTPUT:Client Side[1me16@localhost ~]$ cc tcpclient.c[1me16@localhost ~]$. /a.outEnter the port6523Socket is Created…Conne...
Ex.no:2          CLIENT-SERVER CHAT USING UDPDate:AIM  To write a C program for implementing chat program using UDP.ALGORI...
CLIENT SERVER CHAT USING UDP                                    SERVER#include<stdio.h>#include<sys/types.h>#include<sys/s...
CLIENT#include<stdio.h>#include<sys/socket.h>#include<sys/types.h>#include<netinet/in.h>main(){struct sockaddr_in sadd,cad...
OUTPUT:Client Side[1me16@localhost ~]$ cc udpclient.c[1me16@localhost ~]$. /a.outSocket is Created…Enter the IP Address172...
Ex. No. 3a             PRINTING THE CLIENT ADDRESSDate:                          AT THE SERVER ENDAIM   To write a C progr...
PRINTING THE CLIENT ADDRESS AT THE SERVER END                                     SERVER#include<stdio.h>#include<sys/sock...
CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],revmsg[20];str...
OUTPUT:Client Side[1me16@localhost ~]$ cc addressclient.c[1me16@localhost ~]$. /a.outEnter the port:6543Socket is Created....
Ex.no: 3b                            DATE-TIME SERVERDate:AIM        To write a C program for implementing the simple TCP ...
DISPLAYING TIME AT THE CLIENT END                                    SERVER#include<stdio.h>#include<sys/types.h>#include<...
CLIENT#include<stdio.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>#include<stdlib.h>#include<time.h>...
OUTPUT:Client Side[1me16@localhost ~]$ cc dateclient.c[1me16@localhost ~]$. /a.outEnter the port:8543Socket is Created...C...
Ex.no:3c               FILE TRANSFER USING TCPDate:AIM:       To write a C program for transferring a file using TCP.ALGOR...
FILE TRANSFER PROTOCOL                                USING TCP                                    SERVER#include<stdio.h>...
send(newsd,"error",5,0); close(newsd);}else{ while(fgets(fileread,sizeof(fileread),fp)) {  if(send(newsd,fileread,sizeof(f...
servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(cport);if(connect(csd,(stru...
OUTPUT:Server Side[1me16@localhost ~]$ cc ftpclient.c[1me16@localhost ~]$. /a.outEnter the port address:8663Socket is Crea...
EX.NO:4              SIMULATION OF SLIDING WINDOW                       PROTOCOLDATE:AIM   To write a C program for the si...
SLIDING WINDOW PROTOCOL                                      SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/...
CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){int i,sd,n,port;char sendmsg[10...
OUTPUT:Server:[1me16alhost~]: VI swserver.c[1me16alhost~]: CC swserver.c[1me16alhost~]: /a.outEnter the port address8543So...
EX.NO:5                        DOMAIN NAME SYSTEMDATE:AIM       To write a C program for the simulation of Domain Name Sys...
DOMAIN NAME SYSTEM                                    SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#i...
CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],recvmsg[20];st...
OUTPUT:Server:[1me16alhost~]: VI dnsserver.c[1me16alhost~]: CC dnsserver.c[1me16alhost~]: /a.outEnter the port no8543Socke...
EX.NO:6                 SIMULATION OF ROUTING PROTOCOLSDATE:AIM        To Simulate Shortest Path Routing AlgorithmALGORITH...
SIMULATION OF OSPF ROUTING PROTOCOL#include<iostream.h>#include<conio.h>class dij{private:int graph[15][15],source,no;int ...
}void dij::algorithm(){ initialize(); int count=0,i,u; while(count<no) {  u=minimum();  set[++count]=u;  mark[u]=1;  for(i...
for(int i=1;i<=no;i++){printpath(i);if(pathestimate[i]!=999)cout<<"->("<<pathestimate[i]<<")n"; } cout<<endl; }int dij::mi...
OUTPUTEnter the no of vertices: 3Enter the Adjacent matricesEnter the weight for row: 1013Enter the weight for row: 2211En...
EX.NO:6b               UNIFORM RESOURCE LOCATOR (URL)DATE:AIM       To retrieve the data using Uniform Resource LocatorsAL...
UNIFORM RESOURCE LOCATOR#include<iostream.h>#include<stdio.h>#include<dos.h>#include<conio.h>#include<string.h>void main()...
OUTPUT:CONTENT TYPE=text/htmlDate:03-11-2010 time:15:13:28<html><head><title>welcome</title><body bgcolor=”blue”><h1>welco...
Ex.No:8                MULTICLIENT-SERVER CHATDate:AIM:       To write a C program for implementing Client-Server Chat usi...
MULTI USER CHAT                                   SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#inclu...
{                              recv(nsd,rcvmsg,20,0);                              printf("%s",rcvmsg);                   ...
recv(csd,revmsg,20,0);              printf("%s",revmsg);       }       while(strcmp(revmsg,"bye")!=0);}CLIENT - 2#include<...
OUTPUT:SERVER SIDE:[1me2@localhost ~]$ vi Multiuserserver.c[1me2@localhost ~]$ cc Multiuserserverc[1me2@localhost ~]$ ./a....
CLIENT SIDE –2:[1me2@localhost ~]$ vi multiuserclient2.c[1me2@localhost ~]$ cc multiuserclient2.c[1me2@localhost ~]$ ./a.o...
Ex. No:9               SIMULATION OF SIMPLE NETWORKDate:                      MANAGEMENT PROTOCOLSAIM:       To write a C ...
SIMPLE NETWORK MANAGEMENT PROTOCOLAGENT1#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main...
if(strcmp(recvmsg,oid[i])==0)                        {                                send(nsd,wsize[i],100,0);           ...
if(nsd<0)                printf("Cant Acceptn");         else                printf("Acceptedn");                 recv(nsd...
printf("n 1.TCP Connectionn");           printf("n 2. System n");           printf("Enter the number for the type of infor...
OUTPUT:AGENT1:[1me14@localhost ~]$ vi Agent1.c[1me14@localhost ~]$ cc Agent1.c[1me14@localhost ~]$ ./a.outIm the Agent - T...
MANGER:[1me14@localhost ~]$ vi Manager.c[1me14@localhost ~]$ cc Manger.c[1me14@localhost ~]$ ./a.outEnter the port8543Sock...
EMAIL#include <stdlib.h>#include <string.h>#define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}#define cknltz...
OUTPUT:[1me2@localhost ~]$ vi email.c[1me2@localhost ~]$ cc email.c[1me2@localhost ~]$ ./a.outEnter the file name: sample....
STUDY OF NETWORK SIMULATOR PACKAGESEx. No:                        STUDY OF NS2Date:AIM:       To study about NS2 - Network...
Figure 1. Simplified Users View of NS        As shown in Figure 1, in a simplified users view, NS is Object-oriented Tcl(O...
reduce packet and event processing time (not simulation time), the event scheduler andthe basic network component objects ...
As shown in Figure 1, when a simulation is finished, NS produces one or moretext-based output files that contain detailed ...
The following is the explanation of the script above. In general, an NS script startswith making a Simulator object instan...
2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl" files. One thing to note is that       you can insert error modules...
traffic source does not transmit actual data, but it notifies the underlying agent       that it has some amount of data t...
a classifier that classify multicast packets from unicast packets and a multicast classifierthat performs multicast routin...
Figure 8. Link        One thing to note is that an output queue of a node is actually implemented as apart of simplex link...
Figure 10. Monitoring Queue        When a packet arrives, a snoop queue object notifies the queue monitor object ofthis ev...
header format is initialized when a Simulator object is created, where a stack of allregistered (or possibly useable) head...
Ex. No.                       STUDY OF OPNETDate:AIM:       To study about OPNET - Network SimulatorINTRODUCTION:         ...
The modeling libraries are included with OPNET Modeler and OPNET Plannerand contains protocols and analysis environments, ...
TERRAIN MODELING MODULE (TMM)        Building on the capabilities of OPNETs Wireless Module, the Terrain ModelingModule pr...
Upcoming SlideShare
Loading in...5
×

Networking lab

4,477

Published on

CSC

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,477
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
255
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Networking lab

  1. 1. CS9216 NETWORKING LAB(C/C++)LIST OF EXPERIMENTS1. Socket Programming a. TCP Sockets b. UDP Sockets c. Applications using Sockets2. Simulation of Sliding Window Protocol3. Simulation of Routing Protocols4. Development of applications such as DNS/ HTTP/ E – mail/ Multi - user Chat5. Simulation of Network Management Protocols6. Study of Network Simulator Packages – such as opnet, ns2, etc.
  2. 2. HARDWARE REQUIREMENTSProcessor :Pentium IVHard disk :20 GBRAM :256 MBMonitor :VGA and high resolution monitorSOFTWARE REQUIREMENTSOperating system :LINUXLanguage :C/C++
  3. 3. Ex.no:1 CLIENT-SERVER CHAT PROGRAMDate: USING TCPAIM To write a C program for implementing Client-Server Chat using TCP.ALGORITHMSERVERStep 1: Start the program.Step 2: Create an unnamed socket for the server using the parameters AF_INET as domain and the SOCK_STREAM as type.Step 3: Name the socket using bind( ) system call with the parameters server_sockfd and the server address(sin_addr and sin_sport).Step 4: Create a connection queue and wait for clients using the listen( ) system call with the number of clients request as parameters.Step 5: Accept the connection using accept( ) system call when client requests for connection.Step 6: Get the message which has to be sent to the client and check that it is not equal to ‘Bye’.Step 7: If the message is not equal to ‘Bye’ then write the message to the client and Goto step 6.Step 8: If the message is ‘Bye’ then terminate the Process.Step 9: Stop the program execution.CLIENTStep 1: Start the program.Step 2: Create an unnamed socket for client using socket( ) system.Step 3: Call with parameters AF_INET as domain and SOCK_STREAM as type.Step 4: Name the socket using bind( ) system call.Step 5: Now connect the socket to server using connect( ) system call.Step 6: Read the message from the server socket and compare it with ‘Bye’.Step 7: If the message is not equal to ‘Bye’ then print the message to the server output device and repeat the steps 6 & 7.Step 8: Get the message from the client side.Step 9: Write the message to server sockfd and goto step 4.Step 10:If the message is equal to ‘Bye’then print good bye message and terminate the process.Step 11:Stop the process.
  4. 4. CLIENT SERVER CHAT USING TCP SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){int sd,sd2,nsd,clilen,sport,len;char sendmsg[20],rcvmsg[20];struct sockaddr_in servaddr,cliaddr;printf("Enter the Server port");printf("n_____________________n");scanf("%d",&sport);sd=socket(AF_INET,SOCK_STREAM,0);if(sd<0) printf("Cant Create n");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(sport);sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr));if(sd2<0) printf(" Cant Bindn");else printf("n Bindedn");listen(sd,5);clilen=sizeof(cliaddr);nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);if(nsd<0) printf("Cant Acceptn");else printf("Acceptedn"); printf("nReceived Messagesn");do { recv(nsd,rcvmsg,20,0); printf("%s",rcvmsg); fgets(sendmsg,20,stdin); len=strlen(sendmsg); sendmsg[len-1]=0;
  5. 5. send(nsd,sendmsg,20,0); wait(20); }while(strcmp(sendmsg,"bye")!=0);} CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],revmsg[20];struct sockaddr_in servaddr;printf("Enter the portn");scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0) printf("Cant Createn");else printf("Scocket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn");else printf("Connectedn");do {fgets(sendmsg,20,stdin);len=strlen(sendmsg);sendmsg[len-1]=0;send(csd,sendmsg,20,0);wait(20);recv(csd,revmsg,20,0);printf("%s",revmsg);}while(strcmp(revmsg,"bye")!=0);}
  6. 6. OUTPUT:Client Side[1me16@localhost ~]$ cc tcpclient.c[1me16@localhost ~]$. /a.outEnter the port6523Socket is Created…Connected……HelloServer Side[1me16@localhost ~]$ cc tcpserver.c.c[1me16@localhost ~]$. /a.outEnter the server port…6543Socket is CreatedBindedAcceptedReceived Messages…. HelloRESULT Thus the C program for chat using TCP is executed and the output is verifiedsuccessfully
  7. 7. Ex.no:2 CLIENT-SERVER CHAT USING UDPDate:AIM To write a C program for implementing chat program using UDP.ALGORITHMSERVERStep 1: Start the program.Step 2: Create an unnamed socket for the server using the parameters AF_INET as domain and the SOCK_DGRAM as type.Step 3: Name the socket using bind( ) system call with the parameters server_sockfd and the server address(sin_addr and sin_sport).Step 4: The server gets the message from the client.Step 5: Prints the message.Step 6: Stop the program execution.CLIENTStep 1: Start the program.Step 2: Create an unnamed socket for client using socketStep 3: Call with parameters AF_INET as domain an SOCK_DGRAM as type.Step 4: Name the socket using bind( ) system call.Step 5: The Sendto( ) system call is used to deliver the Message to the server.Step 6: Stop the program execution.
  8. 8. CLIENT SERVER CHAT USING UDP SERVER#include<stdio.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>main(){struct sockaddr_in sadd,cadd;int id,a,b,len,port;char rbuff[100];id=socket(PF_INET,SOCK_DGRAM,0);if(id<0) printf("Cant Createn");else printf("Createdn");printf("Enter the port Addressn");printf("____________________n");scanf("%d",&port);sadd.sin_family=PF_INET;sadd.sin_addr.s_addr=htonl(INADDR_ANY);sadd.sin_port=htons(port);b=bind(id,(struct sockaddr*)&sadd,sizeof(sadd));if(b<0) printf("Cant Bind");else printf("Bindedn"); printf("~~~~~~n");len=sizeof(cadd);if(recvfrom(id,rbuff,sizeof(rbuff),0,(struct sockaddr*)&cadd,&len)<0) printf("Received Errorn");else printf("Server received =%sn",rbuff);close(id);}
  9. 9. CLIENT#include<stdio.h>#include<sys/socket.h>#include<sys/types.h>#include<netinet/in.h>main(){struct sockaddr_in sadd,cadd;int id,len,n,c,s,b,port;char str[100],serstr[100];id=socket(PF_INET,SOCK_DGRAM,0);if(id<0) printf("Cant Createn");else printf("Socket is Createdn");printf("Enter the IP addressn");scanf("%s",serstr);printf("Enter the port Addressn");scanf("%d",&port);cadd.sin_family=PF_INET;cadd.sin_addr.s_addr=inet_addr(serstr);cadd.sin_port=htons(port);printf("Enter the Datan");scanf("%s",str);b=bind(id,(struct sockaddr*)&cadd,sizeof(cadd));if(sendto(id,str,sizeof(str),0,(struct sockaddr*)&cadd,sizeof(cadd))<0) printf("Transmit Error");else printf("Server Transmitted=%sn",str);close(id);}
  10. 10. OUTPUT:Client Side[1me16@localhost ~]$ cc udpclient.c[1me16@localhost ~]$. /a.outSocket is Created…Enter the IP Address172.15.170.104Enter the port address6543Enter the dataHelloServer transmitted = helloServer Side[1me16@localhost ~]$ cc udpserver.c[1me16@localhost ~]$. /a.outCreatedEnter the port address………….6543Binded…………….RESULT Thus the C program for chat using UDP is executed and the output is verifiedsuccessfully.
  11. 11. Ex. No. 3a PRINTING THE CLIENT ADDRESSDate: AT THE SERVER ENDAIM To write a C program for printing the client address at the server end.ALGORITHMSERVERStep 1: Start the program.Step 2: Create an unnamed socket for the server using the parameters AF_INET as domain and the SOCK_STREAM as type.Step 3: Name the socket using bind( ) system call with the parameters server_sockfd and the server address(sin_addr and sin_sport).Step 4: Create a connection queue and wait for clients using the listen( ) system call with the number of clients request as parameters.Step 5: Accept the connection using accept( ) system call when client requests for connection.Step 6: If the descriptor is less than zero,then the connection is not established and the stop the process.Step 7: Print the IP address sent by the client to the server.Step 8: Stop the program execution.CLIENTStep 1: Start the program.Step 2: Create an unnamed socket for client using socket( ) system.Step 3: Call with parameters AF_INET as domain and SOCK_STREAM as type.Step 4: Name the socket using bind( ) system call.Step 5: Now connect the socket to server using connect( ) system call.Step 6: If the descriptor is less than zero, then the connection is not established.Step 7: If there is no connection,then terminate the process.Step 8: Else send the IP address to the server.Step 9: Stop the process.
  12. 12. PRINTING THE CLIENT ADDRESS AT THE SERVER END SERVER#include<stdio.h>#include<sys/socket.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){ int sd,sd2,nsd,clilen,sport,len; char sendmsg[20],rcvmsg[20]; struct sockaddr_in servaddr,cliaddr; printf("Enter the Portn"); scanf("%d",&sport); sd=socket(AF_INET,SOCK_STREAM,0); if(sd<0)printf("Cant Create n"); elseprintf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=inet_addr("172.15.170.104"); servaddr.sin_port=htons(sport); sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr)); if(sd2<0)printf(" Cant Bindn"); elseprintf("n Bindedn");listen(sd,5); clilen=sizeof(cliaddr); nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen); if(nsd<0)printf("Cant Acceptn"); elseprintf("Acceptedn"); printf("The Client Address is %s",inet_ntoa(cliaddr.sin_addr.s_addr));}
  13. 13. CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],revmsg[20];struct sockaddr_in servaddr;printf("Enter the portn");scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0) printf("Cant Createn");else printf("Scocket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=inet_addr("172.15.170.104");servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn");else printf("Connectedn");}
  14. 14. OUTPUT:Client Side[1me16@localhost ~]$ cc addressclient.c[1me16@localhost ~]$. /a.outEnter the port:6543Socket is Created...Server Side[1me16@localhost ~]$ cc addressserver.c[1me16@localhost ~]$. /a.outEnter the port:6543Created...Binded……RESULT Thus the C program for printing the client IP Address at the server end is executedand the output is verified successfully.
  15. 15. Ex.no: 3b DATE-TIME SERVERDate:AIM To write a C program for implementing the simple TCP client-server where theserver acts as a Date-Time server.ALGORITHMSERVERStep 1 :Start the programStep 2 :Create an unnamed socket for the server using parameters AF_INET as domain and SOCK_STREAM as type.Step 3 : Declare the time variables t.Step 4 :Get the server port number.Step 5 :Register the host address to the system by using bind() system call in server side.Step 6 :Create a connection queue and wait for clients using listen() system call with The number of clients requests as parameter.Step 7 :Accept the connection using accept( ) system call when the client request for connection.Step 8 :Stop the Program execution.CLIENTStep 1 :Start the program.Step 2 :Create an unnamed socket for the client using parameters AF_INET as domain and SOCK_STREAM as type.Step 3 :Get the client port number.Step 4 :Now connect the socket to server using connect( ) system call.Step 5 :The recv() system call gets the response of Date-Time request from the server.Step 6 :Print the date and timeStep 7 :Stop the program.
  16. 16. DISPLAYING TIME AT THE CLIENT END SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>#include<time.h>main(){int sd,sd2,nsd,clilen,sport,len;char sendmsg[20],rcvmsg[20];time_t t;struct sockaddr_in servaddr,cliaddr;printf("Enter the Port non");scanf("%d",&sport);sd=socket(AF_INET,SOCK_STREAM,0);time(&t);strcpy(sendmsg,ctime(&t));printf("%s",sendmsg);if(sd<0) printf("Cant Create n");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(sport);sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr));if(sd2<0) printf(" Cant Bindn");else printf("n Binded n");listen(sd,5);clilen=sizeof(cliaddr);nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);if(nsd<0) printf("Cant Acceptn");else printf("Acceptedn");send(nsd,sendmsg,100,0);}
  17. 17. CLIENT#include<stdio.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>#include<stdlib.h>#include<time.h>main(){int csd,cport,len;char revmsg[100];struct sockaddr_in servaddr;printf("Enter the portn");scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0) printf("Cant Createn");else printf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Connection errorn");recv(csd,revmsg,100,0);printf("%sn",revmsg);}
  18. 18. OUTPUT:Client Side[1me16@localhost ~]$ cc dateclient.c[1me16@localhost ~]$. /a.outEnter the port:8543Socket is Created...Connected…Server Side[1me16@localhost ~]$ cc dateserver.c[1me16@localhost ~]$. /a.outEnter the port:8543Fri Sep 17 03:05:27 2010Socket is Created...RESULT Thus the C program for printing Date and time is executed and the output is verifiedsuccessfully.
  19. 19. Ex.no:3c FILE TRANSFER USING TCPDate:AIM: To write a C program for transferring a file using TCP.ALGORITHM:SERVER:Step 1:Start the program.Step 2:Create an unnamed socket for the server using parameters AF_INET as domain and SOCK_STREAM as type.Step 3:Get the server port number.Step 4:Register the host address to the system by using bind() system call in server side.Step 5:Create a connection queue and wait for clients using listen() system call with the number of clients requests as parameter.Step 6:Create a Child process using fork( ) system call.Step 7:If the process identification number is equal to zero accept the connection using accept( ) system call when the client request for connection.Step 8:If pid is not equal to zero then exit the process.Step 9:Stop the Program execution.CLIENT:Step 1:Start the program.Step 2:Create an unnamed socket for the client using parameters AF_INET as domain and SOCK_STREAM as type.Step 3:Get the client port number.Step 4:Now connect the socket to server using connect( ) system call.Step 5:Enter the file name.Step 6:The file is transferred from client to server using send ( ) function.Step 7:Print the contents of the file in a new file.Step 8:Stop the program.
  20. 20. FILE TRANSFER PROTOCOL USING TCP SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){FILE *fp;int sd,newsd,ser,n,a,cli,pid,bd,port,clilen;char name[100],fileread[100],fname[100],ch,file[100],rcv[100];struct sockaddr_in servaddr,cliaddr;printf("Enter the port address: "); scanf("%d",&port);sd=socket(AF_INET,SOCK_STREAM,0);if(sd<0) printf("Cant Create n");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(port);a=sizeof(servaddr);bd=bind(sd,(struct sockaddr*)&servaddr,a);if(bd<0) printf(" Cant Bindn");else printf("n Bindedn");listen(sd,5);clilen=sizeof(cliaddr);newsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);if(newsd<0) printf("Cant Acceptn");else printf("Acceptedn");n=recv(newsd,rcv,100,0);rcv[n]=0;fp=fopen(rcv,"r");if(fp==NULL) {
  21. 21. send(newsd,"error",5,0); close(newsd);}else{ while(fgets(fileread,sizeof(fileread),fp)) { if(send(newsd,fileread,sizeof(fileread),0)<0) { printf("Cant sendn"); } sleep(1); } if(!fgets(fileread,sizeof(fileread),fp)) { send(newsd,"completed",999999999,0); }return(0);}}CLIENT#include<stdio.h>#include<sys/socket.h>#include<netinet/in.h>main(){FILE *fp;int csd,n,ser,s,cli,cport,newsd;char name[100],rcvmsg[100],rcvg[100],fname[100];struct sockaddr_in servaddr;printf("Enter the port"); scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0){printf("Error...");exit(0);}elseprintf("Socket is Created...n");
  22. 22. servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0)printf("Error in Connection...n");elseprintf("Connected...n");printf("Enter the existing file name: "); scanf("%s",name);printf("nEnter the new filename: "); scanf("%s",fname);fp=fopen(fname,"w");send(csd,name,sizeof(name),0);while(1){ s=recv(csd,rcvg,100,0); rcvg[s]=0; if(strcmp(rcvg,"error")==0) printf("File is not Available...n"); if(strcmp(rcvg,"completed")==0) { printf("file is transferred...n"); fclose(fp); close(csd); break; }elsefputs(rcvg,stdout);fprintf(fp,"%s",rcvg);}}
  23. 23. OUTPUT:Server Side[1me16@localhost ~]$ cc ftpclient.c[1me16@localhost ~]$. /a.outEnter the port address:8663Socket is CreatedBindedConnected…Client Side[1me16@localhost ~]$ cc ftpserver.c[1me16@localhost ~]$. /a.outSocket is Created..ConnectedEnter the existing file name: netEnter the new file name: networkWelcome to Network LabFile is transferred...RESULT Thus the C program for transferring file from one machine to another machineusing TCP is executed and the output is verified successfully.
  24. 24. EX.NO:4 SIMULATION OF SLIDING WINDOW PROTOCOLDATE:AIM To write a C program for the simulation of Sliding Window Protocol.ALGORITHMSENDERStep 1: Start the program.Step 2: Create a Socket for the Sender and bind it with the receiver.Step 3: Set the size of the window.Step 4: Send the frames upto the size of the window to the receiverStep 5: If any of the frames are lost then retransmit those frames to the receiverStep 6: Stop the execution.RECEIVERStep 1: Start the program.Step 2: Create the Socket for the Receiver, bind it and listen for the frames from thesender.Step 3: If all the frames are successfully received, send the acknowledgement for the lastframe to the sender.Step 4: If any of the frames is lost, then send the acknowledgement of the last frame,which was successfully received.Step 5: Keep on receiving and acknowledging the frames until the sender sends.Step 6: Stop the program execution.
  25. 25. SLIDING WINDOW PROTOCOL SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>#include<sys/socket.h>main(){int a,bd,sd,newsd,port,clilen;char lost[20],sendmsg[20],recvmsg[20];struct sockaddr_in servaddr,cliaddr;sd=socket(AF_INET,SOCK_STREAM,0);if(sd<0) printf("Cant Create n");else printf("Socket is Createdn");printf("Enter the port non");scanf("%d",&port);servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(port);a=sizeof(servaddr);bd=bind(sd,(struct sockaddr*)&servaddr,a);if(bd<0) printf(" Cant Bindn");else printf("n Bindedn");listen(sd,5);clilen=sizeof(cliaddr);newsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);if(newsd<0) printf("Cant Acceptn");else printf("Acceptedn");printf("Enter the lost framen");scanf("%s",lost);send(newsd,lost,20,0);recv(newsd,recvmsg,20,0);printf("n Frame %s is successfully received",recvmsg);}
  26. 26. CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){int i,sd,n,port;char sendmsg[100],recvmsg[100];struct sockaddr_in servaddr;printf("Enter the portn");scanf("%d",&port);sd=socket(AF_INET,SOCK_STREAM,0);if(sd<0) printf("Cant Createn");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(port);if(connect(sd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn");else printf("Connectedn");printf("Enter the no of framesn");scanf("%d",&n);printf("nThe frames alln");for(i=1;i<=n;i++)printf("Frame %dn",i);recv(sd,recvmsg,20,0);printf("n Lost frame %s is retransmitted ",recvmsg);strcpy(sendmsg,recvmsg);send(sd,sendmsg,20,0);}
  27. 27. OUTPUT:Server:[1me16alhost~]: VI swserver.c[1me16alhost~]: CC swserver.c[1me16alhost~]: /a.outEnter the port address8543Socket is createdBindedAcceptedEnter the lost frame: 3Frame tcpserver.c is successfully transmittedClient:[1me16alhost~]: VI swclient.c[1me16alhost~]: CC swclient.c[1me16alhost~]: /a.outEnter the client port no8543Socket is createdConnected…………..Enter the no of frames: 4The frames allFrame 1/n Frame 2/n Frame 3/n Frame 4/nRESULT Thus the C program for the simulation of Sliding Window Protocol has beenexecuted and the output is verified successfully.
  28. 28. EX.NO:5 DOMAIN NAME SYSTEMDATE:AIM To write a C program for the simulation of Domain Name SystemALGORITHMSERVERStep 1: Start the program.Step 2: Create the Socket for the Server.Step 3: Bind the Socket to the Port.Step 4: Listen for the incoming client connection.Step 5: Receive the IP address from the client to be resolved.Step 6: Get the domain name from the client.Step 7: Check the existence of the domain in the server.Step 8: If domain matches then send the corresponding address to the client.Step 9: Stop the program execution.CLIENTStep 1: Start the program.Step 2: Create the Socket for the client.Step 3: Connect the Socket to the server.Step 4: Send the hostname to the server to be resolved.Step 5: If the server responds the print the address and terminates the process.
  29. 29. DOMAIN NAME SYSTEM SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){int sd,sd2,nsd,clilen,sport,len,i;char sendmsg[20],recvmsg[20];char ipid[20][20]={"172.15.64.66","172.15.44.55","172.15.33.44","172.15.22.33"};char hostid[20][20]={"www.yahoo.com","www.google.com","www.hotmail.com"};struct sockaddr_in servaddr,cliaddr;printf("DNS Server Siden");printf("Enter the Portn");scanf("%d",&sport);sd=socket(AF_INET,SOCK_STREAM,0);if(sd<0) printf("Cant Create n");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(sport);sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr));if(sd2<0) printf("Cant Bindn");else printf("n Bindedn");listen(sd,5);clilen=sizeof(cliaddr);nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);if(nsd<0) printf("Cant Acceptn");else printf("Acceptedn");recv(nsd,recvmsg,20,0);for(i=0;i<4;i++){ if(strcmp(recvmsg,hostid[i])==0) { send(nsd,ipid[i],20,20); break; }}}
  30. 30. CLIENT#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],recvmsg[20];struct sockaddr_in servaddr;printf("DNS Client Siden");printf("Enter the Client portn");scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0) printf("Cant Createn");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn");else printf("Connectedn");printf("Enter the host addressn");scanf("%s",sendmsg);send(csd,sendmsg,20,0);recv(csd,recvmsg,20,20);printf("The Coresponding IP Address isn");printf("%s",recvmsg);}
  31. 31. OUTPUT:Server:[1me16alhost~]: VI dnsserver.c[1me16alhost~]: CC dnsserver.c[1me16alhost~]: /a.outEnter the port no8543Socket is createdBindedAcceptedClient:[1me16alhost~]: VI dnsclient.c[1me16alhost~]: CC dnsclient.c[1me16alhost~]: /a.outEnter the client port no8543Socket is createdConnected…………..Enter the host addresswww.yahoo.comThe corresponding IP Address is172.15.64.66RESULT Thus the C program for the simulation of Domain Name System has been executedand the output is verified successfully.
  32. 32. EX.NO:6 SIMULATION OF ROUTING PROTOCOLSDATE:AIM To Simulate Shortest Path Routing AlgorithmALGORITHMStep 1: Start the ProgramStep 2: Create a distance list, a previous vertex list, a visited list, and a current vertex.Step 3: All the values in the distance list are set to infinity except the starting vertexwhich is set to zero.Step 4: All values in visited list are set to false.Step 5: All values in the previous list are set to a special value signifying that they areundefined.Step 6: Current node is set as the starting vertex.Step 7: Mark the current vertex as visited.Step 8: Update distance and previous lists based on those vertices which can beimmediately reached from the current vertex.Step 9: Update the current vertex to the unvisited vertex that can be reached by theshortest path from the starting vertex.Step 10: Repeat (from step 6) until all nodes are visited.Step 11: Stop the program execution.
  33. 33. SIMULATION OF OSPF ROUTING PROTOCOL#include<iostream.h>#include<conio.h>class dij{private:int graph[15][15],source,no;int set[15],predessor[15],mark[15],pathestimate[15];public:int minimum();void read();void initialize();void printpath(int);void algorithm();void output();};void dij::read(){cout<<"Enter the no of vertices: "; cin>>no;cout<<"Enter the Adjacent matrices"; for(int i=1;i<=no;i++) { cout<<"Enter the weight for row: "<<i; for(int j=1;j<=no;j++) { cin>>graph[i][j]; } }cout<<"Enter the source Vector: ";cin>>source;}void dij::initialize(){for(int i=1;i<=no;i++) { mark[i]=0; pathestimate[i]=999; predessor[i]=0; }pathestimate[source]=0;
  34. 34. }void dij::algorithm(){ initialize(); int count=0,i,u; while(count<no) { u=minimum(); set[++count]=u; mark[u]=1; for(int i=1;i<=no;i++) { if(graph[u][i]>0) { if(mark[i]!=1) { if(pathestimate[i]>pathestimate[u]+graph[u][i]) { predessor[i]=u; pathestimate[i]=pathestimate[u]+graph[u][i]; } } } } //for loop } //while loop}void dij::printpath(int i){cout<<endl;if(i==source){cout<<source;}else if(predessor[i]==0)cout<<"No path from"<<source<<"to"<<i;else{printpath(predessor[i]);cout<<"....."<<i;}}void dij::output(){
  35. 35. for(int i=1;i<=no;i++){printpath(i);if(pathestimate[i]!=999)cout<<"->("<<pathestimate[i]<<")n"; } cout<<endl; }int dij::minimum() { int min=999,i,t;for(i=1;i<=no;i++) { if(mark[i]!=1) { if(min>=pathestimate[i]) { min = pathestimate[i]; t=i; } } }return t;}void main(){ clrscr(); dij d; d.read(); d.algorithm(); d.output(); getch();}
  36. 36. OUTPUTEnter the no of vertices: 3Enter the Adjacent matricesEnter the weight for row: 1013Enter the weight for row: 2211Enter the weight for row: 3211Enter the source vector: 11 -> (0)1……. 2- > (1)1…… 2 ……. 3 -> (1)RESULT: Thus the Program for simulating Shortest Path Routing Algorithm is executedand the output is verified successfully.
  37. 37. EX.NO:6b UNIFORM RESOURCE LOCATOR (URL)DATE:AIM To retrieve the data using Uniform Resource LocatorsALGORITHMStep 1: Start the Program.Step 2: Create an object for the URL class.Step 3: Specify the address from which the data is to be retrieved inside the URL classStep 4: Open the URL connectionStep 5: Request the content Length, modified date etc. using appropriate the methods.Step 6: Display the contents to the userStep 7: Stop the program
  38. 38. UNIFORM RESOURCE LOCATOR#include<iostream.h>#include<stdio.h>#include<dos.h>#include<conio.h>#include<string.h>void main(){char c;int len=0;struct date d;struct time t;clrscr();FILE *fp;getdate(&d);gettime(&t);fp=fopen("welcome.html","r");printf("Content type = text/htmln");printf("n Date : %d-%d-%d Time : %d:%d:%dn",d.da_day,d.da_mon,d.da_year,t.ti_hour,t.ti_min,t.ti_sec);c=fgetc(fp);cout<<c;len++;while((c=fgetc(fp))!=-1){ if(c!=n|| ); len++; cout<<c;} printf("n Content length is %d",len); getch();}
  39. 39. OUTPUT:CONTENT TYPE=text/htmlDate:03-11-2010 time:15:13:28<html><head><title>welcome</title><body bgcolor=”blue”><h1>welcome to network lab-1</h></body></html>content length is 109RESULT Thus the program for retrieving the data using URL is executed and the output isverified successfully.
  40. 40. Ex.No:8 MULTICLIENT-SERVER CHATDate:AIM: To write a C program for implementing Client-Server Chat using TCP.ALGORITHM:SERVER:Step 1: Start the program.Step 2: Create an unnamed socket for the server using the parameters AF_INET asdomain and the SOCK_STREAM as type.Step 3: Name the socket using bind ( ) system call with the parameters server_sockfd andthe server address (sin_addr and sin_sport).Step 4: Create a connection queue and wait for clients using the listen( ) system call withthe number of clients request as parameters.Step 5: Get the client‟s id as input from the user to communicate. If the client‟s id is 0then go to step 10 otherwise go to step 6.Step 6: Accept the connection using accept ( ) system call when client requests forconnection.Step 7: Get the message which has to be sent to the client and check that it is not equal to„Bye‟.Step 8: If the message is not equal to „Bye‟ then write the message to the client and Gotostep 6.Step 9: If the message is „Bye‟ then terminates the connection with current client and Gotostep 5.Step 10: Stop the program execution.CLIENT:Step 1: Start the program.Step 2: Create an unnamed socket for client using socket ( ) system.Step 3: Call with parameters AF_INET as domain and SOCK_STREAM as type.Step 4: Name the socket using bind( ) system call.Step 5: Now connect the socket to server using connect ( ) system call.Step 6: Read the message from the server socket and compare it with „Bye‟.Step 7: If the message is not equal to „Bye‟ then print the message to the server outputdevice and repeat the steps 6 & 7.Step 8: Get the message from the client side.Step 9: Write the message to server sockfd and goto step 4.Step 10: If the message is equal to „Bye‟then print good bye message and terminate theprocess.Step 11: Stop the process.
  41. 41. MULTI USER CHAT SERVER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){ int i,sd,sd2,nsd,clilen,sport,len; char sendmsg[20],rcvmsg[20]; struct sockaddr_in servaddr,cliaddr; printf(“Enter the port no:n”); scanf("%d",&sport); sd=socket(AF_INET,SOCK_STREAM,0); if(sd<0) printf("Cant Create n"); else printf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(sport); sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr)); if(sd2<0) printf("Cant Bindn"); else printf("n Bindedn"); listen(sd,5); do { printf("Enter the client no to communicaten"); scanf("%d",&i); if(i==0) exit(0); printf("Client %d is connectedn",i); clilen=sizeof(cliaddr); nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen); if(nsd<0) printf("Cant Acceptn"); else printf("Acceptedn"); do
  42. 42. { recv(nsd,rcvmsg,20,0); printf("%s",rcvmsg); fgets(sendmsg,20,stdin); len=strlen(sendmsg); sendmsg[len-1]=0; send(nsd,sendmsg,20,0); wait(20); }while(strcmp(sendmsg,"bye")!=0); }while(i!=0);}CLIENT - 1#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){ int csd,cport,len; char sendmsg[20],revmsg[20]; struct sockaddr_in servaddr; printf("Enter the port no:n"); scanf("%d",&cport); csd=socket(AF_INET,SOCK_STREAM,0); if(csd<0) printf("Cant Createn"); else printf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(cport); if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn"); else printf("Connectedn"); do { fgets(sendmsg,20,stdin); len=strlen(sendmsg); sendmsg[len-1]=0; send(csd,sendmsg,20,0); wait(20);
  43. 43. recv(csd,revmsg,20,0); printf("%s",revmsg); } while(strcmp(revmsg,"bye")!=0);}CLIENT - 2#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){int csd,cport,len;char sendmsg[20],revmsg[20];struct sockaddr_in servaddr;printf("Enter the port no:n");scanf("%d",&cport);csd=socket(AF_INET,SOCK_STREAM,0);if(csd<0) printf("Cant Createn");else printf("Socket is Createdn");servaddr.sin_family=AF_INET;servaddr.sin_addr.s_addr=htonl(INADDR_ANY);servaddr.sin_port=htons(cport);if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn");else printf("Connectedn");do {fgets(sendmsg,20,stdin);len=strlen(sendmsg);sendmsg[len-1]=0;send(csd,sendmsg,20,0);wait(20);recv(csd,revmsg,20,0);printf("%s",revmsg);}while(strcmp(revmsg,"bye")!=0);}
  44. 44. OUTPUT:SERVER SIDE:[1me2@localhost ~]$ vi Multiuserserver.c[1me2@localhost ~]$ cc Multiuserserverc[1me2@localhost ~]$ ./a.outEnter the port no8543socket is createdBindedEnter the client to communicate: 1Client 1 is connectedAcceptedhiiiiiByeeeeeeEnter the client no to communicate: 2client 2 is connectedAcceptedhiiiiiiiiiihelloEnter the client no to communicate: 0CLIENT SIDE 1:[1me2@localhost ~]$ vi multiuserclient1.c[1me2@localhost ~]$ cc multiuserclient1.c[1me2@localhost ~]$ ./a.outEnter the port no8543Socket is createdConnectedhiiiiiiByeeeee
  45. 45. CLIENT SIDE –2:[1me2@localhost ~]$ vi multiuserclient2.c[1me2@localhost ~]$ cc multiuserclient2.c[1me2@localhost ~]$ ./a.outEnter the port no8543Socket is createdConnectedHiiiiiiiiihelloRESULT Thus the C program for chat multiclient-serve chat program using tcp has beenexecuted successfully.
  46. 46. Ex. No:9 SIMULATION OF SIMPLE NETWORKDate: MANAGEMENT PROTOCOLSAIM: To write a C program for simulation of Simple Network management Protocols.ALGORITHM:MANAGER:Step 1: Start the program.Step 2: Create an unnamed socket for client using socket ( ) system.Step 3: Call with parameters AF_INET as domain and SOCK_STREAM as type.Step 4: Name the socket using bind ( ) system call.Step 5: Now connect the socket to agent using connect ( ) system call.Step 6: Get the input for the type of information needed from the agent.Step 7: If the input is equal to „TCP connection‟ then goto next step else If it is equal to„system‟ Goto step 9.Step 8: Read the input for the object, send it and receive the details of the TCPconnection of that object from the agent. Go to step 10.Step 9: Read the input for the object, send it and receive the details of the system fromthe agent. Go to step 10.Step 10: Receive the message, print and terminate the process.Step 11: Stop the process.AGENTSStep 1: Start the program.Step 2: Create an unnamed socket for the server using the parameters AF_INET asdomain and the SOCK_STREAM as type.Step 3: Name the socket using bind( ) system call with the parameters server_sockfdand the manager address(sin_addr and sin_sport).Step 4: Create a connection queue and wait for manager using the listen ( ) system callwith the number of manager request as parameters.Step 5: Accept the connection using accept( ) system call when manager requests forconnection.Step 6: Receive the message from the manager. If the request is for „TCP connections‟then send the details of the requested object, else if the request is for „System‟ then sendthe details of the requested system.Step 7: Stop the program execution.
  47. 47. SIMPLE NETWORK MANAGEMENT PROTOCOLAGENT1#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){ int i,sd,sd2,nsd,clilen,sport,len; char sendmsg[20],recvmsg[100]; char oid[5][10]={"client1","client2","client3","cleint4","client5"}; char wsize[5][5]={"5","10","15","3","6"}; struct sockaddr_in servaddr,cliaddr; printf("Im the Agent - TCP Connectionn"); printf("nEnter the Server port"); printf("n_____________________n"); scanf("%d",&sport); sd=socket(AF_INET,SOCK_STREAM,0); if(sd<0) printf("Cant Create n"); else printf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(sport); sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr)); if(sd2<0) printf(" Cant Bindn"); else printf("n Bindedn"); listen(sd,5); clilen=sizeof(cliaddr); nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen); if(nsd<0) printf("Cant Acceptn"); else printf("Acceptedn"); recv(nsd,recvmsg,100,0); for (i=0;i<5;i++) {
  48. 48. if(strcmp(recvmsg,oid[i])==0) { send(nsd,wsize[i],100,0); break; } }}AGENT 2#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>#include<string.h>main(){ int i,sd,sd2,nsd,clilen,sport,len; char sendmsg[20],recvmsg[100]; char oid[5][10]={"System1","System2","System3","System4","System5"}; char mdate[5][15]={"1-10-095","10-03-08","14.03.81","11.07.07","17.12.77"}; char time[5][15]={"9am","10pm","11am","12.30pm","11.30am"}; struct sockaddr_in servaddr,cliaddr; printf("Enter the Server port"); printf("n_____________________n"); scanf("%d",&sport); sd=socket(AF_INET,SOCK_STREAM,0); if(sd<0) printf("Cant Create n"); else printf("Socket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(sport); sd2=bind(sd,(struct sockaddr*)&servaddr,sizeof(servaddr)); if(sd2<0) printf(" Cant Bindn"); else printf("n Bindedn"); listen(sd,5); clilen=sizeof(cliaddr); nsd=accept(sd,(struct sockaddr*)&cliaddr,&clilen);
  49. 49. if(nsd<0) printf("Cant Acceptn"); else printf("Acceptedn"); recv(nsd,recvmsg,100,0); for(i=0;i<5;i++) { if(strcmp(recvmsg,oid[i])==0) { send(nsd,mdate[i],100,0); send(nsd,time[i],100,0); break; } }}MANAGER#include<stdio.h>#include<sys/types.h>#include<netinet/in.h>main(){ int csd,cport,len,i; char sendmsg[20],rcvmsg[100],rmsg[100],oid[100]; struct sockaddr_in servaddr; printf("Enter the portn"); scanf("%d",&cport); csd=socket(AF_INET,SOCK_STREAM,0); if(csd<0) printf("Cant Createn"); else printf("Scocket is Createdn"); servaddr.sin_family=AF_INET; servaddr.sin_addr.s_addr=htonl(INADDR_ANY); servaddr.sin_port=htons(cport); if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0) printf("Cant Connectn"); else printf("Connectedn");
  50. 50. printf("n 1.TCP Connectionn"); printf("n 2. System n"); printf("Enter the number for the type of informtion needed....n"); scanf("%d",&i); if(i==1) { printf("Enter the Object ID for Clientn"); scanf("%s",oid); send(csd,oid,100,0); recv(csd,rmsg,100,0); printf("n The window size of %s is %s",oid,rmsg); } else { printf("nEnter the Object ID for the Systemn"); scanf("%s",oid); send(csd,oid,100,0); recv(csd,rmsg,100,0); printf("nThe Manufacturing date for %s is %s",oid,rmsg); recv(csd,rmsg,100,0); printf("nThe time of Last Utilization for %s is %s",oid,rmsg); }}
  51. 51. OUTPUT:AGENT1:[1me14@localhost ~]$ vi Agent1.c[1me14@localhost ~]$ cc Agent1.c[1me14@localhost ~]$ ./a.outIm the Agent - TCP ConnectionEnter the Server port_____________________8543Socket is createdBindedAcceptedMANGER:[1me14@localhost ~]$ vi Manager.c[1me14@localhost ~]$ cc Manger.c[1me14@localhost ~]$ ./a.outEnter the port8543Socket is CreatedConnected1.TCP Connection2. SystemEnter the number for the type of information needed: 1Enter the Object ID for Client: Client1The window size of client1 is 5AGENT2:[1me14@localhost ~]$ vi Agent2.c[1me14@localhost ~]$ cc Agent2.c[1me14@localhost ~]$ ./a.outEnter the Server port_____________________8543Socket is CreatedBindedAccepted
  52. 52. MANGER:[1me14@localhost ~]$ vi Manager.c[1me14@localhost ~]$ cc Manger.c[1me14@localhost ~]$ ./a.outEnter the port8543Socket is CreatedConnected1.TCP Connection2. SystemEnter the number for the type of informtion needed: 2Enter the Object ID for Client: System3The Manufacturing date for system3 is 14.03.81The time of last utilization for system3 is 11amRESULT Thus the C program for simple network management protocols has been executedsuccessfully.
  53. 53. EMAIL#include <stdlib.h>#include <string.h>#define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}#define cknltz(x) if((x)<0) {perror(""); exit(EXIT_FAILURE);}#define LIST_LEN 4//char *f="sam.txt";void email_it(char *filename);main(){ char fname[15]; printf("enter the filenamen"); scanf("%s",fname); email_it(fname);}void email_it(char *filename){ char tmp[256]={0x0}; char fpBuffer[400]={0x0}; char email_list[LIST_LEN][256]={{"mecse3@localhost.localdomain"},{0x0}}; int i=0; for(i=0;*email_list[i]>0x0;i++) { cknull(strcpy(tmp, email_list[i])); cknltz(sprintf (fpBuffer,"mail -s %s %s %s < %s", "Please Review:", filename, tmp,filename)); if(system (fpBuffer)==(-1)) { perror("email failure"); exit(EXIT_FAILURE); } }}
  54. 54. OUTPUT:[1me2@localhost ~]$ vi email.c[1me2@localhost ~]$ cc email.c[1me2@localhost ~]$ ./a.outEnter the file name: sample.c[1me2@localhost ~]$/home/1me1/dead.letter….saved message in/home/1me1/dead.letter…..RESULT Thus the program for developing E-mail application is executed and the output isverified successfully.
  55. 55. STUDY OF NETWORK SIMULATOR PACKAGESEx. No: STUDY OF NS2Date:AIM: To study about NS2 - Network SimulatorINTRODUCTION: NS is a discrete event simulator targeted at networking research. NS providessubstantial support for simulation of TCP, routing, and multicast protocols over wiredand wireless (local and satellite) networks. NS began as a variant of the REAL networksimulator in 1989 and has evolved substantially over the past few years. In 1995 nsdevelopment was supported by DARPA through the VINT project at LBL, Xerox PARC,UCB, and USC/ISI. Currently ns development is support through DARPA with SAMANand through NSF with CONSER, both in collaboration with other researchers includingACIRI. NS has always included substantial contributions from other researchers,including wireless code from the UCB Daedelus and CMU Monarch projects and SunMicrosystems. The network simulator ns-2 is a widely accepted discrete event network simulator,actively used for wired and wireless network simulations. It has a highly detailed modelof the lower layers (Physical and MAC) of wireless IEEE 802.11 networks. Ns-2 has also an emulation feature, i.e. the ability to introduce the simulator into alive network and to simulate a desired network between real applications in real-time. Within the scope of this project we developed some methods and extensions tothe ns-2 to combine wireless network simulation and network emulation.OVERVIEW: NS is an event driven network simulator developed at UC Berkeley that simulatesvariety of IP networks. It implements network protocols such as TCP and UDP, trafficsource behavior such as FTP, Telnet, Web, CBR and VBR, router queue managementmechanism such as Drop Tail, RED and CBQ, routing algorithms such as Dijkstra, andmore. NS also implements multicasting and some of the MAC layer protocols for LANsimulations. The NS project is now a part of the VINT project that develops tools forsimulation results display, analysis and converters that convert network topologiesgenerated by well-known generators to NS formats. Currently, NS (version 2) written inC++ and OTcl (Tcl script language with Object-oriented extensions developed at MIT) isavailable. This document talks briefly about the basic structure of NS, and explains indetail how to use NS mostly by giving examples. Most of the figures that are used indescribing the NS basic structure and network components are from the 5th VINT/NSSimulator Tutorial/Workshop slides and the NS Manual (formerly called "NS Notes andDocumentation"), modified little bit as needed.
  56. 56. Figure 1. Simplified Users View of NS As shown in Figure 1, in a simplified users view, NS is Object-oriented Tcl(OTcl) script interpreter that has a simulation event scheduler and network componentobject libraries, and network setup (plumbing) module libraries (actually, plumbingmodules are implemented as member functions of the base simulator object). In otherwords, to use NS, you program in OTcl script language. To setup and run a simulationnetwork, a user should write an OTcl script that initiates an event scheduler, sets up thenetwork topology using the network objects and the plumbing functions in the library,and tells traffic sources when to start and stop transmitting packets through the eventscheduler. The term "plumbing" is used for a network setup, because setting up a networkis plumbing possible data paths among network objects by setting the "neighbor" pointerof an object to the address of an appropriate object. When a user wants to make a newnetwork object, he or she can easily make an object either by writing a new object or bymaking a compound object from the object library, and plumb the data path through theobject. This may sound like complicated job, but the plumbing OTcl modules actuallymake the job very easy. The power of NS comes from this plumbing. Another major component of NS beside network objects is the event scheduler.An event in NS is a packet ID that is unique for a packet with scheduled time and thepointer to an object that handles the event. In NS, an event scheduler keeps track ofsimulation time and fires all the events in the event queue scheduled for the current timeby invoking appropriate network components, which usually are the ones who issued theevents, and let them do the appropriate action associated with packet pointed by theevent. Network components communicate with one another passing packets, however thisdoes not consume actual simulation time. All the network components that need to spendsome simulation time handling a packet (i.e. need a delay) use the event scheduler byissuing an event for the packet and waiting for the event to be fired to itself before doingfurther action handling the packet. For example, a network switch component thatsimulates a switch with 20 microseconds of switching delay issues an event for a packetto be switched to the scheduler as an event 20 microsecond later. The scheduler after 20microseconds dequeues the event and fires it to the switch component, which then passesthe packet to an appropriate output link component. Another use of an event scheduler istimer. NS is written not only in OTcl but in C++ also. For efficiency reason, NSseparates the data path implementation from control path implementations. In order to
  57. 57. reduce packet and event processing time (not simulation time), the event scheduler andthe basic network component objects in the data path are written and compiled usingC++. These compiled objects are made available to the OTcl interpreter through an OTcllinkage that creates a matching OTcl object for each of the C++ objects and makes thecontrol functions and the configurable variables specified by the C++ object act asmember functions and member variables of the corresponding OTcl object. In this way,the controls of the C++ objects are given to OTcl. It is also possible to add memberfunctions and variables to a C++ linked OTcl object. The objects in C++ that do not needto be controlled in a simulation or internally used by another object do not need to belinked to OTcl. Likewise, an object (not in the data path) can be entirely implemented inOTcl. Figure 2 shows an object hierarchy example in C++ and OTcl. One thing to note inthe figure is that for C++ objects that have an OTcl linkage forming a hierarchy, there is amatching OTcl object hierarchy very similar to that of C++. Figure 2. C++ and OTcl: The Duality Figure 3. Architectural View of NS Figure 3 shows the general architecture of NS. In this figure a general user (not anNS developer) can be thought of standing at the left bottom corner, designing andrunning simulations in Tcl using the simulator objects in the OTcl library. The eventschedulers and most of the network components are implemented in C++ and available toOTcl through an OTcl linkage that is implemented using tclcl. The whole thing togethermakes NS, which is a OO extended Tcl interpreter with network simulator libraries. This section briefly examined the general structure and architecture of NS. At thispoint, one might be wondering about how to obtain NS simulation results.
  58. 58. As shown in Figure 1, when a simulation is finished, NS produces one or moretext-based output files that contain detailed simulation data, if specified to do so in theinput Tcl (or more specifically, OTcl) script. The data can be used for simulation analysis(two simulation result analysis examples are presented in later sections) or as an input toa graphical simulation display tool called Network Animator (NAM) that is developed asa part of VINT project. NAM has a nice graphical user interface similar to that of a CDplayer (play, fast forward, rewind, pause and so on), and also has a display speedcontroller. Furthermore, it can graphically present information such as throughput andnumber of packet drops at each link, although the graphical information cannot be usedfor accurate simulation analysis.This section shows a simple NS simulation script and explains what each line does.Example 3 is an OTcl script that creates the simple network configuration and runs thesimulation scenario in Figure 4. Figure 4. A Simple Network Topology and Simulation Scenario This network consists of 4 nodes (n0, n1, n2, n3) as shown in above figure. Theduplex links between n0 and n2, and n1 and n2 have 2 Mbps of bandwidth and 10 ms ofdelay. The duplex link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms ofdelay. Each node uses a DropTail queue, of which the maximum size is 10. A "tcp" agentis attached to n0, and a connection is established to a tcp "sink" agent attached to n3. Asdefault, the maximum size of a packet that a "tcp" agent can generate is 1KByte. A tcp"sink" agent generates and sends ACK packets to the sender (tcp agent) and frees thereceived packets. A "udp" agent that is attached to n1 is connected to a "null" agentattached to n3. A "null" agent just frees the packets received.Example 3. A Simple NS Simulation Script
  59. 59. The following is the explanation of the script above. In general, an NS script startswith making a Simulator object instance. set ns [new Simulator]: generates an NS simulator object instance, and assigns it to variable ns (italics is used for variables and values in this section). o Initialize the packet format (ignore this for now) o Create a scheduler (default is calendar scheduler) o Select the default address format (ignore this for now)The "Simulator" object has member functions that do the following:  Create compound objects such as nodes and links (described later)  Connect network component objects created (ex. attach-agent)  Set network component parameters (mostly for compound objects)  Create connections between agents (ex. make connection between a "tcp" and "sink")  Specify NAM display options Most of member functions are for simulation setup and scheduling, however some ofthem are for the NAM display. The "Simulator" object member function implementationsare located in the "ns-2/tcl/lib/ns-lib.tcl" file. $ns color fid color: is to set color of the packets for a flow specified by the flow id (fid). This member function of "Simulator" object is for the NAM display, and has no effect on the actual simulation. $ns namtrace-all file-descriptor: This member function tells the simulator to record simulation traces in NAM input format. It also gives the file name that the trace will be written to later by the command $ns flush-trace. Similarly, the member function trace-all is for recording the simulation trace in a general format. proc finish {}: is called after this simulation is over by the command $ns at 5.0 "finish". In this function, post-simulation processes are specified. set n0 [$ns node]: The member function node creates a node. A node in NS is compound object made of address and port classifiers (described in a later section). Users can create a node by separately creating an address and a port classifier objects and connecting them together. However, this member function of Simulator object makes the job easier. To see how a node is created, look at the files: "ns-2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-node.tcl". $ns duplex-link node1 node2 bandwidth delay queue-type: creates two simplex links of specified bandwidth and delay, and connects the two specified nodes. In NS, the output queue of a node is implemented as a part of a link, therefore users should specify the queue-type when creating links. In the above simulation script, DropTail queue is used. If the reader wants to use a RED queue, simply replace the word DropTail with RED. The NS implementation of a link is shown in a later section. Like a node, a link is a compound object, and users can create its sub- objects and connect them and the nodes. Link source codes can be found in "ns-
  60. 60. 2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl" files. One thing to note is that you can insert error modules in a link component to simulate a lossy link (actually users can make and insert any network objects). Refer to the NS documentation to find out how to do this. $ns queue-limit node1 node2 number: This line sets the queue limit of the two simplex links that connect node1 and node2 to the number specified. At this point, the authors do not know how many of these kinds of member functions of Simulator objects are available and what they are. Please take a look at "ns- 2/tcl/libs/ns-lib.tcl" and "ns-2/tcl/libs/ns-link.tcl", or NS documentation for more information. $ns duplex-link-op node1 node2 ...: The next couple of lines are used for the NAM display. To see the effects of these lines, users can comment these lines out and try the simulation. Now that the basic network setup is done, the next thing to do is to setup trafficagents such as TCP and UDP, traffic sources such as FTP and CBR, and attach them tonodes and agents respectively. set tcp [new Agent/TCP]: This line shows how to create a TCP agent. But in general, users can create any agent or traffic sources in this way. Agents and traffic sources are in fact basic objects (not compound objects), mostly implemented in C++ and linked to OTcl. Therefore, there are no specific Simulator object member functions that create these object instances. To create agents or traffic sources, a user should know the class names these objects (Agent/TCP, Agnet/TCPSink, Application/FTP and so on). This information can be found in the NS documentation or partly in this documentation. But one shortcut is to look at the "ns-2/tcl/libs/ns-default.tcl" file. This file contains the default configurable parameter value settings for available network objects. Therefore, it works as a good indicator of what kind of network objects are available in NS and what are the configurable parameters. $ns attach-agent node agent: The attach-agent member function attaches an agent object created to a node object. Actually, what this function does is call the attach member function of specified node, which attaches the given agent to itself. Therefore, a user can do the same thing by, for example, $n0 attach $tcp. $ns connect agent1 agent2: After two agents that will communicate with each other are created, the next thing is to establish a logical network connection between them. This line establishes a network connection by setting the destination address to each others network and port address pair.Assuming that all the network configuration is done, the next thing to do is write asimulation scenario (i.e. simulation scheduling). The Simulator object has manyscheduling member functions. However, the one that is mostly used is the following: $ns at time "string": This member function of a Simulator object makes the scheduler (scheduler_ is the variable that points the scheduler object created by [new Scheduler] command at the beginning of the script) to schedule the execution of the specified string at given simulation time. For example, $ns at 0.1 "$cbr start" will make the scheduler call a start member function of the CBR traffic source object, which starts the CBR to transmit data. In NS, usually a
  61. 61. traffic source does not transmit actual data, but it notifies the underlying agent that it has some amount of data to transmit, and the agent, just knowing how much of the data to transfer, creates packets and sends them.After all network configuration, scheduling and post-simulation procedure specificationsare done, the only thing left is to run the simulation. This is done by $ns run.NETWORK COMPONENTS: Figure 6. Class Hierarchy (Partial) The root of the hierarchy is the TclObject class that is the superclass of all OTcllibrary objects (scheduler, network components, timers and the other objects includingNAM related ones). As an ancestor class of TclObject, NsObject class is the superclass ofall basic network component objects that handle packets, which may compose compoundnetwork objects such as nodes and links. The basic network components are furtherdivided into two subclasses, Connector and Classifier, based on the number of thepossible output data paths. The basic network objects that have only one output data pathare under the Connector class, and switching objects that have possible multiple outputdata paths are under the Classifier class.NODE AND ROUTING: A node is a compound object composed of a node entry object and classifiers asshown in Figure 7. There are two types of nodes in NS. A unicast node has an addressclassifier that does unicast routing and a port classifier. A multicast node, in addition, has
  62. 62. a classifier that classify multicast packets from unicast packets and a multicast classifierthat performs multicast routing. Figure 7. Node (Unicast and Multicast) In NS, Unicast nodes are the default nodes. To create Multicast nodes the usermust explicitly notify in the input OTcl script, right after creating a scheduler object, thatall the nodes that will be created are multicast nodes. After specifying the node type, theuser can also select a specific routing protocol other than using a default one.  Unicast - $ns rtproto type - type: Static, Session, DV, cost, multi-path Multicast - $ns multicast (right after set $ns [new Scheduler]) - $ns mrtproto type - type: CtrMcast, DM, ST, BSTLINK:A link is another major compound object in NS. When a user creates a link using aduplex-link member function of a Simulator object, two simplex links in both directionsare created as shown in Figure 8.
  63. 63. Figure 8. Link One thing to note is that an output queue of a node is actually implemented as apart of simplex link object. Packets dequeued from a queue are passed to the Delay objectthat simulates the link delay, and packets dropped at a queue are sent to a Null Agent andare freed there. Finally, the TTL object calculates Time To Live parameters for eachpacket received and updates the TTL field of the packet. Tracing In NS, network activities are traced around simplex links. If the simulator isdirected to trace network activities (specified using $ns trace-all file or $ns namtrace-allfile), the links created after the command will have the following trace objects inserted asshown in Figure 9. Users can also specifically create a trace object of type type betweenthe given src and dst nodes using the create-trace {type file src dst} command. Figure 9. Inserting Trace Objects When each inserted trace object (i.e. EnqT, DeqT, DrpT and RecvT) receives apacket, it writes to the specified trace file without consuming any simulation time, andpasses the packet to the next network object. The trace format will be examined in theGeneral Analysis Example section. Queue Monitor Basically, tracing objects are designed to record packet arrival time at which theyare located. Although a user gets enough information from the trace, he or she might beinterested in what is going on inside a specific output queue. For example, a userinterested in RED queue behavior may want to measure the dynamics of average queuesize and current queue size of a specific RED queue (i.e. need for queue monitoring).Queue monitoring can be achieved using queue monitor objects and snoop queue objectsas shown in Figure 10.
  64. 64. Figure 10. Monitoring Queue When a packet arrives, a snoop queue object notifies the queue monitor object ofthis event. The queue monitor using this information monitors the queue. A RED queuemonitoring example is shown in the RED Queue Monitor Example section. Note thatsnoop queue objects can be used in parallel with tracing objects even though it is notshown in the above figure.PACKET FLOW EXAMPLE: Until now, the two most important network components (node and link) wereexamined. Figure 11 shows internals of an example simulation network setup and packetflow. The network consist of two nodes (n0 and n1) of which the network addresses are 0and 1 respectively. A TCP agent attached to n0 using port 0 communicates with a TCPsink object attached to n1 port 0. Finally, an FTP application (or traffic source) isattached to the TCP agent, asking to send some amount of data. Figure 11. Packet Flow Example Note that the above figure does not show the exact behavior of a FTP over TCP. Itonly shows the detailed internals of simulation network setup and a packet flow.PACKET: A NS packet is composed of a stack of headers, and an optional data space (seeFigure 12). As briefly mentioned in the "Simple Simulation Example" section, a packet
  65. 65. header format is initialized when a Simulator object is created, where a stack of allregistered (or possibly useable) headers, such as the common header that is commonlyused by any objects as needed, IP header, TCP header, RTP header (UDP uses RTPheader) and trace header, is defined, and the offset of each header in the stack is recorded.What this means is that whether or not a specific header is used, a stack composed of allregistered headers is created when a packet is allocated by an agent, and a network objectcan access any header in the stack of a packet it processes using the corresponding offsetvalue. Figure 12. NS Packet FormatUsually, a packet only has the header stack (and a data space pointer that is null).Although a packet can carry actual data (from an application) by allocating a data space,very few application and agent implementations support this. This is because it ismeaningless to carry data around in a non-real-time simulation. However, if you want toimplement an application that talks to another application cross the network, you mightwant to use this feature with a little modification in the underlying agent implementation.Another possible approach would be creating a new header for the application andmodifying the underlying agent to write data received from the application to the newheader. The second approach is shown as an example in a later section called "Add NewApplication and Agent".RESULT: Thus the details about NS2(Network Simulator 2) has been studied.
  66. 66. Ex. No. STUDY OF OPNETDate:AIM: To study about OPNET - Network SimulatorINTRODUCTION: OPNET (Optimized Network Engineering Tools) is a commercial tool from MIL3Inc. It is being developed for almost 15 years. As everyone should guess, no muchtechnical detail are available about the internals.USE: Network with several hundreds of nodes can be simulated, but it would take timefor the computation. OPNET is used by companies like Thomson-CSF or CNET whichuse it to model ATM networks and validate various layers protocols, packet switchedradio networks. An example of use of OPNET is George Mason University (Quality ofService IP Network Simulation).THE PACKAGE The software comprises several tools and is divided in several parts, OPNETModeler and OPNET Planner, the Model Library, and the Analysis tool. Featuresincluded in this generic simulator are an event-driven scheduled simulation kernel,integrated analysis tools for interpreting and synthesizing output data, graphicalspecification of models and a hierarchical object-based modeling. OPNET Modeler is intended for modeling, simulating and analyzing theperformance of large communications networks, computer systems and applications.Common uses are assessing and feasibility of new designs, optimizing already developedcommunication systems and predicting performance. The modeling methodology of OPNET is organized in a hierarchical structure. Atthe lowest level, Process models are structured as a finite state machine. State andtransitions are specified graphically using state-transition diagrams whereas conditionsthat specify what happen within each state are programmed with a C-like language calledProto-C. Those processes and built-in modules in OPNET (source and destinationmodules, traffic generators, queues, ...) are then configured with menus and organizedinto data flow diagrams that represent nodes using the graphical Node Editor. Using agraphical Network Editor, nodes and links are selected to build up the topology of acommunication network. The Analysis Tool provides a graphical environment to view and manipulate datacollected during simulation runs. Results can be analyzed for any network element. OPNET Planner is an application that allows administrators to evaluate theperformance of communications networks and distributed systems, without programmingor compiling. Planner analyses behavior and performance by discrete-event simulations.Models are built using a graphical interface. The user only chooses pre-defined models(from the physical layer to the application) from the library and sets attributes. The usercannot define new models, he should contact MIL3s modeling service.
  67. 67. The modeling libraries are included with OPNET Modeler and OPNET Plannerand contains protocols and analysis environments, among them ATM, TCP, IP, FrameRelay, FDDI, Ethernet, link models such as point-to-point or bus, queueing servicedisciplines such as First-in-First-Out (FIFO), Last-In-First-Out (LIFO), priority non-preemptive queueing, shortest first job, round-robin or preempt and resume. OPNET Modeler is the industrys leading environment for network modeling andsimulation, allowing you to design and study communication networks, devices,protocols, and applications with unmatched flexibility and scalability. Modeler is used bythe worlds largest network equipment manufacturers to accelerate the R&D of networkdevices and technologies such as VoIP, TCP, OSPFv3, MPLS, IPv6, and more. Networking technology has become too complex for traditional analyticalmethods or "rules of thumb" to yield an accurate understanding of system behavior. Since 1986, OPNET Technologies Inc., has been the leader in developingpredictive software solutions for networking professionals. OPNET software enables itsusers to optimize the performance and maximize the availability of communicationsnetworks and applications.OPNET is the state-of-art network simulation tool for modeling, simulating and analysingthe performance of i. Communication Networks, Distributed Systems ii. Computer systems and Applications.Product modules provide value-added capabilities to OPNETs intelligent networkmanagement software. Modules span a wide range of applications and receive regularupdates under OPNETs maintenance program.OPNET MODULES:  Modeler  Terrain Modeling Module (TMM)  High Level Architecture (HLA)MODELER: OPNET Modeler is intended for modeling, simulating and analysing theperformance of large communications networks, computer systems and applications.Common uses are assessing and feasibility of new designs, optimizing already developedcommunication systems and predicting performance. The modeling methodology of OPNET is organized in a hierarchical structure. Atthe lowest level, Process models are structured as a finite state machine. State andtransitions are specified graphically using state-transition diagrams whereas conditionsthat specify what happen within each state are programmed with a C-like language calledProto-C. Those processes, and built-in modules in OPNET (source and destinationmodules, traffic generators, queues, ...) are then configured with menus and organizedinto data flow diagrams that represent nodes using the graphical Node Editor. Using agraphical Network Editor, nodes and links are selected to build up the topology of acommunication network.
  68. 68. TERRAIN MODELING MODULE (TMM) Building on the capabilities of OPNETs Wireless Module, the Terrain ModelingModule provides the next level of accuracy and control for wireless network design andplanning. This module allows you to model environmental effects on wireless networkcommunications anywhere. Featuring an open-source Longley-Rice model, the Terrain Modeling Module isready to replicate any known atmospheric or topological conditions and their combinedimpact on signal propagation. Create elevation maps, line-of-sight profiles, and signal-power comparisons of mobile network models. Interfaces to read DTED and USGS DEMterrain data are provided. Open and flexible, the Terrain Modeling Module is supportedby the standard Radio Transceiver Pipeline, which enables easy implementation ofcustom propagation modelsHIGH LEVEL ARCHITECTURE (HLA) The High-Level Architecture (HLA) Module supports building and running afederation of many simulators, each modeling some aspect of a composite system. TheOPNET HLA Module enables OPNET simulations to model some portion (or theentirety) of the communications aspects of the HLA federation models. The OPNET-HLA interface provides the various simulators (federates) the necessary mechanisms toshare a common object representation (for persistent elements), to exchange messages(interactions), and to maintain appropriate time synchronization.The module supports a large subset of the HLA interface, including:  Time management such that an OPNET simulation remains synchronized with overall HLA time  Generation and reception of RTI interactions using OPNET packet  Creation, destruction, or discovery of RTI objects during the simulation  Generation of RTI object attribute updates based on changes to OPNET attribute values  Automatic updates of OPNET attributes upon reception of RTI object attribute updates  A user-defined mapping specifying the relation between RTI and OPNET objectsRESULT: Thus the Network Simulator-OPNET has been studied.

×