NETWORK - LAB Old PDF
NETWORK - LAB Old PDF
ARASUR
(SEMESTER - V)
PAGE
S.No. TITLE
No.
1. Study of ISO/OSI Network Model 3
6. Chat Application 33
9. Downloading a File 50
Appendix 67
-2-
1. STUDY OF ISO/OSI NETWORK MODEL
INTRODUCTION:
PHYSICAL LAYER:
The Physical layer concerns itself with the transmission of bits and the
network card's hardware interface to the network. The hardware interface involves the
type of cabling (coax, twisted pair, etc..), frequency of operation (1 Mbps, 10Mbps,
etc..), voltage levels, cable terminations, topography (star, bus, ring, etc..), etc..
Examples of Physical layer protocols are 10Base5 - Thicknet, 10Base2 - Thinnet,
10BaseT - twisted pair, ArcNet, FDDI, etc...
-3-
DATA LINK LAYER:
The Data Link layer is a firmware layer of the network interface card. The
Data Link layer puts the datagram into packets (frames of bits: 1s & 0s) for
transmission and assembles received packets into datagram. The Data Link layer
works at the bit level and adds start/stop flags and bit error checking (CRC or parity)
to the packet frame. Error checking is at the bit level only, packets with errors are
discarded and a request for re-transmission is sent out. The Data Link layer is
concerned about bit sequence.
NETWORK LAYER:
The Network layer is concerned about the path through the network. It is
responsible for routing, switching and controlling the flow of information between
hosts. The Network layer converts the segments into smaller datagram that the
network can handle. The Network layer does not guarantee that the datagram will
reach its destination. The network hardware source and destination addresses are
added.
-4-
TRANSPORT LAYER:
In order for the data to be sent across the network, the file must be broken up
into usable small data segments (typically 512 - 18K bytes). The Transport layer
breaks up the file into segments for transport to the network and combines incoming
segments into a contiguous file. The Transport layer does this logically not physically;
it is done in software as opposed to hardware. The Transport layer provides error
checking at the segment level (frame control sequence). This checks that the datagram
are in the correct order and the Transport layer will correct out of order datagram. The
Transport layer guarantees an error-free host to host connection; it is not concerned
with the path between machines.
SESSION LAYER:
The Session layer manages the communications between the
workstation and network. The Session layer directs the information to the correct
destination and identifies the source to the destination. The Session layer identifies the
type of information as data or control. The Session layer manages the initial start-up
of a session and the orderly closing of a session. The Session layer also manages
Logon procedures and Password recognition.
-5-
PRESENTATION LAYER:
It converts local representation of data to its canonical form and vice
versa. The Presentation Layer also controls security at the file level. This provides file
locking and user security. It performs specific functions that are requested regularly
by applications. For example: encryption, ASCII to Unicode, Unicode to ASCII,
LSB-first representations to MSB-first representations
APPLICATION LAYER:
It provides network services to the end-users. Mail, ftp, telnet, DNS,
NIS, NFS are examples of network applications. Application layer protocols are
Application-dependent. It implements communication between two applications of
the same type. (Examples: FTP, HTTP, SMTP (email) etc…).
-6-
SUMMARY OF LAYERS:
CONCLUSION:
Thus the seven different layers of ISO/OSI model with their functionalities
were studied successfully.
-7-
2. UNIX SOCKET PROGRAMMING
INTRODUCTION:
SOCKET:
The server and client applications use various system calls to connect which
use the basic construct called socket. A socket is one end of the communication
channel between two applications running on different machines.
Domain Description
AF_INET IPv4 Internet domain
AF_INET6 IPv6 Internet domain
AF_UNIX UNIX domain
AF_UNSPEC unspecified
SOCKET TYPES:
Type Description
SOCK_DGRAM fixed-length, connectionless, unreliable messages.
(IPPROTO_UDP – protocol used for UDP)
SOCK_RAW datagram interface to IP (optional in POSIX.1)
SOCK_SEQPACKET fixed-length, sequenced, reliable, connection-oriented messages
ADDRESS FORMATS:
-8-
struct sockaddr {
sa_family_t sa_family; /* address family */
char sa_data[14]; /* variable-length address */
};
struct sockaddr_in {
sa_family_t sin_family; /* address family */
in_port_t sin_port; /* port number */
struct in_addr sin_addr; /* IPv4 address */
unsigned char sin_zero[8]; /* filler */
};
BYTE ORDERING:
#include <arpa/inet.h>
SYSTEM CALLS:
1. socket()
a. Synopsis:
#include<sys/types.h>
#include<sys/socket.h>
int socket(int domain, int type, int protocol);
#include<sys/socket.h>
int bind ( int sockfd , struct sockaddr *myaddr , int addrlen );
-9-
b. Description: Associates an address to a socket descriptor created by
socket.
3. listen()
a. Synopsis:
#include<sys/socket.h>
int listen(int skfd, int backlog);
#include<sys/socket.h>
#include<netinet/in.h>
int connect(int skfd, struct sockaddr* addr, int addrlen);
#include<sys/socket.h>
int accept(int skfd, struct sockaddr* addr, int addrlen);
#include<sys/socket.h>
int close(int skfd);
- 10 -
CONNECTIONLESS COMMUNICATION:
Packets are sent at a time to a particular destination. For greater reliability, the
receiver may send an acknowledgement.
CONCLUSION:
Thus the various concepts behind UNIX socket programming was studied
successfully.
- 11 -
3. BIT STUFFING AND CRC COMPUTATION
AIM:
To write and execute a C program that takes a binary input file as input and
performs Bit Stuffing and Cyclic Redundancy Check (CRC) Computation.
GENERAL ALGORITHM:
1. Start.
2. Read the input binary number and divisor from the input files.
(BIT STUFFING: FROM STEP 3 to STEP 4).
3. Insert a 0 after each consecutive five 1s.
4. Append a string of n 0s, where n is one less than the number of bits in the
divisor.
5. Display the bit stuffed data.
(CRC GENERATION: FROM STEP 5 TO STEP 8).
6. Divide the newly elongated data unit by the divisor (use binary division)
and the resultant remainder is called CRC of n bits.
7. Display the CRC value.
8. Replace the appended 0s by the CRC derived in Step 5.
9. Display the newly elongated data unit, along with CRC.
(CRC CHECKER: FROM STEP 9 TO STEP 15).
10. Divide the newly elongated data unit by the divisor (use binary division).
11. Display the remainder.
12. Replace the appended CRC by the newly generated remainder to the data
unit.
13. Display the newly elongated data unit.
(DESTUFFING).
14. Remove the appended remainder.
15. Remove the 0s inserted after each five consecutive 1s.
16. Display the resultant data unit which is same as the one taken as input.
17. Stop.
- 12 -
PROGRAM FOR BIT STUFFING AND CRC
//bitstuf.c
#include<stdio.h>
#include<conio.h>
void crc();
void display_rem();
int ip[20],n,i,j,k,fives=0,ndiv,div[20],t,inter[50],times=1,set=0;
void main()
{
FILE *fp,*fp1;
fp=fopen("INPUT.DAT","r");
fp1=fopen("DIV.DAT","r");
printf("\nINPUT BINARY NUMBER\t: ");
i=0;
do
{
fscanf(fp,"%d",&ip[i]);
printf("%d ",ip[i]);
i++;
}while(!feof(fp));
n=i;
printf("\n\nDIVISOR\t\t\t: ");
i=0;
do
{
fscanf(fp1,"%d",&div[i]);
printf("%d ",div[i]);
i++;
}while(!feof(fp1));
ndiv=i;
printf("\n");
fclose(fp);
fclose(fp1);
for(i=0;i<(n+set);i++)
{
if(ip[i]==1)
fives++;
else
fives=0;
if(fives==5)
{
fives=0;
for(j=(n+set);j>i;j--)
ip[j]=ip[j-1];
ip[i+1]=0;
set++;
- 13 -
}
}
j=0;
for(i=(n+set);j<(ndiv-1);i++,j++)
ip[i]=0;
printf("\nAFTER BIT STUFFING\t: ");
for(i=0;i<(n+ndiv+set-1);i++)
printf("%d ",ip[i]);
printf("\n");
crc();
display_rem();
printf("\nAFTER 1 CRC\t\t: ");
for(i=0;i<(n+ndiv+set-1);i++)
printf("%d ",ip[i]);
printf("\n");
times++;
crc();
display_rem();
printf("\nAFTER 2 CRC\t\t: ");
for(i=0;i<(n+ndiv+set-1);i++)
printf("%d ",ip[i]);
printf("\n");
fives=0;
printf("\nAFTER DESTUFFING\t: ");
for(i=0;i<(n+set);i++)
{
if(ip[i]==1)
fives++;
else
fives=0;
if(fives==5)
{
fives=0;
for(j=i+1;j<(n+set);j++)
ip[j]=ip[j+1];
}
}
for(i=0;i<n;i++)
printf("%d ",ip[i]);
printf("\n\n");
}
void crc()
{
for(i=0;i<(ndiv-1);i++)
inter[i]=ip[i];
j=0;
for(i=ndiv;i<=(ndiv+n+set-1);i++)
{
t=0;
- 14 -
if(i!=ndiv)
{
inter[k]=ip[i-1];
j++;
}
for(k=j;t<(ndiv-1);k++)
{
if(div[t]==inter[k])
inter[k]=0;
else
inter[k]=1;
t++;
}
}
}
void display_rem()
{
j=0;
printf("\nREMAINDER OF %d CRC\t: ",times);
t=k-(ndiv-1);
for(i=(n+set);j<(ndiv-1);i++,j++)
{
ip[i]=inter[t];
printf("%d ",inter[t]);
t++;
}
printf("\n");
}
- 15 -
INPUT FILES
INPUT.DAT
1111101
DIV.DAT
111
OUTPUT
DIVISOR :111
[student@ws002 netlab]$
RESULT:
Thus the program for CRC and Bit Stuffing was worked out and the outputs
were generated and verified successfully.
- 16 -
4. SIMULATION OF ARP/RARP
AIM:
To develop a C program in Linux to simulate the Address Resolution Protocol
(ARP) and Reverse Address Resolution Protocol (RARP).
GENERAL ALGORITHM:
1. Start.
2. Specify the IP Addresses and Ethernet Addresses.
3. Create a LINUX Socket using socket () with proper arguments, which returns
a socket descriptor.
4. Set the port number for each of the three processes of arp-rarp programs.
5. Bind the path to the socket created, by calling the function bind () with proper
arguments.
6. Create a child process using fork ().
7. Receive the Ethernet or IP address request from the other processes.
8. Send the corresponding IP or Ethernet addresses reply to the requested
process.
9. Send the Ethernet or IP address request to the other processes.
10. Receive the corresponding IP or Ethernet address reply from the other
processes.
11. Terminate the connection using close ().
12. Stop.
- 17 -
PROGRAM FOR ARP / RARP
//arp1.c
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<fcntl.h>
#include<netinet/in.h>
main()
{
int sd,len=0,sz,i,k=0;
struct sockaddr_in s1,s2,s3;
char str[30]="",string[30]="",addr[30]="",status[10]="";
char
ip[10][20]={"127.0.0.1","127.0.0.2","127.0.0.3","127.0.0.4","127.0.0.5","127.0.0.6","
127.0.0.7","127.0.0.8","127.0.0.9","127.0.0.10"};
char
eth[10][20]={"12.32.45.0.0.1","12.32.45.0.0.2","12.32.45.0.0.3","12.32.45.0.0.4","12.
32.45.0.0.5","12.32.45.0.0.6","12.32.45.0.0.7","12.32.45.0.0.8","12.32.45.0.0.9","12.3
2.45.0.0.10"};
sd=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
s1.sin_port=htons(1101);
s1.sin_family=s2.sin_family=s3.sin_family=AF_INET;
s1.sin_addr.s_addr=s2.sin_addr.s_addr=s3.sin_addr.s_addr=htonl(INADDR_ANY);
s2.sin_port=htons(2202);
s3.sin_port=htons(3303);
if(bind(sd,(struct sockaddr*)&s1,sizeof(s1))<0)
{
printf("Bind error\n");
return 0;
}
sz=sizeof(s2);
if(fork()==0)
while(1)
{
fcntl(sd,F_SETFL,O_NONBLOCK);
recvfrom(sd,&str,30,0,(struct sockaddr*)&s2,&sz);
if(strcmp(str,"\0"))
{
k=2;
goto s;
}
recvfrom(sd,&str,30,0,(struct sockaddr*)&s3,&sz);
k=3;
s:if(strcmp(str,"\0"))
{
printf("%s\n",str);
strcpy(addr,str);
- 18 -
strcpy(str,"\0");
strncpy(str,addr,strlen(addr)-8);
str[strlen(addr)-8]='\0';
for(i=0;i<9;i++)
status[i]=addr[strlen(str)+i];
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
strcpy(string,eth[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
if(!strcmp(str,eth[i]))
{
strcpy(string,ip[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
}
}
strcpy(str,"\0");
k=0;
}
else
while(1)
{
int flg=0;
scanf("%s",str);
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
printf("%sTo Reply\n",eth[i]);
flg=1;
}
- 19 -
if(!strcmp(str,eth[i]))
{
printf("%sTo Reply\n",ip[i]);
flg=1;
}
}
if(flg)
continue;
strcat(str," Request");
sendto(sd,&str,30,0,(struct sockaddr*)&s2,sizeof(s2));
sendto(sd,&str,30,0,(struct sockaddr*)&s3,sizeof(s3));
}
close(sd);
}
//arp2.c
#include<sys/socket.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<fcntl.h>
#include<netinet/in.h>
main()
{
int sd,len=0,sz,i,k=0;
struct sockaddr_in s1,s2,s3;
char str[30]="",string[30]="",addr[30]="",status[10]="";
char
ip[10][20]={"128.0.0.1","128.0.0.2","128.0.0.3","128.0.0.4","128.0.0.5","128.0.0.6","
128.0.0.7","128.0.0.8","128.0.0.9","128.0.0.10"};
char
eth[10][20]={"13.32.45.0.0.1","13.32.45.0.0.2","13.32.45.0.0.3","13.32.45.0.0.4","13.
32.45.0.0.5","13.32.45.0.0.6","13.32.45.0.0.7","13.32.45.0.0.8","13.32.45.0.0.9","13.3
2.45.0.0.10"};
sd=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
s1.sin_port=htons(2202);
s1.sin_family=s2.sin_family=s3.sin_family=AF_INET;
s1.sin_addr.s_addr=s2.sin_addr.s_addr=s3.sin_addr.s_addr=htonl(INADDR_ANY);
s2.sin_port=htons(3303);
s3.sin_port=htons(1101);
if(bind(sd,(struct sockaddr*)&s1,sizeof(s1))<0)
{
printf("Bind error\n");
return 0;
}
sz=sizeof(s2);
if(fork()==0)
- 20 -
while(1)
{
fcntl(sd,F_SETFL,O_NONBLOCK);
recvfrom(sd,&str,30,0,(struct sockaddr*)&s2,&sz);
if(strcmp(str,"\0"))
{
k=2;
goto s;
}
recvfrom(sd,&str,30,0,(struct sockaddr*)&s3,&sz);
k=3;
s:if(strcmp(str,"\0"))
{
printf("%s\n",str);
strcpy(addr,str);
strcpy(str,"\0");
strncpy(str,addr,strlen(addr)-8);
str[strlen(addr)-8]='\0';
for(i=0;i<9;i++)
status[i]=addr[strlen(str)+i];
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
strcpy(string,eth[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
if(!strcmp(str,eth[i]))
{
strcpy(string,ip[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
}
}
- 21 -
strcpy(str,"\0");
k=0;
}
else
while(1)
{
int flg=0;
scanf("%s",str);
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
printf("%sTo Reply\n",eth[i]);
flg=1;
}
if(!strcmp(str,eth[i]))
{
printf("%sTo Reply\n",ip[i]);
flg=1;
}
}
if(flg)
continue;
strcat(str," Request");
sendto(sd,&str,30,0,(struct sockaddr*)&s2,sizeof(s2));
sendto(sd,&str,30,0,(struct sockaddr*)&s3,sizeof(s3));
}
close(sd);
}
//arp3.c
#include<sys/socket.h>
#include<unistd.h>
#include<string.h>
#include<sys/types.h>
#include<fcntl.h>
#include<netinet/in.h>
main()
{
int sd,len=0,sz,i,k=0;
struct sockaddr_in s1,s2,s3;
char str[30]="",string[30]="",addr[30]="",status[10]="";
char
ip[10][20]={"129.0.0.1","129.0.0.2","129.0.0.3","129.0.0.4","129.0.0.5","129.0.0.6","
129.0.0.7","129.0.0.8","129.0.0.9","129.0.0.10"};
char
eth[10][20]={"14.32.45.0.0.1","14.32.45.0.0.2","14.32.45.0.0.3","14.32.45.0.0.4","14.
- 22 -
32.45.0.0.5","14.32.45.0.0.6","14.32.45.0.0.7","14.32.45.0.0.8","14.32.45.0.0.9","14.3
2.45.0.0.10"};
sd=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
s1.sin_port=htons(3303);
s1.sin_family=s2.sin_family=s3.sin_family=AF_INET;
s1.sin_addr.s_addr=s2.sin_addr.s_addr=s3.sin_addr.s_addr=htonl(INADDR_ANY);
s2.sin_port=htons(1101);
s3.sin_port=htons(2202);
if(bind(sd,(struct sockaddr*)&s1,sizeof(s1))<0)
{
printf("Bind error\n");
return 0;
}
sz=sizeof(s2);
if(fork()==0)
while(1)
{
fcntl(sd,F_SETFL,O_NONBLOCK);
recvfrom(sd,&str,30,0,(struct sockaddr*)&s2,&sz);
if(strcmp(str,"\0"))
{
k=2;
goto s;
}
recvfrom(sd,&str,30,0,(struct sockaddr*)&s3,&sz);
k=3;
s:if(strcmp(str,"\0"))
{
printf("%s\n",str);
strcpy(addr,str);
strcpy(str,"\0");
strncpy(str,addr,strlen(addr)-8);
str[strlen(addr)-8]='\0';
for(i=0;i<9;i++)
status[i]=addr[strlen(str)+i];
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
strcpy(string,eth[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
- 23 -
if(!strcmp(str,eth[i]))
{
strcpy(string,ip[i]);
strcat(string,"To Reply");
if(!strcmp(status," Request"))
{
if(k==2)
sendto(sd,&string,30,0,(struct sockaddr*)&s2,sizeof(s2));
else
sendto(sd,&string,30,0,(struct sockaddr*)&s3,sizeof(s3));
break;
}
}
}
}
strcpy(str,"\0");
k=0;
}
else
while(1)
{
int flg=0;
scanf("%s",str);
for(i=0;i<10;i++)
{
if(!strcmp(str,ip[i]))
{
printf("%sTo Reply\n",eth[i]);
flg=1;
}
if(!strcmp(str,eth[i]))
{
printf("%sTo Reply\n",ip[i]);
flg=1;
}
}
if(flg)
continue;
strcat(str," Request");
sendto(sd,&str,30,0,(struct sockaddr*)&s2,sizeof(s2));
sendto(sd,&str,30,0,(struct sockaddr*)&s3,sizeof(s3));
}
close(sd);
}
- 24 -
OUTPUT
RUNNING arp1.c :
[student@ws002arp]$cc arp1.c
[student@ws002 arp]$./a.out
127.0.0.5
12.32.45.0.0.5To Reply
128.0.0.7
13.32.45.0.0.7To Reply
129.0.0.1 Request
12.32.45.0.0.6 Request
[student@ws002 arp]$
RUNNING arp2.c :
RUNNING arp3.c :
RESULT:
Thus the program to simulate ARP-RARP was worked out and the outputs
were generated successfully.
- 25 -
5. SIMULATION OF SLIDING WINDOW PROTOCOL
AIM:
To write and execute a C program in Linux to simulate the Sliding Window
Protocol.
1. Start.
2. Create a LINUX Server Socket using socket () with proper arguments,
which returns a socket descriptor.
3. If socket descriptor < 0, then print the error message that socket can not be
created and exit.
4. Bind the path to the socket created, by calling the function bind () with
proper arguments.
5. If bind () returns a value < 0, then print the error message that can not bind
the socket with the path and exit.
6. Instruct the socket to listen for incoming connections from client
programs, by using listen () with proper arguments.
7. If listen () returns a value < 0, then print the error message that server can
not listen to the clients and exit.
8. Accept a connection from a client by using accept () with proper
arguments which returns another socket descriptor!
9. If the new descriptor < 0, then print the error message that server can not
accept any connection and exit.
10. Scan the string to be transmitted
11. Repeat the following steps until the length of the string:
a) The first four characters of the string is displayed and it is sent to
client, using write().
b) From the client receive whether to insert errors and if so, get the bit
position for inserting error.
c) If there’s error, retransmit from the bit error has inserted, to the client.
12. Terminate the connection using close ().
13. Stop.
- 26 -
GENERAL ALGORITHM FOR SLIDING WINDOW CLIENT:
1. Start.
2. Create a LINUX Socket using socket () with proper arguments, which
returns a socket descriptor.
3. If socket descriptor < 0, then print the error message that socket can not be
created and exit.
4. Initiate a connection to the server's socket by a call to connect ().
- 27 -
PROGRAM FOR SLIDING WINDOW SERVER
//server.c
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<string.h>
#define SERV_TCP_PORT 9888
int main ( )
{
char p[ 15 ],q[ 25 ],r[ 15 ],s[ 15 ];
int sockfd,newsockfd,clilen,i=1,j,k,n;
struct sockaddr_in caddr,saddr ;
char c;
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
perror( "Server:Socket Error");
bzero((char*)&saddr,sizeof(saddr));
saddr.sin_family=AF_INET ;
saddr.sin_addr.s_addr=htonl(INADDR_ANY);
saddr.sin_port=htons(SERV_TCP_PORT);
if((bind(sockfd,(struct sockaddr*)&saddr,sizeof(saddr)))<0)
perror("Server:Bind Error");
listen(sockfd,5);
clilen=sizeof(caddr);
if((newsockfd=accept(sockfd,(struct sockaddr*)&caddr,&clilen))<0)
perror("Server:Accept Error");
printf("Enter the string to be transmaitted\n");
scanf("%s",q);
for(i=0;i<strlen(q);i+=4)
{
strcpy(p,"");
for(j=0;j<4;j++)
{
if((i+j)==strlen(q))
{
for(k=0;k<3;k++)
if(((j+k)%4))
p[j+k]=' ';
else
{
j=j+k+1;
break;
}
}
p[j]=q[i+j];
}
p[j]='\0';
- 28 -
p[strlen(p)]='\0';
printf("\nThe Frame to be transmitted is %s",p );
write(newsockfd,p,strlen(p)+1);
read(newsockfd,s,5);
sscanf(s,"%d",&n);
if(n==-1)
puts("\nNo Error has occured!!!");
else
{
printf("\nAn Error has occured in position %d \n ",n );
for(j=n;j<4;j++)
r[j-n]=p[ j ];
r[j-n]='\0';
strcat(r," ");
n=strlen(r);
for(j=0;j<n-1;j++)
r[n+j]=s[n+j-1+i];
r[n+j]='\0';
puts("\nRetransmitting!!!");
write(newsockfd,r,strlen(r)+1);
}
}
write(newsockfd,p,strlen(p)+1);
puts("\nterminated!!!");
close(newsockfd);
close(sockfd );
}
- 29 -
PROGRAM FOR SLIDING WINDOW CLIENT
// client.c
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include<string.h>
#define SERV_TCP_PORT 9888
int main()
{
char p[25],q[25];
int sockfd,flag=1,n,c,i;
struct sockaddr_in saddr;
FILE *fp;
bzero((char*)&saddr,sizeof(saddr));
saddr.sin_family= AF_INET;
saddr.sin_addr.s_addr=inet_addr("127.0.0.1");
saddr.sin_port=htons( SERV_TCP_PORT);
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
perror("Client::Socket Error");
if((connect(sockfd,(struct sockaddr*)&saddr,sizeof(saddr)))<0)
perror("Client::Connect Error");
while(1)
{
read(sockfd,q,25);
printf("the received Frame is %s\n ",q );
puts("Do u want to insert an error or not ( 1 - yes/0 - no)?");
scanf("%d",&c);
if(c)
{
puts("Enter the bit position you want to enter the error");
scanf("%d",&n);
sprintf(p,"%d",n);
write(sockfd,p,strlen(p)+1);
read(sockfd,q,25);
printf("The Retransmitted frame is %s \n ",q);
}
else
{
puts("No error");
n=-1;
sprintf(p,"%d",n);
write(sockfd,p,strlen(p)+1);
}
}
- 30 -
puts("Connection terminated");
close(sockfd);
return 0;
}
- 31 -
OUTPUT
SERVER SIDE:
Retransmitting!!!
terminated!!!
[student@ws002 slide]$
CLIENT SIDE:
RESULT:
Thus the program for the simulation of Sliding Window Protocol was worked
out and the outputs were generated and verified successfully.
- 32 -
6. CHAT APPLICATION
AIM:
To develop a C program in Linux for the Client - Server Application for Chat
in C.
1. Start.
2. Create a LINUX Server Socket using socket () with proper arguments,
which returns a socket descriptor.
3. If socket descriptor < 0, then print the error message that socket can not be
created and exit.
4. Bind the path to the socket created, by calling the function bind () with
proper arguments.
5. If bind () returns a value < 0, then print the error message that can not bind
the socket with the path and exit.
6. Instruct the socket to listen for incoming connections from client
programs, by using listen () with proper arguments.
7. If listen () returns a value < 0, then print the error message that server can
not listen to the clients and exit.
8. Accept a connection from a client by using accept () with proper
arguments which returns another socket descriptor! The old descriptor is
still listening for new connections, but this new one is connected to the
client.
9. If the new descriptor < 0, then print the error message that server can not
accept any connection and exit.
10. Read the string from the client using read ().
11. Print the client message.
12. Send reply message to the client using write ().
13. Listen for the client message and read it from the client.
14. Repeat the steps from 10 to 12 until server or client says bye.
15. Terminate the connection using close ().
16. Stop.
- 33 -
GENERAL ALGORITHM FOR CHAT CLIENT:
1. Start.
2. Create a LINUX Socket using socket () with proper arguments, which
returns a socket descriptor.
3. If socket descriptor < 0, then print the error message that socket can not be
created and exit.
4. Initiate a connection to the server's socket by a call to connect ().
- 34 -
PROGRAM FOR CHAT SERVER
//server.c
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<netinet/in.h>
#include<unistd.h>
#define SER_PORT 8888
int main()
{
int a,sersock,newsock,n;
char str[25],str2[25];
struct sockaddr_in seraddr;
struct sockaddr_in cliinfo;
socklen_t esize=sizeof(cliinfo);
seraddr.sin_family=AF_INET;
seraddr.sin_port=htons(SER_PORT);
seraddr.sin_addr.s_addr=htonl(INADDR_ANY);
if((sersock=socket(AF_INET,SOCK_STREAM,0))<0)
{
error("SOCKET CANNOT BE CREATED\n");
exit(0);
}
else
printf("\n SOCKET CREATED SUCCESSFULLY\n");
if(bind(sersock,(struct sockaddr*)&seraddr,sizeof(seraddr))<0)
{
error("CANT BIND\n");
exit(0);
}
if(listen(sersock,1)<0)
{
error("CANT LISTEN");
exit(0);
}
else
printf("\n SERVER IS LISTENING\n");
if((newsock=accept(sersock,(struct sockaddr*)&cliinfo,&esize))<0)
{
error("CANT ACCEPT\n");
exit(0);
}
else
printf("\n CONNECTION ESTABLISHED WITH CLIENT\n");
read(newsock,str,sizeof(str));
- 35 -
do
{
printf("\n CLIENT:%s\n",str);
printf("\n SERVER:");
scanf("%s",&str2);
printf("\n");
write(newsock,str2,sizeof(str2));
listen(newsock,1);
read(newsock,str,sizeof(str));
n=strcmp(str,"bye");
a=strcmp(str2,"bye");
}
while(n!=0||a!=0);
close(newsock);
close(sersock);
return 0;
}
- 36 -
PROGRAM FOR CHAT CLIENT
//client.c
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<netinet/in.h>
#include<unistd.h>
#define SER_PORT 8888
int main()
{
int a,disock;
char str[25],str2[25];
struct sockaddr_in diaddr;
diaddr.sin_family=PF_INET;
diaddr.sin_port=htons(SER_PORT);
diaddr.sin_addr.s_addr=htonl(INADDR_ANY);
if((disock=socket(PF_INET,SOCK_STREAM,0))<0)
{
perror("SOCKET\n");
exit(0);
}
else
printf("\n SOCKET CREATED SUCCESSFULLY\n");
if(connect(disock,(struct sockaddr*)&diaddr,sizeof(diaddr))<0)
{
perror("connect\n");
exit(0);
}
printf("\n CONNECTION ESTABLISHED WITH SERVER\n");
printf("\n CLIENT:");
scanf("%s",str);
printf("\n");
if(write(disock,str,sizeof(str))<0)
{
printf("\n DATA NOT SENT\n");
}
do
{
listen(disock,1);
read(disock,str,sizeof(str));
printf("\n SERVER:%s\n",str);
printf("\n CLIENT:");
scanf("%s",&str2);
printf("\n");
- 37 -
a=strcmp(str2,"bye");
write(disock,str2,sizeof(str2));
}
while(a!=0);
close(disock);
return 0;
}
- 38 -
OUTPUT
SERVER SIDE:
SERVER IS LISTENING
CLIENT: Hi
SERVER: Hello
CLIENT: bye
SERVER: bye
[student@ws002 chat]$
CLIENT SIDE:
CLIENT:Hi
SERVER:Hello
CLIENT:bye
[student@ws002 chat]$
RESULT:
Thus the Client – server application for Chat was worked out and the output
was generated and verified successfully.
- 39 -
7. SIMULATION OF OSPF ROUTING PROTOCOL
AIM:
To write and execute a C program to simulate the OSPF Routing Protocol.
GENERAL ALGORITHM:
1. Start.
2. Open the input file in read mode and display the adjacent matrix.
3. Close the input file.
4. While the condition is true, repeat the following:
a) Get the source node for which the routing table is to be displayed.
b) For each node, do the following:
5. Stop.
- 40 -
PROGRAM FOR OSPF PROTOCOL
//ospf.c
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#define MAX 30
#define UNVISITED -1
#define VISITED 1
#define INFINITY 32767
int adjMat[MAX][MAX],n;
void viewAdjMat();
void viewPathMat(int pm[MAX],int n,int len);
int searchPath(int src,int des,int pathmat[MAX],int *minLen);
typedef struct
{
int previous,len,status;
}node;
void main()
{
char ch,s,d;
int i,j,k,src,des,minLen,tot,pathMat[MAX];
FILE *f1;
n=7;
clrscr();
printf("\n The number of vertices of Weighted Graph: %d\n\n",n);
//scanf("%d",&n);
if((f1=fopen("input.txt","rt"))==NULL)
{
fprintf(stderr,"Cannot open input file.\n");
return;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
fscanf(f1,"%d",&adjMat[i][j]);
fclose(f1);
printf("\n The adjacency matrix is . . .\n");
printf(“\n\t A B C D E F G \n”);
viewAdjMat();
while(1)
{
printf("\n\n Enter the Source Node:");
fflush(stdin);
scanf("%c",&s);
src=toupper(s)-64;
printf("\t DES \t COST \t NR\n");
for(i=1;i<=n;i++)
{
tot=searchPath(src,i,pathMat,&minLen);
- 41 -
printf("\t%c\t%d\t",i+64,minLen);
if(src==i)
printf("-\n");
else
printf("%c\n",pathMat[tot-1]+64);
}
printf("\n Do u want to continue (Y/N):");
ch=getche();
if(ch!='Y'&&ch!='y')
break;
}
}
void viewAdjMat()
{
int i,j;
printf("\n");
for(i=1;i<=n;i++)
{
printf("\n\n");
for(i=1;i<=n;i++)
{
printf("\n\n");
for(j=1;j<=n;j++)
{
if(j==1)
printf("%4c",i+64);
printf("%4d",adjMat[i][j]);
}
}
}
}
int searchPath(int src,int des,int pathMat[MAX],int *minLen)
{
node graph[MAX];
int i,k,min,tot=0,curVertex,newLen,u,v;
*minLen=0;
for(i=1;i<=n;i++)
{
graph[i].previous=0;
graph[i].len=INFINITY;
graph[i].status=UNVISITED;
}
graph[src].previous=0;
graph[src].len=0;
graph[src].status=VISITED;
curVertex=src;
while(curVertex!=des)
{
for(k=1;k<=n;k++)
{
- 42 -
if(adjMat[curVertex][k]>0&&graph[k].status==UNVISITED)
{
newLen=graph[curVertex].len+adjMat[curVertex][k];
if(newLen<graph[k].len)
{
graph[k].previous=curVertex;
graph[k].len=newLen;
}
}
}
min=INFINITY;
curVertex=0;
for(i=1;i<=n;i++)
if(graph[i].status==UNVISITED&&graph[i].len<min)
{
min=graph[i].len;
curVertex=i;
}
if(curVertex==0)
return 0;
graph[curVertex].status=VISITED;
}
while(curVertex!=0)
{
pathMat[++tot]=curVertex;
curVertex=graph[curVertex].previous;
}
for(i=tot;i>1;i--)
{
u=pathMat[i];
v=pathMat[i-1];
*minLen=*minLen+adjMat[u][v];
}
return(tot);
}
- 43 -
INPUT FILE
//INPUT.TXT
0 2 0 1 0 0 0
0 0 0 3 10 0 0
4 0 0 0 0 5 0
0 0 2 0 2 8 0
0 0 0 0 0 0 6
0 0 0 0 0 0 0
0 0 0 0 0 1 0
- 44 -
OUTPUT
A B C D E F G
A 0 2 0 1 0 0 0
B 0 0 0 3 10 0 0
C 4 0 0 0 0 5 0
D 0 0 2 0 2 8 0
E 0 0 0 0 0 0 6
F 0 0 0 0 0 0 0
G 0 0 0 0 0 1 0
DES COST NR
A 0 -
B 2 B
C 3 D
D 1 D
E 3 D
F 8 D
G 9 D
RESULT:
Thus the program for the simulation of OSPF routing protocol was worked
out and the output (shortest path) was generated successfully.
- 45 -
8. DOMAIN NAMING SYSTEM
AIM:
To develop a Client, in C, that contacts a given DNS Server to resolve a given
host name.
1. Start.
2. Create a LINUX Server Socket using socket () with proper arguments,
which returns a socket descriptor.
3. Bind the path to the socket created, by calling the function bind () with
proper arguments.
4. Instruct the socket to listen for incoming connections from client
programs, by using listen () with proper arguments.
5. Accept a connection from a client by using accept () with proper
arguments which returns another socket descriptor! The old descriptor is
still listening for new connections, but this new one is connected to the
client.
6. Read the domain name from the client using read() with proper arguments.
7. Search the host address for the given domain name .
8. Write the host address to the client using write () with proper arguments.
9. Terminate the connection using close ().
10. Stop.
1. Start.
2. Create a LINUX Socket using socket () with proper arguments, which
returns a socket descriptor.
3. Initiate a connection to the server's socket by a call to connect ().
4. Scan the domain name from the user and send it to the server.
5. Read the host address from the server and display it.
6. Stop.
- 46 -
PROGRAM FOR DNS SERVER
//server.c
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include<stdio.h>
#include<netdb.h>
#include<string.h>
#define TCP_SERV_PORT 7890
int main()
{
int listenfd,connfd;
socklen_t len;
struct sockaddr_in servaddr,cliaddr;
struct hostent *hp,tp;
char host[50],buff[100];
listenfd=socket(AF_INET,SOCK_STREAM,0);
bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family=AF_INET;
servaddr.sin_port=htons(7TCP_SERV_PORT);
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
bind(listenfd,(struct sockaddr*)&servaddr,sizeof(servaddr));
listen(listenfd,10);
for(;;)
{
len=sizeof(cliaddr);
connfd=accept(listenfd,(struct sockaddr*)&cliaddr,&len);
read(connfd,host,sizeof(host));
printf("%s",host);
if((hp=gethostbyname(host))==NULL)
printf("cant get addr");
if(inet_ntop(AF_INET,hp->h_addr,buff,sizeof(buff))<=0)
printf("host address not available");
printf("%s",buff);
write(connfd,buff,strlen(buff)+1);
close(connfd);
}
return 0;
}
- 47 -
PROGRAM FOR DNS CLIENT
// client.c
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include<stdio.h>
#include<netdb.h>
#include<string.h>
#include<stdlib.h>
- 48 -
OUTPUT
SERVER SIDE:
CLIENT SIDE
[student@ws002 dns]$
RESULT:
Thus the Client that contacts a given DNS Server was developed and the given
host name was resolved successfully.
- 49 -
9. DOWNLOADING A FILE
AIM:
To write and execute a C program in Linux to download a file from a given
server.
1. Start.
2. Create a LINUX Server Socket using socket () with proper arguments, which
returns a socket descriptor.
3. Bind the path to the socket created, by calling the function bind () with proper
arguments.
4. Instruct the socket to listen for incoming connections from client programs, by
using listen () with proper arguments.
5. Accept a connection from a client by using accept () with proper arguments
which returns another socket descriptor!
6. Read the filename from the client, using read().
7. Open the file that the client requested in read mode.
8. Write all the file contents to the client using write().
9. Close the file.
10. Terminate the connection using close ().
11. Stop.
- 50 -
GENERAL ALGORITHM FOR DOWNLOAD CLIENT:
1. Start.
2. Create a LINUX Server Socket using socket () with proper arguments, which
returns a socket descriptor.
3. Initiate a connection to the server's socket by a call to connect ().
4. Enter the file name to be downloaded.
5. Enter the filename in which the downloaded file must be saved.
6. Open the destination file name in write mode.
7. Send the file name to be downloaded to the server.
8. Read the file contents from the server and print it both in screen and
destination file.
9. Close the file.
10. Terminate the connection using close ().
11. Stop.
- 51 -
PROGRAM FOR SERVER
//server.c
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<netdb.h>
#include<fcntl.h>
#include<stdlib.h>
#include<unistd.h>
#define SERV_TCP_PORT 8016
#define MAX 80
int main(int argc,char *argv[])
{
FILE *fp;
int sockfd,newsockfd,clength;
struct sockaddr_in serv_addr,cli_addr;
char s[MAX],t[MAX],str[MAX];
strcpy(t,"exit");
sockfd=socket(AF_INET,SOCK_STREAM,0);
serv_addr.sin_family=AF_INET;
serv_addr.sin_addr.s_addr=htonl(INADDR_ANY);
serv_addr.sin_port=htons(SERV_TCP_PORT);
bind(sockfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr));
listen(sockfd,5);
clength=sizeof(cli_addr);
newsockfd=accept(sockfd,(struct sockaddr*)&cli_addr,&clength);
close(sockfd);
read(newsockfd,&str,MAX);
printf("FILE NAME REQUESTED :%s\n",str);
fp=fopen(str,"r");
while(fgets(s,79,fp)!=NULL)
write(newsockfd,&s,MAX);
write(newsockfd,&t,MAX);
fclose(fp);
close(newsockfd);
return 0;
}
- 52 -
PROGRAM FOR CLIENT
//client.c
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>
#include<fcntl.h>
#include<stdlib.h>
#include<unistd.h>
#define SERV_TCP_PORT 8016
#define MAX 80
int main(int argc,char *argv[])
{
FILE *fp;
int sockfd;
char s[MAX],name[MAX],sendline[MAX],recvline[MAX+1];
struct sockaddr_in serv_addr;
strcpy(s,"exit");
sockfd=socket(AF_INET,SOCK_STREAM,0);
serv_addr.sin_family=AF_INET;
serv_addr.sin_addr.s_addr=INADDR_ANY;
serv_addr.sin_port=htons(SERV_TCP_PORT);
connect(sockfd,(struct sockaddr*)&serv_addr,sizeof(serv_addr));
printf("\n Enter the file name to be downloaded : ");
scanf("%s",sendline);
printf("\nEnter the destination file name : ");
scanf("%s",name);
fp=fopen(name,"w");
write(sockfd,sendline,MAX);
while(1)
{
read(sockfd,recvline,MAX);
if(strcmp(recvline,s)==0)
exit(0);
printf("%s",recvline);
fputs(recvline,fp);
}
fclose(fp);
close(sockfd);
return 0;
}
- 53 -
INPUT FILE
INPUT.DAT
OUTPUT
SERVER SIDE:
[student@ws002 download]$
CLIENT SIDE
[student@ws002 download]$
OUTPUT FILE
OUTPUT.DAT
RESULT:
Thus the program for downloading a file was worked out and requested file
was downloaded successfully.
- 54 -
10. DATA TRANSFER OVER RS232
AIM:
To write a C program to transfer data between systems over RS232.
1. Start.
2. Initialize the COM1 port.
3. Repeat the following:
3.1 Wait until get the data.
3.2 If data is available on the port, then do the following:
3.2.1 Input the data.
3.2.2 Display the data onto the screen.
3.3 If a key is pressed, do the following:
3.4 If it is esc key, then break.
3.5 Output the data.
4. Stop.
- 55 -
PROGRAM FOR DATA TRANSFER OVER RS232
// datatransfer.c
#include <bios.h>
#include <conio.h>
#define COM1 0
#define DATA_READY 0x100
int main(void)
{
int in, out, status;
- 56 -
OUTPUT
System1:
System2:
RESULT:
Thus the program to transfer data between two systems over RS232 was
worked out and outputs were generated successfully.
- 57 -
11. STUDY OF NS2 (NETWORK SIMULATOR VERSION 2)
SIMULATOR
INTRODUCTION:
C++ :
Æ Detailed protocol simulations require Systems Programming
Language.
Æ Byte manipulation, packet processing algorithm implementation.
Æ Runtime speed is important.
Æ Turn Around Time (run simulation, final bug, fix bug, recompile
and re-run) is slower.
TCL :
Æ Simulation of slightly varying parameters.
Æ Quickly exploring a number of scenarios.
Æ Iteration time (change the model and re-run) is more important.
- 58 -
• Scheduling disciplines - DropTail, RED, WFQ, DRR, LQD etc.
• Different traffic characterizations - Poisson, Exponential, Pareto etc.
• Modify NS-2 to implement your own versions of the above protocols or even
code totally new protocols
• Measurement of Statistics:
PLATFORMS:
THE DOWNSIDE:
simple.tcl
$ns run
% ns simple.tcl
Hello World!
- 59 -
RUNNING A SIMULATION:
n0
n1
$ns run
- 60 -
STEPS INVLOVED:
• Usage: ns file.tcl
• If the C++ source codes are modified, re-compilation is required
• What ns-2 does:
• Use some scripts like awk or Perl, to filter the trace file
• Use Excel, xplot or xgraph to plot the results
CONCLUSION:
Thus we have analyzed the several aspects of the NS2 Simulator in detail.
- 61 -
12. STUDY OF OPNET ( OPTIMIZED NETWORK ) SIMULATOR
INTRODUCTION
Optimized Network Engineering Tool
A powerful network simulation tool
o comprehensive development environment for modeling of
communication networks and distributed systems
o Accuracy and easy-of-use for network planner
System requirements
o Visual studio 6.0
MODELING OVERVIEW
BACKGROUNDS:
Object orientation
o OPNET Consists of objects, each with configurable sets of attribute
o Objects Belong to classes
Specialized in communication networks and information systems
Graphical specification
Flexibility to develop detailed custom models
o OPNET provides a flexible, high-level programming language with
extensive support
Automatic generation of simulations
o Automatically compiled with C programming language
MODELING DOMAINS:
- 62 -
OPNET MODEL HIERARCHY:
Re-Spec.
Analysis
PROCESS DOMAIN
INTERRUPT DRIVEN EXECUTION:
Process are driven by events
- 63 -
INITIAL STATE AND TRANSITIONS:
Initial state
(Condition)
/Executive
VARIABLES:
State variable
NODE DOMAIN
TYPICAL NODE MODELS:
Work station
o Generate and receive transfers of files or sparse packets and manage
several concurrent network connections
Packet switch
o Supports large numbers of incoming and outgoing data links and
performs packet routing at high speeds
Satellite terminal
o Generates and receives packets according to a CA protocol
Remote data sensor
o Acts as a simple source of packets, usually transmitting them in bursts
MODULE DEFINITION:
Processor modules
o Primary general-purpose building blocks of node models
o Can be specified by process model attribute
o Used to perform general processing of data packets
Queue modules
o Provide superset of the functionality of processor modules
o Are related to memories
- 64 -
Transmitter modules
o Serve as the outbound interface between packet streams in side a node
and communication links outside node
Receiver modules
o Serve as the inbound interface between communication links outside a
node and packet streams inside the node
NETWORK DOMAIN
CONCEPTS:
- 65 -
NETWORK OBJECTS:
Sub networks
o Provide a powerful mechanism to manipulate complex networks
structures and to break down the system’s complexity through
abstractions
o Have Fixed, mobile, satellite types
Communication nodes
o Exits within a sub network and represents a network device with a
wide range of possible capabilities
o Determined by node models
o Have fixed, mobile, and satellite types
Communication links
o Allow communication of information between nodes in the form of
structured message called packets
o Simplex, duplex point to point, bus and taps.
CONCLUSION:
Thus we have analyzed the several aspects of the OPNET Simulator in detail.
- 66 -
APPENDIX
- 67 -
S.No Header file Purpose / System calls / structure
1 <sys/socket.h> Defines various socket functions.
struct sockaddr.
- 68 -
CRC AND BIT STUFFING
CRC stands for Cyclic Redundancy Check; most powerful error detector
which is based on Binary division.
The redundancy bits used by CRC are derived by dividing the data unit by a
predetermined divisor; the remainder is CRC.
To be valid CRC must have two qualities:
• CRC must have exactly one bit less than divisor.
• Appending CRC to the end of the data string must make the
resulting bit sequence exactly divisible by the divisor.
Polynomial Form:
o The divisor can also be represented as polynomial.
o Ex: x7 + x5 + x2+ x + 1 == > 10100111.
Bit stuffing is the process of adding an extra 0 to prevent the receiver from
mistaking the data for a flag.
SIMULATION OF ARP/RARP
ARP -> Address Resolution Protocol.
-> It maps an Internet address into a hardware address. (used in
network layer)
RARP ->Reverse Address Resolution Protocol.
-> it maps a hardware address into an Internet Address. (used in
network layer)
- 69 -
CHAT APPLICATION
Sockets provide point-to-point, two-way communication between two
processes.
A socket is an endpoint of communication to which a name can be bound.
A socket domain is an abstraction that provides an addressing structure
and a set of protocols.
Sockets connect only with sockets in the same domain.
- 70 -
DOWNLOADING A FILE
HyperText Transfer Protocol (HTTP) is a communications protocol used to
transfer or convey information on the World Wide Web.
Its original purpose was to provide a way to publish and retrieve HTML
hypertext pages.
HTTP is a request/response protocol between clients and servers.
File Transfer Protocol (FTP), a standard Internet protocol is commonly used
to download programs and other files to your computer from other servers.
- 71 -
Examples of data acquisition devices include GPS receivers, electronic
balances, data loggers, temperature interfaces and other measurement
instruments.
- 72 -