CSA07-lab Manual Current-2023 (With Output C Program)
CSA07-lab Manual Current-2023 (With Output C Program)
Sl. No Experiment CO
1. Configuration of Network Devices using Packet Tracer tools (Hub, CO1
Switch, Ethernet, Broadcast).
2. Design and Configuration of Star Topologies using Packet Tracer. CO1
3. Design and Configuration of BUS Topologies using Packet Tracer. CO1
4. Design and Configuration of RING Topologies using Packet Tracer. CO1
5. Design and Configuration of Mesh Topologies using Packet Tracer. CO1
6. Design and Configuration of Tree Topologies using Packet Tracer. CO1
7. Design and Configuration of Hybrid Topologies using Packet Tracer. CO1
8. Data Link Layer Traffic Simulation using Packet Tracer Analysis of CO2
ARP.
9. Data Link Layer Traffic Simulation using Packet Tracer Analysis CO2
11. Designing two different networks with Static Routing techniques using CO3
Packet Tracer.
12. Design the Functionalities and Exploration of TCP using Packet Tracer. CO4
13. Design the network model for Subnetting – Class C Addressing using CO4
Packet Tracer.
14. Simulating X, Y, Z Company Network Design and simulate using Packet C05
Tracer.
15. Configuration of DHCP (dynamic host configuration protocol) in packet CO4
Tracer.
16. Configuration of firewall in packet tracer. C05
17. Make a Computer Lab to transfer a message from one node to another to CO5
design and simulate using Cisco Packet Tracer.
18. Simulate a Multimedia Network in Cisco Packet Tracer. CO4
1
20. Implementation of IoT based smart gardening. CO2
2
EXPERIMENT-1
1. Node: In a communications network, a network node is a connection point that can receive,
create, store or send data along distributed network routes.
3
3. Hub: Ethernet hub, active hub, network hub, repeater hub
Hub or concentrator is a device for connecting multiple twisted pair or fiber optic Ethernet
devices together and making them act as a single network segment. Hubs work at the physical
layer (layer 1) of the OSI model. The device is a form of multiport repeater. Repeater hubs
also participate in collision detection, forwarding a jam signal to all ports if it detects a
collision.
4
5. Bridge: A network bridge connects multiple network segments at the data link
layer (Layer 2) of the OSI model. In Ethernet networks, the term bridge formally
means a device that behaves according to the IEEE 802.1D standard. A bridge and
switch are very much alike; a switch being a bridge with numerous ports. Switch or
Layer 2 switch is often used interchangeably with bridge. Bridges can analyze
incoming data packets to determine if the bridge is able to send the given packet to
another segment of the network.
5
6. Router: A router is an electronic device that interconnects two or more computer
networks, and selectively interchanges packets of data between them. Each data
packet contains address information that a router can use to determine if the source
and destination are on the same network, or if the data packet must be transferred
from one network to another. The multiple routers are used in a large collection of
interconnected networks, the routers exchange information about target system
addresses, so that each router can build up a table showing the preferred paths
between any two systems on the interconnected networks.
7. Gate Way: In a communication network, a network node equipped for interfacing with
another network that uses different protocols. A gateway may contain devices such as
protocol translators, impedance matching devices, rate converters, fault isolators, or signal
translators as necessary to provide system interoperability. It also requires the establishment
of mutually acceptable administrative procedures between both networks.
• A protocol translation/mapping gateway interconnects networks with different
network protocol technologies by performing the required protocol conversions.
6
7
8. Server: A server is a type of computer or device on a network that manages network resources.
Servers are often dedicated, meaning that they perform no other tasks besides their server tasks.
On multiprocessing operating systems, however, a single computer
can execute several programs at once. A server in this case could refer to the program that is
managing resources rather than the entire computer.
9. Transmission media: The medium through which the signals travel from one device to another.
These are classified as guided and unguided. Guided media are those that provide a conduit from
one device to another. Eg. Twisted pair, coaxial cable etc. Unguided media transport signals
without using physical cables. Eg. Air.
8
EXPERIMENT-2
Aim: To Implement a star topology using packet tracer and hence to transmit data
between the devices connected using star topology.
9
generated automatically.
Step 7: To confirm Data transfer between the devices
Click on the node. Select desktop option and then command prompt. Once the window
pops up, ping the IP address of the device to which node0 is connected. Ping statistics will be
displayed.
Result: Thus the Star topology is implemented with Packet Tracer simulation Tool.
10
Date:
EXPERIMENT-3
Aim: To Implement a Bus topology using packet tracer and hence to transmit data between the
devices connected using Bus topology.
11
generated automatically.
Step 7: To confirm Data transfer between the devices
Click on the node. Select desktop option and then command prompt. Once the window
pops up, ping the IP address of the device to which node0 is connected. Ping statistics will
be displayed.
Result: Thus, the Bus topology is implemented with Packet Tracer simulation Tool.
12
Date:
EXPERIMENT-4
Aim: To Implement a Ring topology using packet tracer and hence to transmit data between the
devices connected using Ring topology.
13
generated automatically.
Step 7: To confirm Data transfer between the devices
Click on the node. Select desktop option and then command prompt. Once the window
pops up, ping the IP address of the device to which node0 is connected. Ping statistics
will be displayed.
Result: Thus the Ring topology is implemented with Packet Tracer simulation Tool.
14
Date:
EXPERIMENT-5
Aim: To Implement a Mesh topology using packet tracer and hence to transmit data between the
devices connected using Mesh topology.
15
generated automatically.
Step 7: To confirm Data transfer between the devices
Click on the node. Select desktop option and then command prompt. Once the window
pops up, ping the IP address of the device to which node0 is connected. Ping statistic will
be displayed.
Result: Thus the Mesh topology is implemented with Packet Tracer simulation Tool.
16
Date:
EXPERIMENT-6
Aim: To Implement a tree topology using packet tracer and hence to transmit data
between the devices connected using tree topology.
Procedure:
17
automatically.
Step 8: Verifying Connectivity in Real time Mode
Be sure you are in Real time mode.
Select the Add Simple PDU tool used to ping devices.
Click once on PC0, then once on PC3.
The PDU Last Status should show as Successful.
Step 9: Verifying Connectivity in Simulation Mode
Be sure you are in Simulation mode.
Deselect all filters (All/None) and select only ICMP.
Select the Add Simple PDU tool used to ping devices
Click once on PC0, then once on PC3.
Continue clicking Capture/Forward button until the ICMP ping is completed. You
should see the ICMP messages move between the hosts, hub and switch. The PDU last
status should show as Successful.
Result: Thus the Tree topology is implemented with Packet Tracer simulation Tool.
18
Date:
EXPERIMENT-7
Aim: To Implement a hybrid topology using packet tracer and hence to transmit data
between the devices connected using tree topology.
19
To start communication between the hosts IP Addresses and Subnet Masks had to be
configured on the devices. Click once on PC0. Choose the Config tab and click on
FastEthernet0. Type the IP address in its field. Click on the subnet mask. It will be
Generated automatically.
Step 8: Verifying Connectivity in Realtime Mode
Be sure you are in Realtime mode.
Select the Add Simple PDU tool used to ping devices.
Click once on PC0, then once on PC3.
The PDU Last Status should show as Successful.
Step 9: Verifying Connectivity in Simulation Mode
Be sure you are in Simulation mode.
Deselect all filters (All/None) and select only ICMP.
Select the Add Simple PDU tool used to ping devices
Click once on PC0, then once on PC3.
Continue clicking Capture/Forward button until the ICMP ping is completed. The ICMP
messages move between the hosts, hub and switch. The PDU Last Status should show as
Successful.
Result: Thus the Hybrid topology is implemented with Packet Tracer simulation Tool.
20
Date:
EXPERIMENT-8
DATA LINK LAYER TRAFFIC SIMULATION USING PACKET TRACER ANALYSIS
OF ARP
Aim: To implement Data Link Layer Traffic Simulation using Packet Tracer Analysis of ARP.
Result: Thus the Data Link Layer Traffic Simulation using Packet Tracer Analysis of
ARP is implemented.
21
Date:
EXPERIMENT-9
DATA LINK LAYER TRAFFIC SIMULATION USING PACKET TRACER
Aim: To implement Data Link Layer Traffic Simulation using Packet Tracer Analysis
of CSMA/CD & CSMA/CA.
22
Date:
EXPERIMENT-10
Result: Thus the Computer Lab in Cisco Packet Tracer is set up successfully.
23
Date:
EXPERIMENT-11
Aim: To Configure a router using packet tracer software and hence to transmit data
between the devices in real time mode and simulation mode.
Procedure:
24
Deselect all filters (All/None) and select only ICMP.
Select the Add Simple PDU tool used to ping devices
Click once on PC0, then once on PC3.
Continue clicking Capture/Forward button until the ICMP ping is completed. The ICMP
messages move between the hosts, hub and switch. The PDU Last Status should show as
Successful.
Result: Thus Configuration of a simple static routing in packet tracer using a simple topology with
two routers was done successfully.
25
Date:
EXPERIMENT-12
Aim: To design the Functionalities and Exploration of TCP using Packet Tracer.
Procedure:
Next, we will configure IP addresses for the computers. Double-click on each PC to open
the configuration window and navigate to the Desktop tab. Click on the IP Configuration
icon and enter the IP address and subnet mask for each computer. For example, PC1 can
have an IP address of 192.168.1.1 with a subnet mask of 255.255.255.0 and PC2 can have
an IP address of 192.168.1.2 with the same subnet mask.
Now, we will configure the router. Double-click on the router to open the configuration
window and navigate to the CLI tab.
COMMANDS:
enable
configure terminal
interface FastEthernet0/0
no shutdown
exit
exit
26
Step 4: Test the connection
Now that the network is set up and configured, we can test the connection between the
two computers. Open a command prompt on PC1 and ping PC2 by typing ping
192.168.1.2 in the command prompt. If the ping is successful, it means that the two
computers are communicating with each other.
Now, let's explore the functionalities of TCP. We will use the Netcat utility to establish a
TCP connection between the two computers. Netcat is a versatile networking tool that can
be used for various purposes, including establishing TCP connections.
Result: Thus the Functionalities and Exploration of TCP using Packet Tracer is designed
successfully.
27
Date:
EXPERIMENT-13
DESIGN THE NETWORK MODEL FOR SUBNETTING – CLASS C ADDRESSING
USING PACKET TRACER
AIM: To design the network model for subnetting-class C addressing using packet tracer.
Procedure:
STEP 1: Click on end devices, select generic Pc’s drag and drop it on the window. Click on
SWITCH drag and drop it on the window.
STEP 2: Select the straight through cable and connect all end device to switch. Assign the IP address
for all end devices. (Double click the end device Select → desktop → IP configuration static
STEP 3: Now set the IP address to Host A (192.168.1.1) in static mode. Similarly set IP address for
Host B (192.168.1.2) and Host C (192.168.1.3)
STEP 4: To view the IP address, give ipconfig command in command prompt. Using ping command,
we can establish communication between two host devices.
28
STEP 6: Now display the packet transmission in simulation mode.
Result:
There for designing for network model subnetting has been successfully implemented using packet
tracer.
29
Date:
EXPERIMENT: 14
SIMULATING X, Y, Z COMPANY NETWORK DESIGN AND SIMULATE USING
PACKET TRACER
Aim: To simulate X,Y,Z company network design and stimulate using packet tracer.
30
workstations.
4. Connect devices: Use the "Cable" tool to connect the devices together. Configure the
connections as needed.
5. Configure devices: Double-click on each device to open its configuration menu, and
configure its settings such as IP address, subnet mask, and routing protocols. Configure security
measures such as firewalls, access control lists, and intrusion detection systems as needed.
6. Add applications: Click on the "Applications" tab in the bottom-left corner of the window,
and drag and drop applications onto the workstations and servers. Configure the applications as
needed.
7. Test the network: Use Packet Tracer's built-in testing tools to verify that the network is
working correctly. Test the network connectivity by pinging devices and verifying that data can be
transmitted between them.
8. Monitor network traffic: Use Packet Tracer's built-in network monitoring tools to monitor
network traffic and identify any potential issues.
9. Make adjustments as needed: Make adjustments to the network configuration as needed to
improve performance, security, or functionality.
10. Save the project: Click on "File" and select "Save" to save the project.
Result: Therefore stimulating of companies network designing has been successfully done using
packet tracer.
31
Date:
EXPERIMENT: 15
CONFIGURATION OF DHCP (DYNAMIC HOST CONFIGURATION PROTOCOL) IN
PACKET TRACER
32
configuration details.
8. Client configuration:
• The client receives the ACK message and configures its network interface with the assigned
IP address, subnet mask, default gateway, DNS server, and any other parameters provided by the
DHCP server.
9. Lease renewal and expiration:
• The client periodically contacts the DHCP server to renew its lease before it expires.
• If the client doesn't renew the lease or is unable to contact the DHCP server, the IP address
lease eventually expires, and the IP address returns to the pool for future assignment.
10. End:
Procedure:
1. Launch Cisco Packet Tracer and create a new network topology or open an existing one.
2. Add the necessary network devices to your topology, including a DHCP server, switch, and
DHCP clients. Connect them using appropriate cables.
3. Configure the DHCP server:
• Select the DHCP server device and open its configuration panel.
• Assign an IP address to the server interface connected to the switch.
• Enable the DHCP service on the server by checking the "DHCP" option.
• Define the IP address pool range that the server can assign to clients. Specify the starting and
ending IP addresses.
• Optionally, set other DHCP options like default gateway, DNS server, and subnet mask.
• Save the configuration.
4. Configure the switch:
• Select the switch device and open its configuration panel.
• Enable the interfaces that connect to the DHCP clients. This allows the clients to
communicate with the DHCP server.
• Save the configuration.
5. Configure the DHCP clients:
• Select each DHCP client device and open its configuration panel.
• Set the IP address assignment method to "DHCP" or "Obtain an IP address automatically."
• Save the configuration for each client.
6. Start the simulation:
• Click the "Start/Stop Simulation" button to start the simulation.
7. Verify DHCP operation:
33
• Wait for the DHCP clients to boot up or refresh their IP configurations.
• Check if the DHCP clients receive IP addresses from the DHCP server.
• Verify that the clients have the correct IP address, subnet mask, default gateway, and DNS
server settings.
Result: Therefore the configuration for DHCP has been successfully executed using packet tracer.
34
Date:
EXPERIMENT-16
To begin, we will create a simple network topology consisting of three computers, a router,
and a firewall. Open Packet Tracer and drag three PCs, a router, and a firewall onto the
workspace. Connect the three PCs to the router using Ethernet cables, and connect the firewall
to the router using another Ethernet cable.
Next, we will configure IP addresses for the computers. Double-click on each PC to open the
configuration window and navigate to the Desktop tab. Click on the IP Configuration icon and
enter the IP address and subnet mask for each computer. For example, PC1 can have an IP
address of 192.168.1.1 with a subnet mask of 255.255.255.0, PC2 can have an IP address of
192.168.1.2 with the same subnet mask, and PC3 can have an IP address of 192.168.1.3 with
the same subnet mask
Now, we will configure the router. Double-click on the router to open the configuration
window and navigate to the CLI tab. Enter the following commands:
Commands :
enable
configure terminal
interface FastEthernet0/0
no shutdown
exit
35
Step 4: Configure the firewall
Now, we will configure the firewall. Double-click on the firewall to open the configuration
window
Now that the firewall is configured, we can test the connection between the computers. Open a
command prompt on PC1 and ping PC2 and PC3 by typing ping 192.168.1.2 and ping
192.168.1.3 in the command prompt. If the pings are successful, it means that the computers
are communicating with each other.
To test the firewall, try to connect to PC1 from the internet using a protocol or port that is not
allowed by the access rule. For example, you can try to connect to PC1 using Telnet on port
23.
36
Date:
EXPERIMENT-17
Aim: To make a Computer Lab to transfer a message from one node to another to design and
simulate using Cisco Packet Tracer.
Procedure:
First, we need to create the network topology for the computer lab. In Packet Tracer, drag two
computers, a switch, and two routers onto the workspace. Connect the computers to the switch
using Ethernet cables, and connect the switch to the two routers using Ethernet cables. The
network should look like this:
CODE:
PC1 PC2
| |
Next, we will configure IP addresses for the computers. Double-click on each PC to open the
configuration window and navigate to the Desktop tab. Click on the IP Configuration icon and
enter the IP address and subnet mask for each computer. For example, PC1 can have an IP
address of 192.168.1.1 with a subnet mask of 255.255.255.0, and PC2 can have an IP address
of 192.168.1.2 with the same subnet mask.
Now, we will configure the routers. Double-click on Router1 to open the configuration
window and navigate to the CLI tab. Enter the following commands:
COMMANDS:
enable
37
configure terminal
interface FastEthernet0/0
no shutdown
interface Serial0/0/0
no shutdown
exit
Now, double-click on Router2 to open the configuration window and navigate to the CLI tab.
Enter the following commands
enable
configure terminal
interface Serial0/0/0
no shutdown
interface FastEthernet0/0
no shutdown
exit
We need to configure routing between the routers so that they can communicate with each
other. Enter the following commands on Router1:
enable
configure terminal
exit
These commands will configure a static route on Router1 to reach the 192.168.2.0/24 network,
which is connected to Router2's Fast Ethernet interface.
38
enable
configure terminal
exit
To send a message from PC1 to PC2, open the command prompt on PC1 and type:
ping 192.168.1.2
Result: Hence the message is transferred from one node to another to design and simulate
using Cisco Packet Tracer successfully .
39
Date:
EXPERIMENT-18
40
encountered during the simulation. This documentation will help to analyze the results and make
improvements if necessary.
Remember to save your project regularly to preserve your progress. Cisco Packet Tracer provides a
simulated environment to experiment with multimedia networks, allowing you to understand the
challenges and requirements of such networks in a virtual setting.
41
Date:
EXPERIMENT-19
IOT BASED SMART HOME APPLICATIONS
Aim: To implement IoT based smart home applications in Cisco Packet Tracer.
Result: Thus IoT based smart home applications in Cisco Packet Tracer is implemented
successfully.
42
Date:
EXPERIMENT: 20
IMPLEMENTATION OF IOT BASED SMART GARDENING
Aim: To implement IOT based smart gardening using Cisco packet tracer.
43
Date:
EXPERIMENT: 21
Procedure:
Steps:
Drag and drop a router from the "Devices" panel onto the workspace area.
2. Connect the router to the Internet by dragging and dropping a "Cloud" device from the
"Devices" panel onto the workspace area, and then connecting the router to the cloud using a
straight-through cable.
3. Add an IoT device to the network by dragging and dropping a device from the "Devices"
panel onto the workspace area. There are various IoT devices available in the "Devices"
panel, such as a Raspberry Pi or an Arduino.
4. Connect the IoT device to the router using an Ethernet cable. To do this, click on the IoT
device and then click on the "Config" tab. Under the "Interfaces" section, select the Ethernet
interface and then click on the "+" button to add a new interface. Connect the new interface
to the router.
5. Configure the IoT device by clicking on it and then clicking on the "CLI" tab. This will
bring up the command line interface for the IoT device, where you can configure its settings.
6. Test the connectivity of the IoT device by pinging it from the router or from another
device on the network.
7. These are just general steps and the specifics of the implementation will depend on the
specific IoT device and network configuration you want to create. Additionally, you may
need to configure the router and the cloud device to enable Internet connectivity for the IoT
device.
Result: Thus an IOT device in networking is implemented using Cisco Packet Tracer
successfully.
44
Date:
EXPERIMENT: 22
Aim: Designing an IoT based AAA Local and Server based authentication configuration.
45
Configure the central AAA server with user profiles or roles and associated permissions.
6. Implement Server Authentication:
After local authentication, the IoT device establishes a secure connection with the central AAA
server.
The IoT device sends its authentication token or session key to the central AAA server for
verification.
The central AAA server validates the authentication token or session key received from the IoT
device.
7. Implement Server Authorization:
Once the central AAA server verifies the authentication token or session key, it performs additional
authorization checks.
The central AAA server ensures that the IoT device has the necessary permissions to access critical
resources or perform higher-level operations.
If authorized, the central AAA server sends an authorization response to the IoT device.
8. Logging and Accounting:
Both the local and central AAA servers maintain logs of authentication and authorization events for
auditing and accounting purposes.
They record information such as user/device identification, timestamps, and actions taken.
9. Revocation and Updates:
Implement mechanisms to handle credential revocation, such as disabling user accounts or tokens
when necessary.
Regularly update user profiles, roles, and permissions in both the local and central AAA servers to
reflect changes in the network environment.
Remember to implement appropriate security measures such as encryption, secure communication
protocols, and strong password policies to ensure the integrity and confidentiality of the
authentication process.
Result: IoT based AAA Local and Server based authentication is designed successfully.
46
Date:
EXPERIMENT: 23
TRANSPORT LAYER PROTOCOL HEADER ANALYSIS USING WIRE SHARK-TCP
AND UDP
Aim: To analyze capturing of Transport layer protocol header analysis using Wire shark- TCP and
UDP.
SOFTWARE USED:
Wire shark network analyzer
Procedure:
1. Open wire shark.
2. Click on list the available capture interface.
3. Choose the LAN interface.
4. Click on start button.
5. Active packets will be displayed.
6. Capture the packets & select any IP address from the source.
7. Click on the expression and select IPV4 →IP addr source address in the field name.
8. Select the double equals (==) from the selection and enter the selected IP source address.
9. Click on apply button.
10. All the packets will be filtered using source address.
Result: Hence, the capturing of packets using wire shark network analyzer was analyzed for TCP
and UDP.
47
Date:
EXPERIMENT-24
NETWORK LAYER PROTOCOL HEADER ANALYSIS USING WIRE SHARK –
SMTPAND ICMP
Aim: To analyze capturing of Transport layer protocol header analysis using Wire shark- SMTP and
ICMP.
SOFTWARE USED:
Wire shark network analyzer
Procedure:
1. Open wire shark.
2. Click on list the available capture interface.
3. Choose the LAN interface.
4. Click on start button.
5. Active packets will be displayed.
6. Capture the packets & select any IP address from the source.
7. Click on the expression and select IPV4 →IP addr source address in the field name.
8. Select the double equals (==) from the selection and enter the selected IP source address.
9. Click on apply button.
10. All the packets will be filtered using source address.
Result: Hence, the capturing of packets using wire shark network analyzer was analyzed for SMTP
and ICMP.
48
Date:
EXPERIMENT-25
NETWORK LAYER PROTOCOL HEADER ANALYSIS USING WIRE SHARK – ARP AND
HTTP
AIM: To analyze capturing of Transport layer protocol header analysis using Wire shark- ARP and
HTTP.
SOFTWARE USED:
Wire shark network analyzer
PROCEDURE:
1. Open wire shark.
2. Click on list the available capture interface.
3. Choose the LAN interface.
4. Click on start button.
5. Active packets will be displayed.
6. Capture the packets & select any IP address from the source.
7. Click on the expression and select IPV4 →IP addr source address in the field name.
8. Select the double equals (==) from the selection and enter the selected IP source address.
9. Click on apply button.
10. All the packets will be filtered using source address.
Result: Hence, the capturing of packets using wire shark network analyzer was analyzed for ARP
and HTTP.
49
Date:
EXPERIMENT: 26
TO IMPLEMENT DATE AND TIME DISPLAY FROM CLIENT TO SERVER USING TCP
SOCKETS IN JAVA/C
Aim: To implement date and time display from client to server using TCP Sockets.
Algorithm:
Server
1. Create a server socket and bind it to port.
2. Listen for new connection and when a connection arrives, accept it.
3. Send server‟s date and time to the client.
4. Read client‟s IP address sent by the client.
5. Display the client details.
6. Repeat steps 2-5 until the server is terminated.
7. Close all streams.
8. Close the server socket.
9. Stop.
Client
1. Create a client socket and connect it to the server‟s port number.
2. Retrieve its own IP address using built-in function.
3. Send its address to the server.
4. Display the date & time sent by the server.
5. Close the input and output streams.
6. Close the client socket.
7. Stop.
Result: Thus date and time is displayed from client to server using TCP Sockets successfully.
50
Date:
EXPERIMENT: 27
IMPLEMENTATION OF A DNS SERVER AND CLIENT IN JAVA/C USING UDP
SOCKET
Aim: To implement a DNS server and client in java using UDP socket
Algorithm:
Server
1. Create an array of hosts and its IP address in another array
2. Create a datagram socket and bind it to a port
3. Create a datagram packet to receive client request
4. Read the domain name from client to be resolved
5. Lookup the host array for the domain name
6. If found then retrieve corresponding address
7. Create a datagram packet and send ip address to client
8. Repeat steps 3-7 to resolve further requests from clients
9. Close the server socket
10. Stop
Client
1. Create a datagram socket
2. Get domain name from user
3. Create a datagram packet and send domain name to the server
4. Create a datagram packet to receive server message
5. Read server's response
6. If ip address then display it else display "Domain does not exist"
7. Close the client socket
Procedure:
DNS Server-side implementation:
1. Create a UDP socket using the `socket()` function with the `AF_INET` address family and
`SOCK_DGRAM` socket type.
2. Set socket options using the `setsockopt()` function to allow reuse of the address and port.
3. Bind the socket to a specific IP address and port using the `bind()` function.
4. Receive a DNS query from a client using the `recvfrom()` function.
51
5. Parse the DNS query to extract the requested domain name and record type.
6. Lookup the requested domain name and retrieve the corresponding IP address or other records.
7. Create a DNS response packet with the appropriate format.
8. Send the DNS response to the client using the `sendto()` function with the client address and port
obtained from `recvfrom()`.
9. Close the socket using the `close()` function.
DNS Client-side implementation:
1. Create a UDP socket using the `socket()` function with the `AF_INET` address family and
`SOCK_DGRAM` socket type.
2. Set the server address and port in a `struct sockaddr_in` structure.
3. Prepare a DNS query packet with the desired domain name and record type.
4. Send the DNS query to the server using the `sendto()` function with the server address and port.
5. Receive the DNS response from the server using the `recvfrom()` function.
6. Parse the DNS response packet to extract the requested information.
7. Process and display the received information as needed.
8. Close the socket using the `close()` function.
1. Create a UDP socket using the `socket()` function with the `AF_INET` address family and
`SOCK_DGRAM` socket type.
2. Set socket options using the `setsockopt()` function to allow reuse of the address and port.
3. Bind the socket to a specific IP address and port using the `bind()` function.
4. Receive a DNS query from a client using the `recvfrom()` function.
5. Parse the DNS query to extract the requested domain name and record type.
6. Lookup the requested domain name and retrieve the corresponding IP address or other records.
7. Create a DNS response packet with the appropriate format.
8. Send the DNS response to the client using the `sendto()` function with the client address and port
obtained from `recvfrom()`.
9. Close the socket using the `close()` function.
1. Create a UDP socket using the `socket()` function with the `AF_INET` address family and
52
`SOCK_DGRAM` socket type.
2. Set the server address and port in a `struct sockaddr_in` structure.
3. Prepare a DNS query packet with the desired domain name and record type.
4. Send the DNS query to the server using the `sendto()` function with the server address and port.
5. Receive the DNS response from the server using the `recvfrom()` function.
6. Parse the DNS response packet to extract the requested information.
7. Process and display the received information as needed.
8. Close the socket using the `close()` function.
Note: Remember to include the necessary header files (`<stdio.h>`, `<stdlib.h>`, `<string.h>`,
`<sys/socket.h>`, `<netinet/in.h>`, etc.) and handle errors appropriately in your code. Additionally,
you may need to implement DNS-specific functions for packet parsing, DNS lookup, and response
creation.
Remember to include the necessary header files (`<stdio.h>`, `<stdlib.h>`, `<string.h>`,
`<sys/socket.h>`, `<netinet/in.h>`, etc.) and handle errors appropriately in your code. Additionally,
you may need to implement DNS-specific functions for packet parsing, DNS lookup, and response
creation.
Result: Thus a DNS server and client in java using UDP socket is implemented successfully.
53
Date:
EXPERIMENT: 28
DEVELOPING A CLIENT THAT CONTACTS A GIVEN DNS SERVER TO RESOLVE A
GIVEN HOSTNAME in JAVA/C
Aim: To develop a client that contacts a given DNS server to resolve a given hostname.
Description: · Get the host name to be resolve using gethostname() · Check the host name using
nslookup · Print the IP address, host name, Address length and Address type. · List the addresses stored
in lookup
Algorithm :
Step 1. Find the host name by using get host by name()
Step 2. The host name is followed by the list of alias names
Step 3. Pointer points to the array of pointers to the individual address
Step 4. For each address call the inet_ntop() and print the returned string
Procedure:
1. Initialize necessary variables and structures:
- Create a socket using the `socket()` function with the `AF_INET` address family and
`SOCK_DGRAM` socket type.
- Set the DNS server address and port in a `struct sock addr_in` structure.
- Prepare a DNS query packet with the desired hostname and record type.
2. Send the DNS query to the DNS server:
- Use the `send to()` function to send the DNS query to the DNS server using the socket descriptor
and the server address structure.
3. Receive the DNS response from the DNS server:
- Use the `recvfrom()` function to receive the DNS response from the DNS server using the socket
descriptor.
- Store the response in a buffer.
4. Parse and process the DNS response:
- Extract the necessary information from the DNS response packet based on the DNS protocol.
- Handle any error conditions, such as a non-existent hostname or failed resolution.
5. Display or use the resolved information:
- Extract the resolved IP address or other relevant data from the DNS response.
- Process and utilize the resolved information as needed in your application.
6. Close the socket:
54
- Use the `close()` function to close the socket descriptor.
Remember to include the necessary header files (`<stdio.h>`, `<stdlib.h>`, `<string.h>`,
`<sys/socket.h>`, `<netinet/in.h>`, etc.) and handle errors appropriately in your code. Additionally,
you may need to implement DNS-specific functions for packet parsing and response handling based
on the DNS protocol.
It's important to note that DNS resolution involves dealing with DNS protocol intricacies, including
packet format, header fields, and query/response structure. Familiarize with the DNS protocol
specifications to ensure correct handling of DNS messages.
Result: Thus a client that contacts a given DNS server to resolve a given hostname is developed
successfully.
55
Date:
EXPERIMENT: 29
CREATING THE APPLICATIONS USING TCP ECHO SERVER AND CLIENT IN
JAVA/C
STEP1:Start
STEP6: Listen and accept the client’s request for the connection
STEP10: Stop
CLIENT:
STEP1:Start
56
Procedure:
TCP Echo Server-side implementation:
1. Create a TCP socket using the `socket()` function with the `AF_INET` address family and
`SOCK_STREAM` socket type.
2. Set socket options using the `setsockopt()` function to allow reuse of the address and port.
3. Bind the socket to a specific IP address and port using the `bind()` function.
4. Listen for incoming connections using the `listen()` function.
5. Accept a client connection using the `accept()` function, which returns a new socket descriptor for
the accepted connection.
6. Receive data from the client using the `recv()` function on the accepted socket descriptor.
7. Process the received data if necessary.
8. Optionally, send a response back to the client using the `send()` function on the accepted socket
descriptor.
9. Close the accepted socket descriptor using the `close()` function.
10. Close the server socket descriptor using the `close()` function.
TCP Echo Client-side implementation:
1. Create a TCP socket using the `socket()` function with the `AF_INET` address family and
`SOCK_STREAM` socket type.
2. Set the server address and port in a `struct sockaddr_in` structure.
3. Connect to the server using the `connect()` function with the server socket descriptor and the
server address structure.
4. Send data from the client to the server using the `send()` function on the connected socket
descriptor.
5. Receive the response from the server using the `recv()` function on the connected socket
descriptor.
6. Process and display the received data as needed.
7. Close the connected socket descriptor using the `close()` function.
The echo server simply returns back the received data, allowing the client to see the echoed message.
Remember to include the necessary header files (`<stdio.h>`, `<stdlib.h>`, `<string.h>`,
`<sys/socket.h>`, `<netinet/in.h>`, etc.) and handle errors appropriately in the code.
57
Result: Thus the Applications using TCP ECHO SERVER AND CLIENT is created successfully.
Date:
EXPERIMENT: 30
CREATING THE APPLICATIONS USING TCP CHAT CLIENT AND CHAT SERVER IN
JAVA/C
Aim: To create an application using TCP CHAT CLIENT and CHAT SERVER.
Algorithm:
SERVER:
STEP 1: Start
STEP 6: Listen and accept the client’s request for the connection
CLIENT:
STEP 1: Start
58
STEP 5: Call the connect() function
Date :
EXPERIMENT: 31
STEP 7: Stop
Implementing the ARP (Address Resolution Protocol) protocol in C involves constructing and
sending ARP request and response packets, as well as handling the reception and processing of ARP
packets.
Steps involved:
1. Define the necessary structures and constants:
- Define the structure for the ARP header, including fields like hardware type, protocol type,
hardware address length, protocol address length, operation, sender hardware address, sender
protocol address, target hardware address, and target protocol address.
59
- Define constants for the ARP hardware type (e.g., Ethernet) and protocol type (e.g., IPv4).
2. Create and send an ARP request packet:
- Create a socket using the `socket()` function with the `AF_PACKET` address family and
`SOCK_RAW` socket type.
- Create an ARP request packet using the defined ARP header structure.
- Set the appropriate values for the fields in the ARP header, such as the hardware type, protocol
type, operation (request), sender hardware and protocol addresses, and target protocol address.
- Create and set a `struct sockaddr_ll` structure to specify the interface index, destination MAC
address, and other necessary information for sending the packet.
- Use the `sendto()` function to send the ARP request packet using the socket descriptor and the
destination address structure.
3. Receive and process ARP packets:
- Create a socket using the `socket()` function with the `AF_PACKET` address family and
`SOCK_RAW` socket type.
- Use a loop to continuously receive packets using the `recvfrom()` function and the socket
descriptor.
- Extract the received packet and analyze its contents.
- Parse the ARP header from the received packet and examine the operation field to determine if it
is an ARP request or response.
- Process the ARP packet accordingly, such as updating an ARP cache or responding to ARP
requests.
Note: Implementing the full functionality of ARP, including caching, table management, and
handling ARP requests and responses in a network environment, can be complex. The above steps
provide a high-level overview, but a complete implementation would require further details and
handling of specific use cases.
Remember to include the necessary header files (`<stdio.h>`, `<stdlib.h>`, `<string.h>`,
`<sys/socket.h>`, `<netinet/if_ether.h>`, etc.) and handle errors appropriately in your code.
Additionally, consider working with lower-level networking libraries or using a network packet
capture library like libpcap for handling raw sockets and packet capturing.
60
Result: Thus the ARP protocols in JAVA/C are implemented successfully.
Date:
EXPERIMENT: 32
61
different inputs.
Result : Therefore bit suffering mechanism has been successfully implemented using c program.
Date:
EXPERIMENT: 33
IMPLEMENTING THE APPLICATIONS USING TCP FILE TRANSFER IN JAVA/C
62
- Read the contents of the file in chunks and send them over the TCP connection using the `send()`
function.
- Close the file using `fclose()`.
3. Client-side implementation:
- Receive the file data from the server using the `recv()` function on the client side.
- Write the received data to a file on the client side using `fwrite()`.
- Continue receiving and writing data until the entire file is received.
- Close the file using `fclose()`.
Result: Thus the applications using TCP file transfer in java is completed successfully.
Date:
EXPERIMENT: 34
IMPLEMENTING THE SIMULATION OF ERROR CORRECTION CODE – CRC IN
JAVA/C
63
In this code, the `calculate CRC` function takes an input data array and its length. It performs the
CRC calculation by iterating through each bit of the data and performing XOR and shift operations.
The function returns the calculated CRC value.
In the `main` function, a test data array is defined along with the expected CRC value. The `calculate
CRC` function is then called to calculate the CRC for the test data. The calculated and expected CRC
values are printed, and a comparison is made to check if they match.
Result: The simulation of error correction code – CRC in java is implementation successfully.
Date:
EXPERIMENT: 35
IMPLEMENTION OF SLIDING WINDOW PROTOCOL IN JAVA/C
64
Result: Hence implementation of sliding window protocol was done successfully in java.
65