Documente Academic
Documente Profesional
Documente Cultură
Ex.No: 1
Date:
AIM:
To write a c program for simulation of ARP, RARP client and server.
ALGORITHM:
Server:
1. Start
2. Create a shared memory segment and get its id using shmget() ;
3. Create a shared memory pointer 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.
1
FLOW CHART:
PROGRAM:
PROGRAM EXECUTION
RESULT:
Thus the ARP, RARP client and server program was written and output was executed
successfully.
8
BIT STUFFING
Ex.No: 2
Date:
AIM:
To write a c program for bit stuffing.
ALGORITHM:
1. Start the program.
2. Include all the header files.
3. Declare two files pointers for opening the input file in read mode and the output in write
mode.
4. Read the content of an input file.
5. If the bit is 1, then check for four consecutive 1s.
6. If so then stuff a bit 0 at that position (i.e. after five consecutive 1s)
7.Open the output file in write mode and print the stuffed string.
8. Stop the program.
FLOW CHART:
10
PROGRAM:
11
12
13
14
PROGRAM EXECUTION
15
RESULT:
Thus the bit stuffing program was executed and output was verified.
16
IMPLEMENTATION OF CRC
Ex.No: 3
Date:
AIM:
To write a c program for implementing CRC.
ALGORITHM:
1. Start.
2. Get the number of data bits.
3. Get the size of generator.
4. Get the number of generator.
5. Display the generator matrix.
6. Perform CRC by using generator bits as a divisor and data bits as a dividend.
7. If the first bit of data is zero, then XOR with zero.
8. Otherwise XOR the data bit with generator bits.
9. Repeat step 7 & 8 until getting the reminder, the reminder is CRC.
10. Append the CRC bit with the data bits.
11. Stop
17
FLOW CHART:
18
PROGRAM:
19
20
PROGRAM EXECUTION
21
RESULT:
Thus the CRC program was executed and output was verified.
22
23
FLOW CHART:
24
PROGRAM:
25
26
27
28
PROGRAM EXECUTION
29
RESULT:
Thus the sliding window program was executed and output was verified.
30
31
FLOW CHART:
32
PROGRAM:
33
34
35
36
PROGRAM EXECUTION
37
RESULT:
Thus the simulation of BGP / OSPF routing protocol was implemented and executed
successfully.
38
Client:
Step 1: Start.
Step 2: Create a socket with address family AF_INET type SOCK_STERAM and default
protocol.
Step 3: Initialize the socket and set it attributes set the required port number.
Step 4: Connect to the server using connect() function to initialize the request.
Step 5: Repeat steps 6-8 until server sends bye.
Step 6: Accept the client message and write it to the server using write function.
Step 7: If the client message is bye go to step 9.
Step 8: Read the message from the server using read() function. Display the message.
Step 9: Stop.
FLOW CHART:
40
41
PROGRAM:
42
43
44
PROGRAM EXECUTION
45
RESULT:
Thus the client server application for chat was implemented and executed successfully.
46
Client:
1. Get the host name and port number from the user through command line argument.
2. Check the number , it must be 2. If not prompt an error msg.
3. Open the socket connection.
4. Clear the buffer using bzero function.
5. Check if the write operation was successfully or not if not print the error msg.
6. Exit the client connection.
47
FLOW CHART:
48
PROGRAM:
49
50
51
52
PROGRAM EXECUTION
53
RESULT:
Thus the implementation of DNS server using C program was executed successfully.
54
Start.
Create n number of .txt file separately for n number of domain.
In each and every .txt file the content of that domain is entered.
Create a file pointer in c program using FILE *f1.
Get the domain name from user and string comparison is done with respect to domain
name.
6. If the input domain name matches with the string then open a file in a read mode using
fopen().
7. Print the corresponding content of that file.
8. Stop.
FLOW CHART:
55
56
PROGRAM:
57
58
59
60
PROGRAM EXECUTION
61
RESULT:
Thus the C p;rogram for downloading file form http server was implemented and executed
successfully.
62
64
PROGRAM:
65
66
67
68
PROGRAM EXECUTION
69
RESULT:
Thus the file transfer between two computers using tcp socket was implemented and
output was executed successfully.
70
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.
7. Close the socket connection.
8. Stop.
71
FLOW CHART:
72
PROGRAM:
73
74
75
76
PROGRAM EXECUTION
77
RESULT:
Thus the C program for file transfer using RS232C was implemented and executed
successfully.
78
APPENDIX
SAMPLE OUTPUT:
1. SIMULATION OF ARP AND RARP
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
2. BIT STUFFING
Enter the choice
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
79
MESSAGE
sa
ve
eth
a
un
iv
e
rs
it
y
ACK
2
4
7
9
11
13
14
16
18
19
80
4 6
10 3
7 9
81
Input File:
Dns.txt
Yahoo 192.10.11.124
www.gmail.com 209.34.56.123
Output :
[cseb17@localhost cseb 17]$ ./a.out 5677
cc rsser.c
./a.out 8222
Server waiting for client on port 8222
File received and socket closed
cat> recvfile.txt
this is rs232 program
Client Side:
cc rscli.c
./a.out 197.168.2.100 rsinput.txt 8222
The rsinput.txt send over RS232
cat > rsinput.txt
this is rs232 program
83