Академический Документы
Профессиональный Документы
Культура Документы
Issue Number: 1
Revision: 0
DEPARTMENT OF ECE
6. 7.
8. 9. 10.
CYCLE II
2. i) Develop a Client Server application for chat. ii) Develop a Client that contacts a given DNS Server to resolve a given host name. 3. Write a Client to download a file from a HTTP Server. 4. Implementation of distance vector routing algorithm. 5. Study of Network Simulators like NS2/ Glomosim / OPNET.
Server: 1. Start 2. Create a shared memory segment and get its id using shmget() ; 3. Create a shared memory painter and attach it to the shared memory using shmat(). 4. A table containing machine address and its equivalent IP address is created and it is shared in the shared memory segment. 5. Display contents of shared memory using its pointer. 6. Detach pointer from the shared memory using shmdt(). 7. Stop. Client: 1. Start. 2. Create the shared memory pointer which refers to the same memory segment that server has created using shmget() . 3. Create options to find ARP, RARP and exit.
4. If ARP is requested, then compare the given IP address in the shared memory segment and print the machine address. 5. If RARP is requested, then compare the given machine address in the ARP table and display the equivalent IP address. 6. Repeat step 4 and 5 depending upon the user's choice. 7. Exit.
#include<stdio.h> #include<sys/types.h> #include<sys/shm.h> #include<string.h> main() { int shmid, a, i; char *ptr, *shmptr; shmid=shmget(3000,10,IPC_CREAT | 0666); shmptr=shmat(shmid,NULL,0); ptr=shmptr; for(i=0;i<3;i++) {
puts("enter the mac"); scanf("%s",ptr); a=strlen(ptr); printf("string length:%d",a); ptr[a]= ' ' ; puts("enter ip"); ptr=ptr+a+1; scanf("%s",ptr); ptr[a]='\n' ; ptr= ptr+a+1; } ptr[strlen(ptr)]= '\0'; printf("\n ARP table at serverside is=\n%s", shmptr); shmdt(shmptr); } ARP table at serverside is a.b.c.d 1.2.3.4 e.f.g.h 5.6.7.8 i.j.k.l 9.1.2.3
ARP Client #include<stdio.h> #include<string.h> #include<sys/types.h> #include<sys/shm.h> main() { int shmid,a; char *ptr, *shmptr; char ptr2[51], ip[12], mac[26]; shmid=shmget(3000,10,0666); shmptr=shmat(shmid,NULL,0); puts("the arp table is"); printf("%s",shmptr); printf("\n1.ARP\n 2.RARP\n 3.EXIT\n"); scanf("%d",&a); switch(a) { case 1: puts("enter ip address");
scanf("%s",ip); ptr=strstr(shmptr, ip); ptr-=8; sscanf(ptr,"%s%*s",ptr2); printf("mac addr is %s",ptr2); break; case 2: puts("enter mac addr"); scanf("%s",mac); ptr=strstr(shmptr, mac); sscanf(ptr,"%*s%s",ptr2); printf("%s",ptr2); break; case 3: exit(1); } }
RESULT
The arp table is a.b.c.d 1.2.3.4 e.f.g.h 5.6.7.8 i.j.k.l 9.1.2.3 1.ARP 2.RARP 3.EXIT enter your choice: 1 enter ip address: 1.2.3.4 mac addr is a.b.c.d enter your choice:2 enter mac address: e.f.g.h ip addr is 5.6.7.8
information.
SOFTWARE USED:
Step1: Start the program. Step 2: Include all the header files. Step 3: Declare two files pointers for opening the input file in read mode and the output in write mode. Step 4: Read the content of an input file. Step 5: If the bit is 1, then check for four consecutive 1,s. Step 6: If so then stuff a bit 0 at that position (i.e. after five consecutive 1s) Step 7: open the output file in write mode and print the stuffed string. Step 8: Stop the program.
10
PROGRAM:
#include<stdio.h> #include<string.h> main() { int i=0,j=0,k,d; char a[50]; do { printf("\n enter the choice 1.stuff 2.destuff 3.exit"); scanf("%d",&d); switch(d) { case 1: printf("enter the data.."); scanf("%s",a); for(i=0;i<strlen(a);i++) { if(a[i]=='1') j++; else j=0;
11
if(j==5) { for(k=strlen(a);k>i;k--) { a[k+1]=a[k]; } a[i+1]='0'; } } printf("%s",a); break; case 2: printf("\n enter the data"); scanf("%s",a); j=0; for(i=0;i<strlen(a);i++) { if(a[i]=='1') j++; else j=0;
12
if(j==5) { i=i+1; for(k=i;k<strlen(a);k++) a[k]=a[k+1]; a[k]='\0'; i=i-1; } } printf("\n the unstuffed data is %s",a); break; case 3: break; } } while(d<4); }
13
Input Output: Enter the choise 1.stuff 2.destuff 3.exit 1 Enter the data..10111111010 10111111010 Enter the choice 1.stuff 2.destuff 3.exit 2 Enter the data 10111111010 The unstuffed data is 10111111010 enter the choice 1.stuff 2.destuff 3.exit
Result: Thus the c program for bit stuffing was verified and written successfully.
14
ALGORITHM:
Step 1: Declare int crc 16, SHIFT_CRC, shift Byte, Byte_SIZE as global variables. Step 2: Input the data in a file. Step 3: perform the crc computation using cal CRC 16 (). Step 4: In cal CRC 16 each character from input shifted with shift-byte where value 987. Step 5: Output of step 4 and step 5 are exclusive. Step 6: store in a temporary variable. Step 7: Byte value is now left_shifted by 1. Step 8: The loop is repeated for the Byte_size. Step 9: The computed crc is display as output in screen.
15
PROGRAM
#include<stdio.h> int i.data[10].dl.gen[10],gl,temp[10],c; void left_shift() { for(i=0;i<gl-1;i++) temp(i)=temp[i+1]; if(c<d1) temp[gl-1]=data[c]; else temp[gl-1]=0 } void xor() { if(temp[0]==0 { left_shift(); c++; for(i=0;i<gl;i++) { if(gen(i)==temp(i) temp(i)=0
16
else temp[i]=1; } } main() { int j; printf("1.generate2.check\nchoice:"); scanf("%d",&j); printf("Enter the length of data:"); scanf("%d",&dl); printf("Enter the data:"); for(i=0;i<dl;i++) scanf("%d";&data[i]); printf("Enter the length of generator:"); scanf("%d",&gl); printf("Enter the generator:"); for(i=0;i<gl;i++) temp[i]=data[i] if(j==1) {
17
for(c=4;c<dl+gl-2;c++) { xor(); printf("crc:"); for(i=0;i<dl;i++) printf"%d",data[i]); } else { for(c=4;c<dl;c++) { xor(); left_shift(); } printf("crc"); } for(i=1;i<gl;i++) printf("%d"'temp[i]); printf("\n"); } Input Output:
18
1. Generate2.check choice:1 Enter the length of data:6 Enter the data:1 0 1 1 0 1 Enter the length of generator:4 Enter the generator:1 1 0 1 crc:101101001
Result: Thus the c program for CRC was verified and written successfully.
Exp. No. :3 Date:
19
Server: 1. Start. 2. Open the file recvfile.txt in write mode. 3. Receive the port number and establish socket connection. 4. Listen to clients request using system call listen() . 5. While the message size is not zero, receive the client message and write it in to a file. 6. Close the socket connection, 7. Stop.
Client: 1. Start. 2. Pass server address and file name as command line arguments. 3. Open the file and establish connection using socket(). 4. Using memset(), get the size of client address. 5. Connect to server using connect()system call. 6. While not end of file, print the contents into the file.
20
7. Close the socket connection. 8. Stop. Syntax: 1. socket() socket(protocol family, type of socket, protocol); 2. connect() connect(client socketid, client address, length of server address); 3. send() send(int s, void $buf, size_tlen, int flags); 4. recv() recv(int s, void $buf, size_tlen, int flags); 5. listen() listen(server socket, protocol type for number of connection) ; 6. accept() accept(socket id, client information, client size);
Rs232 server program:
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/socket.h> #include<sys/types.h> #include<arpa/inet.h> #define MAX 5 #define BUF 256 int main(int argc, char **argv)
21
{ int sersock, clisock, portno; struct sockaddr_in echoseraddr,echocliaddr; char echobuffer[BUF]; unsigned int clilen, recvmsgsize; FILE *fp=fopen(recvfile.txt,w); portno=atoi(argv[1]); sersock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); memset(&echoseraddr,0,sizeof(&echoseraddr)); echoseraddr.sin_family=AF_INET; echoseraddr.sin_addr.s_addr=htonl(INADDR_ANY); echoseraddr.sin_port=htons(portno); bind(sersock,(struct sockaddr*)&echoseraddr,sizeof(echoseraddr)); printf(\nServer waiting for client on port %d, portno); listen(sersock,MAX); clilen=sizeof(echocliaddr); clisock=accept(sersock,(struct sockaddr *)&echocliaddr, &clilen); recvmsgsize=1; while(recvmsgsize>0) { recvmsgsize=recv(clisock,echobuffer,BUF,0); echobuffer[recvmsgsize]=\0; fprintfp(fp,%s,echobuffer); } printf(\nFile received and socket closed); close(clisock); fclose(fp);
22
return 0; }
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/types.h> #include<sys/socket.h> #include<unistd.h> #include<arpa/inet.h> #define BUF 256 int main(int argc, char **argv) { int sock, portno; struct sockaddr_in echoseraddr; char *serIP, *filename, echobuffer[32]; FILE *fp; serIP=argv[1]; filename=argv[2]; portno=atoi(argv[3]); fp=fopen(filename,r); sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); memset(&echoseraddr,0,sizeof(&echoseraddr)); echoseraddr.sin_family=AF_INET; echoseraddr.sin_addr.s_addr=inet_addr(serIP);
23
echoseraddr.sin_port=htons(portno); connect(sock,(struct sockaddr *)&echoseraddr, sizeof(echoseraddr)); while(!feof(fp)) { fgets(echobuffer,BUF,fp); send(sock,echobuffer,strlen(echobuffer),0); } printf(\nThe %s send over RS232,filename); close(sock); return 0; }
Input Output:
In Server Side: Server waiting for client on port 8222 File received and socket closed cat recvfile.txt this is rs232 program In Client Side: The rsinput.txt send over RS232 cat > rsinput.txt this is rs232 program
RESULT:
Thus the program for transferring files over RS232 was verified and written successfully.
24
Sliding-Window protocol
AIM:
Step 1: start the program. Step 2: Open the input file in read mode. Step 3: Read the size of the window Step 4: Select randomly the number of packets is to be transferred. Step 5: Read the content of the input file. Step 6: Transfer the packet until it reaches the maximum defined size. Step 7: Resume the window size and repeat the above two steps until packets in. Step 8: Close the file. Step 9: Stop the program.
25
PROGRAM:
#include<stdio.h> #include<stdlib.h> main() int i,m,n,j,w,1; char c; FILE*f; f=fopen("text.txt","r"); printf("window size"); scanf("%d",&n); m=n; while(!fof(f)) { i=rand()%n+1; j=i; 1=i; if(m>i) { m=m-i; if(m>0) { printf("\n"); while(i>0 & !feof(f)) {
26
c=getc(f); printf("%c",c); i--; } printf("\n%d transferred"j); if(j>3) printf("\n 1 acknowledgement received"); else printf("\n acknowledgement received",j+1); } } m=m+j-1; } }
ack received
Result: Thus the c program of Sliding window was verified and written successfully
28
To write a program for open shortest path between server and destination node.
SOFTWARE REQUIRED:
Step 1: Start the program. Step 2: Include the necessary header files. Step 3: Declare the variable functions. Step 4: Get the Number of nodes and the cost of the edge between various nodes. Step 5: Enter the source and destination nodes. Step 6: Find the shortest path between source and destination node. Step 7: Stop the program execution.
29
PROGRAM:
#include<iostream.h> #include<conio.h> #include<stdlib.h> class path { int a[10][10],c[10[10],key[10][10],num,min,i,j,k; public: void findpath(); void read(); void output(int,int); void out(int i, int j); }; void path::read() { cout<<Number of nodes:; cin>>num; for(i=1;i<=num;i++) for(j=1;j<=nump;j++) { if(i==j) a[i][j]=0; else { cout<<The cost for[<<i<<,<<j<<]; cin>>a[i][j]; } c[i][j]=a[i][j]; key[i][j]=0; }} void path::findpath() { int t1,t2,t3; for(k=1;k<=num;k++) for(i=1;i<=num;i++) for(j=1;j<=num;j++) { t1=c[i][k]; t2=c[k][j]; t3=c[i][j]; if(t1!=0 &&t2!=0 && (t3==0||t1+t2<t3)) { c[i][j]=t1+t2; key[i][j]=k; }}}
30
void path::output(int i, int j) { min=0; if(c[i][j]==0) { cout<<no path exist; return; } else { cout<<The path is :<<i; out(i,j); cout<<end1<<cost is :<<min; cout<<\n; }} void path :: out(int i, int j) { if(i==j) return; if(key[i][j]==0) { cout<<-><<j; min+=a[i][j]; } else { out(i,key[i][j]); out(key[i][j],j); }} void main() { clrscr(); int ch=1,n1,n2; path p; p.read(); p.findpath(); cout<<end1<<1.Shortest path<<end1; cout<<2.Exit<<end1; while(ch!=2) { cout<<end1<<choice..; cin>>ch; switch(ch) { case 1: cout<<enter the source node; cin>>n1; cout<<enter the destination node; cin>>n2;
31
Output: Number of nodes : 3 The cost for [1,2] : 1 The cost for [1,3] : 4 The cost for [2,1] : 2 The cost for [2,3] : 2 The cost for [3,1] : 2 The cost for [3,2] : 1 1.shortest path 2.exit Choice.. 1 Enter the source code : 1 Enter the destination code : 3 The path is 1 -> 2 ->3 Cost is 3
Result: Thus the program for the simulation of OSPF routing protocol was executed.
32
Client: 1. Start the program 2. To create a socket in client to server. 3. The client establishes a connection to the server. 4. The client accept the connection and to send the data from client to server and versa 5. The client communicate the server to send the end of the message 6. Stop the program. Server: 1. Start the program 2. To create a socket in server to client 3. The server establishes a connection to the client. 4. The server accept the connection and to send the data from server to client and vice Versa 5. The server communicate the client to send the end of the message 6. Stop the program.
vice
33
PROGRAM: Client: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <sys/types.h> #include <sys/socket.h> char buf[80]; struct sockaddr myname; void replyBack(FILE *fp, int sockfd) { char sendline[1000], recvline[1000]; printf("Enter your echo: \n"); while(fgets(sendline,1000,stdin) != NULL) { write(sockfd,sendline,sizeof(sendline)); if(read(sockfd,recvline,1000) == 0) { printf("str_cli: server terminated prematurely"); exit(-1); } fputs(recvline, stdout); } } main() { int sock, adrlen, cnt; sock = socket(AF_UNIX, SOCK_STREAM, 0); if(sock < 0) { printf("client socket failure%d\n", errno); printf("client: "); exit(1); } myname.sa_family = AF_UNIX; strcpy(myname.sa_data, "/tmp/billb");
34
adrlen = strlen(myname.sa_data) + sizeof(myname.sa_family); if(connect(sock, &myname, adrlen) < 0) { printf("client connect failure %d\n", errno); perror("client: "); exit(1); } replyBack(stdin,sock); exit(0); } Server: #include <stdio.h> #include <errno.h> #include <signal.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> struct sockaddr myname; char buf[80]; void echo(int sockfd) { ssize_t n; int write_err; char buf[1000]; char * send_start_pos; while(1) { bytes_in = read(sockfd, buf, 1000); if(bytes_in < 1) { if(errno == EINTR) continue; break; } bytes_remaining = bytes_in; send_start_pos = buf; write_err = 0;
35
while((bytes_remaining > 0) && !(write_err)) { bytes_out = write(sockfd, send_start_pos, bytes_remaining); if(bytes_out < 0) { if(errno == EINTR) continue; write_err = 1; break; } bytes_remaining -= bytes_out; send_start_pos += bytes_out; } if(write_err) break; } } main() { int sock, new_sd, adrlen, cnt; sock = socket(AF_UNIX, SOCK_STREAM, 0); if(sock < 0) { printf("server socket failure %d\n", errno); perror("server: "); exit(1); } myname.sa_family = AF_UNIX; strcpy(myname.sa_data, "/tmp/billb"); adrlen = strlen(myname.sa_data) + sizeof(myname.sa_family); unlink("/tmp/billb"); /*defensive programming */ if(bind(sock, &myname, adrlen) < 0) { printf("server bind failure%d\n", errno); perror("server: "); exit(1); } if(listen(sock, 5) < 0) {
36
printf("server listen failure %d\n", errno); perror("server: "); exit(1); } while(1) { if(new_sd = accept(sock, &myname, &adrlen) < 0) { printf("server accept failure %d\n", errno); perror("server: "); exit(1); } printf("Socket address in server %d is %s, %s\n", getpid(), myname.sa_data, myname.sa_data); if(fork() == 0) { close(sock); echo(new_sd); exit(0); } close(new_sd); } }
Result: Thus the program for client-server application for chat was executed.
37
Step 1: start the program excution. Step 2: include header file,define max data size and port. Step 3: enter the domain name. Step 4: get the domain name. Step 5: if it is not found then error on domain name.
PROGRAM: DNS Server
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<sys/socket.h> #include<sys/types.h> #include<netinet/in.h> #include<arpa/inet.h> #include<error.h> #include<netdb.h> #define MAX 100 #define ipaddr"127.0.0.1" #define port 4001 typedef struct sockaddr SA; struct dns { char dname[25];
38
char ipaddr[25]; }; int main() { int cfd; char buff[MAX]; struct socket_in server; struct dns r; cfd=socket(AF_INET<SOCK_STREAM,0); bzero(&server,sizeof(server)); server.sin_family=AF_INET; server.sin_port=htons(port); inet_pton(AF_INET,ipaddr,&server.sin_addr); connect((cfd,(SA*)&server ,sizeof(server)); printf("enter the domain name"); scanf("%s",r,dname); write(cfd,&r,sizeof(struct dns)); bzero(&r,sizeof(struct dns )); read(cfd,&r,sizeof(struct dns)); printf("ipaddr = %s",r, ipaddr); close(cfd); }
DNS Client
#include<stdio.h> #include<string.h> #include<sys/socket.h> #include<netinet/in.h> int main() { int csd,cport,len; char sendmsg[20],recvmsg[20],rc[20]; struct socket_in servaddr; printf(\n enter the port address); scanf(%d,&cport); csd=socket(AF_INET<SOCK_STREAM,0); if(csd<0) printf(ERROR:socket creation failed); servaddr.sin_family=AF_INET; servaddr.sin_port=htons(port); if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))<0)
39
printf(\n cannot connect); else printf( \n connected); printf("enter the domain name"); scanf("%s",sendmsg); sendmsg(csd,sendmsg,20,0); recvmsg(csd,rc,20,0); printf("\n the corresponding ip address for given domain name is:); printf(%s,rc);}
Result: Thus the program for domain name system was verified and written successfully.
40
1. Set the command line argument. 2. Check the command line arguments and allocate yes or no for the rest of argv[1]=1; 3. Copy 1 info host and info integers. 4. Otherwise assign post to argv[1] 5. Print the host and the request. 6. Create a socket and connect the socket. 7. Print the download page into a buffer. 8. Open a file in a write mode, write the download page into the fill. 9. Close the socket and the file.
41
PROGRAM
#include<stdio.h> #include<stdlib.h> #include<netdb.h> #include<netinet/in.h> #include<arpa/inet.h> #include<sys/types.h> #include<sys/socket.h> #define size 100 int main(int argc, char *argv[]) { struct sockaddr_in sock; struct hostent *hp,port; char *req,*hostname,*cp; FILE *local; char buff[size]; int con,i,l,nrv,sd; if(argc!=3) { printf(\nUsage: %s<server>filename,argv[0]); exit(1); } if(cp=strchr(argv[1],/)) { *cp=\0; l=strlen(argv[1]); hostname=malloc(l+1); strcpy(hostname,argv[1]); *cp=/; l=strlen(cp); req=malloc(l+1); strcpy(req,cp); } else { hostname=argv[1]; req=/; } printf(\nHost=%s\nReq= %s,hostname,req);
42
sd=socket(AF_INET,SOCK_STREAM,0); if(sd<0) { perror(\nCannot open socket); exit(1); } bzero(&sock,sizeof(sock)); sock.sin_family=AF_INET; con=inet_pton(AF_INET, argv[1], &sock); sock.sin_port=htons(80); con=connect(sd,(struct sockaddr *)&sock, sizeof(sock)); if(con<0) { perror(\nConnection failed); exit(1); } sprintf(buff,Get HTTP:%s//1.1\r\nHost: %s\r\nConnection: class\r\n\r, req, hostname); printf(Buff=%s\n, buff); l=strlen(buff); local=fopen(argv[2],w); write(sd,buff,1); do { nrv=read(sd,buff,size); if(nrv>0) { for(i=0;i<nrv;i++) putc(buff[i],local); } else break; } while(1); close(sd); fclose(local); return 0; }
43
Input Output: http:/197.168.2.3/z :hi.txt hello.txt Host=http: Connection failed: Connection refused Req= /197.168.2.3/z :hi.txt
Result: Thus the program was executed for downloading a file from a HTTP Server.
44
45
Shortest path algorithm is a static routing algorithm; hence the network topology / Configuration needs to be given before the router starts working. During the router operation if there is a change in the network topology or if a router goes down the new network topology need to be entered again. PROCEDURE Distance Vector Algorithm The values need to be entered on all the pcs that are to be used as nodes. Here we are taking the number of hops as the metrics for calculating best path to the destination node. 1. Select the Distance vector routing algorithm from the menu or click on the on the shortcut for distance vector.
46
clicking on the O.K button the messenger window will open. Click on the Show table you can see all the possible paths to all other nodes is unknown initially. The path with least number of hops is selected. OBSERVATION In this algorithm also we can understand the algorithm and the path taken by packet by sending messages from one node to another. To pass the message from Node 1 to Node 3 through Node 2, it will choose less No of hops to travel from node 1 to node 3.When the message is sent to node 3, the packet will first be sent to the node is the path column. In this case the packet is first sent to node 2, which will then forward the packet to node 3
RESULT Thus the implementation of distance vector routing has been done and verified.
47
48
Distributing the Link State Packets: The Fundamental idea is to use flooding to distribute the Link state Packets. To Keep the Flood in check, each packet contains a sequence number that is incremented for each new packet sent. Routers keep track of all the packets that they receive. They keep track of the Source Router that sent the packet and the sequence number of the packet. When a new Link State Packet comes in, it is checked against the list of packets already seen. If it is new, it is forwarded on all lines except the one it arrived on. If it is a duplicate it is discarded. If the sequence number is lower than the highest one seen so far, it is rejected as being obsolete. Age field is included after the sequence number and is decremented every second. When the age hits zero, the information from that router is discarded. Normally a packet comes in every 10 minutes, so router information only times out when the router is down. The age field is also decremented by each router during the initial flooding process, to make sure no packet can get lost and live for an indefinite period of time. Computing the New Routes: Once the Router has accumulated a full set of link state packets, it can construct the entire subnet graph because every link is known. Now dijikstras algorithm can be run locally to construct the shortest path to all possible destinations. The results of this algorithm can be installed in the routing tables and normal operations resumed. PROCEDURE Consider the example below for Link State entering the values. The values need to be entered on all the pcs that are to be used as nodes. Here we are taking the number of hops as the metrics for calculating best path to the destination node.
49
1. Select the Link State routing algorithm from the menu or by selecting the shortcut icon
t we have taken, there are 4 5. After configuring and clicking on the O.K button the messenger window will open.
50
6. Click on the Show table you can see the path to all other nodes is unknown initially. Once the other nodes come up the path will be obtained automatically by sending hello packets and neighbor info to all other nodes. In distance vector the neighbor info is sent to only other neighbors whereas in link state routing neighbor info is sent to all other nodes 8. Similarly configure for other systems by clicking the Executable Routers with the same procedure as explained above. Once all the nodes come up, they will exchange their neighbor information with all other nodes and calculate the shortest to all the nodes in the network. The shortest path from a given node to all other network can be seen by clicking on the show table button on the messenger window. OBSERVATION The message from node 1 to node 4 will have to pass through node 2 as the path from 1 to 4 is 1-2-4. When the message is sent to node 4, the packet will first be sent to the node is the path column. In this case the packet is first sent to node 2, which will then forward the packet to node 4.
RESULT Thus the implementation of link state routing has been done and verified. 51
A discrete event simulator targeted at networking research. Ns provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks. Simulation of protocols (TCP, routing, multicast...) over networks (wireless, Wired, satellite). Ns began as a variant of the REAL network simulator in 1989 and have evolved substantially over the past few years. In 1995 ns development was supported by DARPA through the VINT project at LBL, Xerox PARC, UCB, and USC/ISI. Currently ns development is support through DARPA with SAMAN and through NSF with CONSER, both in collaboration with other researchers including ACIRI. Ns have always included substantial contributions from other researchers, including wireless code from the UCB Daedelus and CMU Monarch projects and Sun Microsystems. For documentation on recent changes, see the version 2 change log. While we have considerable confidence in ns, ns is not a polished and finished product, but the result of an on-going effort of research and development. In particular, bugs in the software are still being discovered and corrected. Users of ns are responsible for verifying for themselves that their simulations are not invalidated by bugs. We are working to help the user with this by significantly expanding and automating the validation tests and demos. Similarly, users are responsible for verifying for themselves that their simulations are not invalidated because the model implemented in the simulator is not the model that they were expecting. The ongoing Ns Manual should help in this process. NS is Object Oriented Tcl (OTcl) script interpreter that has a simulation event scheduler and network component object libraries, and network setup module libraries. To run a simulation network, a user should write an OTcl script that initiates an event scheduler, sets up the network 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 event scheduler. Another major component of NS beside network objects is the event scheduler. An event is NS is a packet ID that is unique for a packet with scheduled time and the pointer to an object that handles the event. All the network components that need to spend some simulation time handling a
52
packet (i.e. need a delay) use the event scheduler by issuing an event for the packet and waiting for the vent to be fired to itself before doing further action handling the packet. Another use of an event scheduler is timer. It can generally implemented in split language programming using C++ and TCL. Split-Language Programming Ns separate the data path implementation from control path implementations. In order to reduce packet and event processing time, the event scheduler and the basic network component objects in the data path are written and compiled using C++. Implementation Of Node and Link General, architecture of NS a user can be thought of standing at the left bottom corner, designing and running simulations in Tcl using the simulator objects in the OTcl library. The event scheduler and most of the network components are implemented in C++ and available to OTcl through an OTcl linkage that is implemented using tclcl. When a simulation is finished, NS produces one or more text-based output that files that contain detailed simulation data. The data can be used for simulation analysis or as and input to a graphical simulation display too called Network Animator (NAM) that is developed as a part of VINT project.
53
OPNET
A common presentation of the OPNET simulator (OPNET Modeler) is Provided . OPNET is very large and powerful software with wide variety of possibilities . Enables the possibility to simulate entire heterogeneous networks with various protocols . Development work was started in 1986 by MIL3 Inc. (nowadays OPNET Technologies Inc.) . Originally the software was developed for the needs of military, but it has grown to be a world leading commercial network simulation tool . OPNET is quite expensive for commercial usage but there are also free licenses for educational purposes. OPNET is a high level event based network level simulation tool . Simulation operates at packet-level .Originally built for the simulation of fixed networks . OPNET contains a huge library of accurate models of commercially available fixed network hardware and protocols . Nowadays, the possibilities for wireless network simulations are also very Wide . Accurate radio transmission pipeline stage for the modeling of the physical layer (radio interface) . The simulator has a lot of potentiality, but there exists typically a lack of the recent wireless systems . Much of the work considering new technologies must be done by Oneself .OPNET can be used as a research tool or as a network design/analysis tool (end user). The threshold for the usage is high for the developer, but low for the end user.
54
The structure of OPNET OPNET consists of high level user interface, which is constructed from C and C++ source code blocks with a huge library of OPNET specific functions Hierarchical structure, modeling is divided to three main domains: Network domain Networks + sub-networks, network topologies, geographical coordinates, mobility Node domain Single network nodes (e.g., routers, workstations, mobile devices) Process domain Single modules and source code inside network nodes (e.g., data traffic source model) With OPNET it is also possible to run external code components (External System Domain, ESD) The Various Tools of OPNET Source code editing environment Network model editor Node model editor Process model editor Antenna pattern editor Modulation curve editor (SNR BER behavior) Packet format editor Analysis configuration tool Simulation tool ICI editor (Interface Control Information) Probe model tool (organization of result collection) Link model editor (properties of fixed link models) Path model editor (for routing and modeling virtual circuits) Demand model editor (wide scale application modeling) OPNET Animation viewer
55
GloMoSim
Global Mobile Information System Simulator (GloMoSim) is a scalable simulation environment for large wireless and wireline communication networks [1]. GloMoSim uses a parallel discrete-event simulation capability provided by Parsec. GloMoSim simulates networks with up to thousand nodes linked by a heterogeneous communications capability that includes multicast, asymmetric communications using direct satellite broadcasts, multi-hop wireless communications using ad-hoc networking, and traditional Internet protocols. The following table lists the GloMoSim models currently available at each of the major layers:
VTT TECHNICAL RESEARCH CENTRE OF FINLAND The node aggregation technique is introduced into GloMoSim to give signicant benets to the simulation performance. Initializing each node as a separate entity inherently limits the the scalability because the memory requirements increase dramatically for a model with large number of nodes. With node aggregation, a single entity can simulate several network nodes in the system. Node aggregation technique implies that the number of nodes in the system can be increased while maintaining the same number of entities in the simulation. In GloMoSim, each entity represents a geographical area of the simulation. Hence the network nodes which a particular entity represents are determined by the physical position of the nodes.
Use of GloMoSim Simulator After successfully installing GloMoSim, a simulation can be started by executing the following command in the BIN subdirectory. ./glomosim < inputfile >
56
The Visualization Tool GloMoSim has a Visualization Tool that is platform independent because it is coded in Java. To initialize the Visualization Tool, we must execute from the java gui directory the following: java GlomoMain. This tool allows to debug and verify models and scenarios; stop, resume and step execution; show packet transmissions, show mobility groups in dierent colors and show statistics. The radio layer is displayed in the Visualization Tool as follows: When a node transmits a packet, a yellow link is drawn from this node to all nodes within it's power range. As each node receives the packet, the link is erased and a green line is drawn for successful reception and a red line is drawn for unsuccessful reception. No distinction is made between dierent packet types (ie: control packets vs. regular pacekts, etc) Basic Configuration File (Config.in) The main conguration parameters for setting up an scenario are dened in the CONFIG.IN file. These parameters are the following:
The default values of these parameters in the CONFIG.IN file are: SIMULATION-TIME 15M SEED 1 TERRAIN-DIMENSIONS (2000, 2000) NUMBER-OF-NODES 30
The NODE-PLACEMENT parameter can be assigned the following values: RANDOM (nodes are placed randomly within the physical terrain), UNIFORM (based on the number of nodes in the simulation, the physical terrain is divided into a number of cells. Within each cell, a node is placed randomly), GRID (Node placement starts at
57
0,0 and are placed in grid format with each node GRID-UNIT away from its neighbors, the number of nodes has to be square of an integer) and FILE (Position of nodes is read from NODE- PLACEMENT-FILE). The default values of these parameters in the CONFIG.IN file and an example of the NODES.INPUT file are: # NODE-PLACEMENT FILE # NODE-PLACEMENT-FILE ./nodes.input # NODE-PLACEMENT GRID # GRID-UNIT 30 # NODE-PLACEMENT RANDOM NODE-PLACEMENT UNIFORM # Example of the NODES.IN file # Format: nodeAddr 0 (x, y, z) # The second parameter is for consistency with the mobility trace format 0 0 (20.2, 0.9, 0.11) 1 0 (20.3, 30.8, 0.01) 2 0 (20.4, 60.7, 0.12) If the MOBILITY parameter is set to NONE then there is no movement of nodes in the model.
Result: Thus the network simulators such as NS2/Glomosim / OPNET were studied.
58