Professional Documents
Culture Documents
Tech CSE
Exp No. 1
BASICS OF NETWORK CONFIGURATION FILES AND NETWORKING
COMMANDS IN LINUX
Getting started with the basics of network configuration files and networking
commands in Linux.*
Files Description
ifcfg-lo Stores the configuration of loopback device. Loopback device is a
virtual network interface. It is used to test the TCP/IP protocol
stocks in local host.
ifcfg-* Stores the configuration of the network interface. Each file only
stores the configuration of that interface, which it represents.
Directive Description
BOOTPROTO Defines how the IP address should be obtained. Four values can
be used here; dhcp, bootp, none and static. Use the
value "dhcp", to obtain IP from the dhcp server. To boot from
a network boot server and get IP, use the value "bootp". To
assign IP manually, use the value "static". Use the
value "none" if you don't want to assign the IP address.
BRIDGE Specifies the name of the network bridge.
BROADCAST0 Broadcast address of the first IP configuration.
GATEWAY0 Gateway address of the first IP configuration.
DEFROUTE Specifies whether to use this interface as the default route or
not.
DEVICE Device name of the network interface.
DNS1 IP address of the first DNS server.
HWADDR Hardware address of the network interface.
IPADDR0 Specifies the first IP address of interface.
IPV6INIT Specifies whether to enable to IPv6 or not.
NAME Name of the interface. If not assigned manually, the device
name will be used.
NETMASK0 Netmask or subnet mask address of the first IP configuration.
NM_CONTROLLED Specifies whether the Network Manager service is allowed to
modify the settings stored in this file or not.
ONBOOT Whether to activate or not this interface on boot.
USERCTL Specifies whether the non-root users are allowed to activate
this interface or not.
UUID Unique ID of this interface.
TYPE Type of this interface.
Settings stored in the interface’s configuration file are applied on the interface when we start the
system or activate the interface. To view these settings, cat command is used.
The following table lists important directives of this file with description.
In addition to the individual network interface configuration files in the /etc/sysconfig/network-
scripts directory, there are other, more global network configuration files. These files are:
etc/hosts file
This file is used to map the hostname with IP address. Once hostname and IP address are mapped,
hostname can be used to access the services available on the destination IP address. A hostname
can be mapped with an IP address in two ways; through the DNS server and through the /etc/hosts
file.
DNS server provides this facility in more dynamic and flexible way but also requires a lot of
complex configurations. Due to complexity, usually DNS server is not used in small
networks.The /etc/hosts file also provides this functionality in local system but requires manual
mapping of all hostnames with their IP addresses.Each row in this file represents a unique entry.
It contains an IP address in the first column, full or official hostname in the second column and
short or alias name in third column.
/etc/resolv.conf
The resolver configuration file provides access to DNS. This file usually has at least two lines,
one line specifying the IP address of a DNS server (or name server) and the other specifying the
search domain. The following example shows the name servers and the search domain:
#cat /etc/resolv.conf
search example.com
nameserver 192.168.154.2
nameserver 172.168.106.3
nameserver 193.32.3.25
/etc/sysconfig/network
Based on how the network interfaces are configured, this filemay contain none, one or two
configuration directives. If a system is configured to get IP configuration from the DHCP server,
there will be no configuration in this file.
Two directives that may appear in this file are; GATEWAY and NETWORKING.
GATEWAY directive shows the IP address of default gateway. This directive appears only if
the same IP address is used for the default gateway in all network interfaces.
NETWORKING directive is used to control the network service. It can be configured with two
values; yes and no. If the value "no" is used, the network service does not start.
Department of Computer Science and Engineering Page 18
Toc H Institute of Science and Technology, Arakkunnam
CSL 332 Networking Lab, B. Tech CSE
/etc/nsswitch.conf
This file is the system databases and name service switch configuration file. It provides
sources for common configuration databases and name resolution mechanisms. Entries
in this file identify the database name in the first field, then a colon, and then a list of
possible resolution mechanisms in the second field. The order in which the mechanisms
are listed determines the order in which queries on the specified database are resolved.
The following example indicates that host name resolution is attempted first by querying
local files, that is, /etc/hosts, and then by querying the DNS server if the host name is not
resolved:
# cat /etc/nsswitch.conf
...
hosts: files dns...
The "ipaddr show" command displays the current configuration and status of all
network interfaces. This command is used to know or view the following information.
To view information only about a specific interface, specify that interface’s name or ID
with the commands.
b)Test the network connectivity between your computer and several other computers.
To check connectivity between two computers,use the ping command. The ping command uses
the following syntax.
#ping [ip address or name of remote system]
By default, the ping command works continuously. To stop this command, press the ctrl+c keys.
If reply from the remote system is there, both systems are connected.
c)View the active TCP connections in the computer after visiting a website.
d)Find the hardware/MAC address of another computer in the network using ARP
ARP table contains hardware address (MAC address) and software address (IP address) of
other systems available in LAN network. By default, a system builds and uses this table to
connect with other systems in LAN network.To view this table, use the ip neigh command.
Sample output
Result:
Observed network configuration files and executed various networking commands in Linux.
Exp No. 2
SYSTEM CALLS USED FOR NETWORK PROGRAMMING IN LINUX
To familiarize and understand the use and functioning of system calls used for
network programming in Linux.
a)Write the system calls used for creating sockets and transferring data between two
nodes.
AIM: To study system calls used for creating sockets and transferring data between two
nodes.
Sockets are a form of interprocess communication that exists between two unrelated
processes which allows us to communicate over the internet using streams (TCP-
Transmission Control Protocol) or datagrams (UDP-User Datagram Protocol).
Server is started first; it will accept connections from the client. Once a connection is established,
then communication can occur through the read and write system calls to the file descriptor
associated with the socket.
socket
#include<sys/types.h>
#include<sys/socket.h>
int socket(int family, int type, int protocol);
Usage
s = socket(AF_INET, SOCK_STREAM, 0);
s is a small integer value, similar to a file descriptor with five pieces of information (5-
tuple):
The family AF_INET indicates that the socket will be created in the internet domain. The
AF_ prefix stands for "address family."SOCK_STREAM indicates that it will be a
connection-oriented protocol. SOCK_DGRAMindicates that it will be a connectionless
protocol.0 indicates to automatically fill in the protocol, which will be TCP when
SOCK_STREAM is used and UDP when SOCK_DGRAM is used.
bind
Usage
bind(s,(struct sockaddr *)&saddr,sizeof(saddr))
There are three uses of bind. Servers register their well-known address with the system.
It tells the system "this is my address and any messages received for this address are to be given
to me." Both connection-oriented and connectionless servers need to do this before accepting
client requests.A client can register a specific address for itself.A connectionless client needs to
assure that the system assigns it some unique address, so that the other end (the server) has a
valid return address to send its responses to.
connect
A client process connects a socket descriptor following the socket system call to establish a
connection with a server.
#include <sys/types.h>
#include <sys/socket.h>
listen
This system call is used by a connection-oriented server to indicate that it is willing to receive
connections.
#include <sys/types.h>
#include <sys/socket.h>
It is usually executed after both the socket and bind system calls, and immediately before the
accept system call. The backlog argument specifies how many connection requests can be
queued by the system while it waits for the server to execute the accept system call. This
argument is usually specified as 5, the maximum value currently allowed.
accept
After a connection-oriented server executes the listen system call described above, an actual
connection from some client process is waited for by having the server execute the accept system
call.
#include <sys/types.h>
#include <sys/socket.h>
int accept(int sockfd, struct sockaddr *peer, int *addrlen);
accept takes the first connection request on the queue and creates another socket with the same
properties as sockfd. If there are no connection requests pending, this call blocks the caller until
one arrives.
The peer and addrlen arguments are used to return the address of the connected peer process (the
client). addrlen is called a value-result argument: the caller sets its value before the system call,
and the system call stores a result in the variable. For this system call the caller sets addrlen to
the size of the sockaddr structure whose address is passed as the peer argument.
These system calls are similar to the standard read and write system calls, but additional
arguments are required.
#include <sys/types.h>
#include <sys/socket.h>
The normal Unix close system call is also used to close a socket.
int close(int fd);
If the socket being closed is associated with a protocol that promises reliable delivery (e.g.,
TCP ), the system must assure that any data within the kernel that still has to be transmitted or
acknowledged, is sent.
Results:
Familiarized and understood the system calls used in socket programming in Linux.
Exp No. 3
CLIENT-SERVER COMMUNICATION USING TCP SOCKET PROGRAMMING
AIM: To implement calculator using socket programming and TCP as transport layer protocol
in C
Server
client
Multi-user Chat
To implement chat server the select function is used. It is a function called by a process.
When aprocess calls this function, the processgoes tosleep and wakes up only when one or
moreeventsoccurorwhen aspecified amount of timehas passed.
intselect(int maxfdp1,fd_set*readset,fd_set*writeset,fd_set*exceptset,conststructtimeval
*timeout);
Theheaderfilesrequired are<sys/select.h>and<sys/time.h>
The function returns -1 on error, count of ready descriptors and 0 on timeout. If we want the
kernel towait for as long as one descriptor becomes ready then we specify the timeout
argument as a nullpointer. readset, writeset and exceptset specify the descriptors that we
want the kernel to test forreading, writing and exception conditions. select uses descriptor
sets. Each set is an array of integers.Each bit in an integer corresponds to a descriptor. In a
32 bit integer, the first element of the arrayrepresents descriptors from 0 to 31. Second
element of the array represents descriptors from 32 to 63andso on. Wehavefourmacros
forthefd_set datatype.
client1
client2
Result:
The program hasbeen executed successfully and the output is obtained and verified.
Exp No. 4
CLIENT-SERVER COMMUNICATION USING UDP SOCKET PROGRAMMING
AIM:
To exchange datagrams from client to server using UDP socket.
ALGORITHM:
Server
1. Create a UDP socket.
2. Bind the socket to the server address.
3. Wait until the datagram packet arrives from the client.
4. Process the datagram packet and send a reply to the client.
5. Go back to Step 3.
Client
1. Create a UDP socket.
2. Send a message to the server.
3. Wait until response from the server is received.
4. Process reply and go back to step 2, if necessary.
5. Close socket descriptor and exit.
server
client
Result:
The program hasbeen executed successfully and the output is obtained and verified.
b. Implement a Concurrent Time Server application using UDP to execute the program
at a remote server. Client sends a time request to the server, server sends its system time
back to the client. Client displays the result.
AIM: Clients to send time request to the server, server send its system time back to the client.
Description:
A concurrent server handles multiple clients at the same time. The simplest technique for a
concurrent server is tocall the Unix fork function, i.e; creating one child proces s for each
client.
The current time and date is obtained by the library function time which returns the number
of secondssince the Unix Epoch: 00:00:00 January 1, 1970, UTC (Coordinated Universal
Time). ctime is afunctionthat converts this integer value into a humanreadable string.
Algorithm:
Client
1. Create UDP socket
2. Send a request for time to the server
3. Receive the time from the server
4. Display the result
Server
Server
Client
Result:
The program has been executed successfully and the output is obtained and verified.
Exp No. 5
SIMULATE SLIDING WINDOW FLOW CONTROL PROTOCOLS
a. Simulate the Stop and Wait sliding window flow control protocol.
AIM: To implement a program for the Stop and Wait sliding window flow control protocol.
Description:
A sliding window protocol with a maximum window size of one is a protocol uses stop-and-wait
since the sender transmits a frame and waits for its acknowledgement before sending the next
one starting machine fetches the first packet from its network layer, builds a frame from it, and
sends it. When this frame arrives, the receiving data link layer checks to see if it is a duplicate.
If the frame is the one expected, it is passed to the network layer and the receiver's window is
slid up. The acknowledgement field contains the number of the last frame received without error.
If this number agrees with the sequence number of the frame the sender is trying to send, the
sender knows it is done with the frame stored in buffer and can fetch the next packet from its
network layer. If the sequence number disagrees, it must continue trying to send the same frame.
Algorithm:
1. Start.
2. Transmit the first frame
3. Receive the acknowledgement for the first frame
4. Transmit the next frame
5. If an acknowledgement is not received for a particular frame, retransmit that frame.
6. Repeat the steps 5 to 7 till the number of frames reaches the limit.
7. Stop.
Result:
The program has been executed successfully and the output is obtained and verified.
Exp No. 6
IMPLEMENT AND SIMULATE ALGORITHM FOR DISTANCE VECTOR
ROUTING PROTOCOL
AIM:A program for distance vector algorithm to find suitable path for transmission.
Description:
Distance vector routing algorithms operate by having each router maintain a table giving
the best known distance to each destination and which line to get there. These tables are
updated by exchanging information with the neighbour's. In distance vector routing,
each router maintains a routing table indexed by, and containing one entry for, each
router in subnet. This entry contains two parts: the preferred outgoing line to use for that
destination, and an estimate of the time or distance to that destination.The router is
assumed to know the "distance" to each of its neighbour. If the metric is hops, the
distance is just one hop. If the metric is queue length, the router simply examines each
queue.
Here Bellman-Ford algorithm is used to implement distance vector routing algorithm.
Algorithm:
1. Start
2. The distance of the node to itself is assigned to zero and when a node is unreachable the
distance is accepted as 999.
3. Accept the input distance matrix from the user (costmat[][]) that represents the distance
between each node in the network.
4. Store the distance between nodes in a suitable variable.
5. Calculate the minimum distance between two nodes by iterating.
6. If the distance between two nodes is larger than the calculated alternate available path,
replace the existing distance with the calculated distance.
7. Print the shortest path calculated.
8. Stop.
Result:
The program hasbeen executed successfully and the output is obtained and verified.
Exp No. 7
IMPLEMENTATION OF FILE TRANSFER PROTOCOL
AIM: -
Program to implement simple FTP server for file transfer to server.
Algorithm:
Server:
1. Start
2. Declare the variables and structures
3. Create a socket using socket function
4. The socket is binded to a specific port.
5.Start Listening for the Connection
6. Accept the Connection from the client
7. Receive the data from the client
8.Write the data into the file
9. Stop.
Client:
1.Start
2. Declare the variables and structures
3. Create a socket and execute the connection function
4. Open a new file with some contents
5. Read the data from the file and written to a new file by the server.
6. The content is displayed.
7. Close the Connection.
ftpserver
ftpclient
hellocopy.txt
Result:
The program has been executed successfully and the output is obtained and verified.
Exp No. 8
LEAKY BUCKET ALGORITHM
AIM:To implementa program for congestion control using Leaky bucket algorithm.
Description:
It is a single-server queueing system with constant service time. Imagine a bucket with a small
hole in the bottom. No matter the rate at which water enters the bucket, the outflow is at a
constant rate, when there is any water in the bucket and zero when the bucket is empty. Also,
once the bucket is full, any additional water entering it spills over the sides and is lost (i.e., does
not appear in the output stream under the hole). The same idea can be applied to packets.
Conceptually, each host is connected to the network by an interface containing a leaky bucket,
that is, a finite internal queue. The leaky bucket consists of a finite queue. When a packet arrives,
if there is room on the queue it is appended to the queue; otherwise, it is discarded. At every
clock tick, one packet is transmitted.
Algorithm:
1. Start.
2. Set the bucket size or the buffer size.
3. Set the output rate.
4. Transmit the packets such that there is no overflow.
5. Repeat the process of transmission until all packets are transmitted. (Reject packets
where its size is greater than the bucket size).
6. Stop.
Result:
The program has been executed successfully and the output is obtained and verified.
Exp No. 9
UNDERSTANDING THE WIRESHARK TOOL
AIM
To understand the packet capturing tool called WireShark.
Description
WIRESHARK
A packet sniffer also known as packet analyzer or a network analyzer or protocol analyzer
is a computer program or a piece of computer hardware that can intercept and log traffic passing
over a digital network or part of a network. As data streams flow across the network, the sniffer
captures each packet and, if needed, decodes the packet's raw data, showing the values of various
fields in the packet, and analyzes its content according to the appropriate specification.Packet
capture is the process of intercepting and logging traffic.
Wireshark is a free and open-source packet analyzer. It is used for network
troubleshooting, analysis, software and communications protocol development, and education.
A network packet analyzer will try to capture network packets and tries to display that packet
data as detailed as possible. A network packet analyzer can be considered as a measuring device
used to examine what's going on inside a network cable, just like a voltmeter is used by an
electrician to examine what's going on inside an electric cable. In the past, such tools were either
very expensive, proprietary, or both. However, with the advent of Wireshark, all that has
changed. Wireshark is perhaps one of the best open source packet analyzers available today.
Originally named Ethereal, in May 2006 the project was renamed Wireshark. Wireshark is cross-
platform, using the GTK+ widget toolkit to implement its user interface, and using pcap to
capture packets.It runs on various Unix-like operating systems including Linux, OS X, BSD, and
Solaris, and on Microsoft Windows.
PURPOSES
The main purposes of Wireshark are:
⮚ Network administrators use it to troubleshoot network problems
⮚ Network security engineers use it to examine security problems
⮚ Developers use it to debug protocol implementations
⮚ People use it to learn network protocol internals
FEATURES
The following are some of the many features Wireshark provides:
⮚ It works in promiscuous and non-promiscuous mode.
⮚ Promiscuous mode allows to see all the packets that the interface can see,even those
destined for other machines.
⮚ Non promiscuous mode captures only; allows to see packets destined for your machine,
which includes broadcast packets and multicast packets if your machine is part of a
multicast group.
⮚ Live data can be read from a number of types of network, including Ethernet, IEEE
802.11, PPP,and loopback.
⮚ Data display can be refined using a display filter.
⮚ Available for UNIX and Windows.
⮚ Capture live packet data from a network interface.
⮚ Display packets with very detailed protocol information.
⮚ Filter and Search packets on many criteria. Colorize packet display based on filters.
WIRESHARK INTERFACES
Menu
The Wireshark menu sits on top of the Wireshark window
File
This menu contains items to open and merge capture files,save/print/export capture files
in whole or in part,and to quit from Wireshark.
File Set > List Files : To show a list of files in a file set. ox .
File Set > Next File : If the currently loaded file is part of a file set, jump to the next file in the
set. If it isn't part of a file set or just the last file in that set, this item is greyed out.
File Set > Previous File : If the currently loaded file is part of a file set, jump to the previous
file in the set. If it isn't part of a file set or just the first file in that set, this item is greyed out.
Export > File : To export all (or some) of the packets in the capture file to file.
Export > Selected Packet Bytes : To export the currently selected bytes in the packet bytes pane
to a binary file.
Print : To print all (or some) of the packets in the capture file.
Quit : To quit from Wireshark.
Edit
This menu contains items to find a packet, time reference or mark one or more packets,
handle configuration profiles, and set your preferences.
Copy > Description : To copy the description of the selected item in the detail view to the
clipboard.
Copy > Fieldname : To copy the fieldname of the selected item in the detail view to the
clipboard.
Copy > Value : To copy the value of the selected item in the detail view to the clipboard.
Copy > As Filter : To use the selected item in the detail view to create a display filter.
Find Packet : To allows you to find a packet by many criteria.
Find Next : This menu item tries to find the next packet matching the settings from "Find
Packet..."
Find Previous : To find the previous packet matching the settings from "Find Packet..."
Mark Packet (toggle) : This menu item "marks" the currently selected packet.
Unmark All Displayed Packets : This menu item "unmarks" all displayed packets.
Find Next Mark : Find the next marked packet.
Find Previous Mark : Find the previous marked packet.
View
This menu controls the display of the captured data, including colorization of packets,
zooming the font, showing a packet in a separate window, expanding and collapsing trees in
packet details.
Department of Computer Science and Engineering Page 47
Toc H Institute of Science and Technology, Arakkunnam
CSL 332 Networking Lab, B. Tech CSE
Go
This menu contains items to go to a specific packet.
Capture
This menu allows you to start and stop captures and to edit capture filters
Interfaces... This menu item brings up a dialog box that shows what's going on at the
network interfaces Wireshark knows of.
Analyze
This menu contains items to manipulate display filters, enable or disable the dissection
of
protocols, configure user specified decodes and follow a TCP stream.
Display Filters : This menu item brings up a dialog box that allows you to create and edit display
filters.
Telephony
This menu contains items to display various telephony related statistic windows,
including a media analysis, flow diagrams, display protocol hierarchy statistics and much more.
Statistics
This menu contains items to display various statistic windows, including a summary of
the packets that have been captured, display protocol hierarchy statistics and much more.
Tools
This menu contains various tools available in Wireshark, such as creating Firewall ACL
Rules.
Internals
This menu contains items that show information about the internals of Wireshark.
Help
This menu contains items to help the user, e.g. access to some basic help, manual pages
of the various command line tools, online access to some of the web pages, and the usual about
dialog.
AIM: To investigate the protocols used in each packet, the values of the header fields and the
size of the packet.
AIM: To observe Three Way Handshaking Connection Establishment, Data Transfer and Three
Way Handshaking Connection Termination in client server communication using TCP.
Theory:
Assume that both host (A) and server (B) side start from CLOSED status.
1. The server process create a TCB and use TCB prepares to accept the host's request.
After TCB born the server change status to LISTEN.
2. The host does the same thing, create a TCB and use this TCB to send request, set the "SYN=1"
in the request header, and initates a arbitrary sequence number, seq=x. SYN paccket (which
means SYN=1) can not take any data content, but it will consume a sequence number. After
request sent, the host goes into SYN-SENT status.
● i. If the server accept to this connection, it will send back a confirm response. In the
response both SYN and ACK bits should be '1', and server side also initiates a SEQ
number, seq=y. The server will send its sequence number within packet which is used to
be acknowledged to the clinet's SYN packet. This packet can not take any data content
either, but it consumes a sequence number. So in this packet seq=y, ack=x+1. And the
server goes into SYN-RCVD status.
● ii. If the server rejects the connection, it just responses a RST packet to reset the
connection.
4. After the host received the server's response, it will send back also a confirm packet with ACK
bit sets to '1' and seq=x+1, ack=y+1.
After that, both side gose into ESTABLISHED status. This is what we called three-way
handshake.
Output:
c. Explore at least the following features of Wireshark: filters, Flow graphs (TCP),
statistics, and protocol hierarchies.
AIM: To explore filters, Flow graphs (TCP), statistics, and protocol hierarchies
Statistics
Protocol hierarchies
Result:
Explored wireshark tool and its features.
Exp No. 10
CONFIGURING A NETWORK
Design and configure a network (wired and wireless LANs) with multiple subnets using
required network devices.Configure at least three of the following services in the network-
TELNET, SSH, FTP server, Web server, File server, DHCP server and DNS server
a. Design and configure a network (wired and wireless LANs) with multiple subnets
using required network devices
For serial links only 2 ip addresses are required so we can use /30 as subnet mask ie,
255.255.255.252 is subnet mask. Each new subnets will be multiples of 4.so
192.168.10.0/30 (exacluding base network) , the subnetwork addresses are ,
192.168.10.4/30
192.168.10.8/30
192.168.10.12/30, for addressing the 3 serial links.
Then for 10 and 12 host need 4 bits in host part/28 or 255.255.255.240 is new subnet mask ,
with this subnetmask we can create the 2 subnets,
192.168.10.16/28
192.168.10.32/28 for the subnets.
For next 18 hosts and 28 hosts need 5 bits in host part and remaining 3 bits can be borrowed to
network part and the new subnet mask is 255.255.255.227 or /27
For the last 28 hosts the new subnet address is
192.168.10.64/27
192.168.10.96/27.
Then for the wireless network we can give the subnet mask as 192.168.10.128/26 and using
this subnet mask we can address 64 wireless devices.
Thus by using VLSM , with the same network address we can address all the 7 subnets and a
wireless network.
b.Configure at least three of the following services in the network- TELNET, SSH, FTP
server, Web server, File server, DHCP server and DNS server
Step 1: First, open the cisco packet tracer desktop and select the devices and create a network
topology like this.
Step 2: Configure the Server with IPv4 address and Subnet Mask.
Parameters Address value
Default-Gateway 172.168.10.1
• Repeat the same procedure with other PCs to configure them thoroughly.
1. Select a 2911 Router from Network Devices and drag and drop to the workspace.
2. Select Router0 and Go to Config.
3. Configure the FastEthernet0/0by assigning IP address as 192.168.1.1 and subnet mask as
255.255.255.0 and turn on the port status
4. Configure the FastEthernet1/0by assigning IP address as 10.0.0.1 and subnet mask as
255.0.0.0 and turn on the port status.
Pc0
Checking connections from PC1 to the other hosts in the network using ping Command in
Command Prompt.
Writing(uploading) the file named 2.txt into FTP Server from PC0 using put 2.txt command
and verifying this file transfer using dir command.
Reading(Downloading) the file named 2.txt present in FTP Server from PC1 using get 2.txt
command and verifying this file transfer using dir command.
A Domain Name System (DNS) server resolves host names into IP addresses.
PC0
PC1
To do this, click on the server, then Click on Services tab. Click on DNS server from the
menu. First turn ON the DNS service, then define names of the hosts and their
corresponding IP addresses
Click on add then save. Repeat this for the PC1 and the server.
Finally,
4. Test domain name – IP resolution. Ping the hosts from one another using their names
instead of their IP addresses. If the DNS service is turned on and all IP configurations are okay,
then ping should work.
Result:
Explored design and configuration of networks and how to configure commonly used services
in the network
.
Exp No. 11
STUDY OF NS2 SIMULATOR
a) The network consists of TCP source node (n0) and destination node (n1) over an area
size of 500m x 500m. Node (n0) uses Agent/TCP/Reno as the sending TCP agent and FTP
traffic source. Node (n1) is the receiver of FTP transfers, and it uses Agent/TCP sink as
its TCP-agent for the connection establishment. Run the simulation for 150 seconds and
show the TCP window size in two static nodes scenario with any dynamic routing
protocol. Run the script and analyze the output graph for the given scenario.
Simple two node wired network(TCP Connection)
Output:
Figure1:
Sending
TCP Packet
Receiving acknowledgment
b. Simulate the transmission of ping messages over a star network topology consisting of
‘n’ nodes and find the number of packets dropped due to congestion using NS2simulator
Description:
The network for this experiment uses six nodes n0 to n5. In this scenario, node n1 sends
constant bit-rate (CBR) traffic to node n5 using UDP agent. The UDP traffic travels
through n2 and n3 before reaching n5. Both n0 and n4 node sends ping message at
certain time intervals. Ping messages are dropped from the network when the traffic
through node n2 and n3 is full.
Output
In the output obtained there is a normal flow of packets from node 1 to node 4. We now
disable the link between nodes 2 and 3 at time 1 and the simulations changes as shown
below. The disabled link is shown in red and the packet flow this time changes direction
rather than the original route to node 4
Result :
Simulated NS2 .
ADDITIONAL
&
OPEN ENDED EXPERIMENTS
Exp No. 12
ADDITIONAL EXPERIMENT
a. Implement TCP bidirectional communication between client and server
Note: Input a string at client, Server to reverse the string, Reversed string to be displayed at
client.
AIM:
To connect server and client using TCP socket and to exchange messages.
ALGORITHM:
Server
1. Create a socket with the socket() system call.
2. Initialize the socket address structure and bind the socket to an address using the bind()
system call.
3. Listen for connections with the listen() system call.
4. Accept a connection with the accept() system call. This call typically blocks until a client
connects to the server.
5. Receive and send data by using recv() and send().
6. Close the connection by using the close().
Client
1. Create a socket with the socket() system call.
2. Initialize the socket address structure as per the server and connect the socket to the
address of the server using the connect() system call.
3. Receive and send the data using the recv() and send().
4. Close the connection by calling the close() function.
Client
Result:
The program has been executed successfully and the output is obtained and verified.
Exp No. 13
OPEN ENDED EXPERIMENT
CONCURRENT FILE SERVER
AIM:-
To develop a concurrent file server which will provide the file requested by client if it
exists. Ifnot, server sends appropriate message to the client. Serversends its process ID
(PID) to clients fordisplayalongwith fileorthe message.
Description:
The file server creates listening sockets on two ports that have consecutive port numbers.
One is thelistening socket for control connection and the other is the listening socket for data
connection. Thesesockets have descriptors listen_controland listen_datarespectively. The
client creates a socket andconnects to the server using TCP connection.The client socket
descriptor is stored in sock_ctrl. Theserver creates a connection socket when the client makes
a TCP connection with the server. Thisconnection socket is stored in sock_ctrl. This
connection is for control information to pass betweenclient and server. Next, the server forks
a child process. Since the child is a perfect image of its parent,the child process will also
have descriptorslisten_control, listen_dataand sock_ctrl. The controlconnection will also be
duplicated between the client and the child process. The child process closes its listening
socket for control connection, i.e; listen_control. The parent server process closes its
connection socket for the control connection i.e; sock_ctrl. The client now makes a TCP
connection with the server for transferring data is stored in sock_data.The connection socket
for the data connectionis stored insock_datain theserver child process.
Algorithm
Client
1. Create the client TCP control connection to a port (port_num) of the server with
the client socket descriptor sock_ctrl.
2. while(1)
2.1 Create client socket descriptor sock_data for the data connection with server on
another port (portnum + 1). For each file transfer a new data connection is required.
2.2 Read the command from the terminal given by the user
2.3 Send the command to the server using control socket sock_ctrl.
2.4 If command == “close”
close sock_data and sock_ctrl
break
else
Enter the filename using the keyboard
Write the filename using control socket sock_ctrl to the server.
2.5 Use connect() for the data connection.
2.6 read data using sock_data (file contents) from the server and write to the file
If file does not exist print the process id of server
Server
1. Initialize variable file_present to 1
2. Create listening socket for the control connection on port (port_num) and store it
in listen_control.
3. Create a listening socket for the data connection on port (port_num +1) and store
it in listen_data
4. while (1)
4.1 accepts the client control connection and returns the connect socket descriptor
sock_ctrl
4.2 fork a child process
if(childprocess)
close listening socket listen_control
4.2.1 while(1)
4.2.1.1 read command from the client on the control connection
if command == “close”
break
else
open the file
if (no file)
form a string “@FILE NOT FOUND PROCESS ID =
getprocess id” and store it in variable buffer
file_present = 0;
4.2.1.2 accept the data connection and return the socket descriptor
sock_data
4.2.1.3 if(file_present)
read file contents and write to sock_data
form a string “FILE filename RECEIVED FROM
SERVER WITH PROCESS ID = getprocess id” and store
it in variable buffer
else
write buffer using sock_data to the client
file_present = 1;
4.2.2 close all socket-descriptors.
child process exits
Result:
The program hasbeen executed successfully and the output is obtained and verified.
1. What is a socket?
A socket is used to connect an application to a network protocol. A socket enables
communication between a client and a server. The communication is started when the client
is assigned a local port number, and binds a socket to it. The client writes on the socket and
gets information from server by reading it.
Class D: It has first, second and third bit value as 1 and the fourth bit as 0. The other 28 bits
are used for identifying the group of computers which is intended for multicast messages.
Class E: Class E is used for identification purpose. The four bits value is 1. The other 28 bits
are used for identifying the group of computers which is intended for multicast messages
to track or trace the path the packet takes from the computer where the command is given
until the destination. In windows ping command is written as tracertip_address
63. Define IP ?
Internetwork protocol (IP) is the transmission mechanism used by TCP/IP protocol.It is an
unreliable and connectionless datagram protocol.It provides no error checking and tracking.
65. What are the information that a PC attached to a TCP/IP internet must
possesses ?
Each computer attached to TCP/IP must possesses the following information
• Its IP addesss
• Its subnet mask
• The IP addesss of the router.
• The Ip address of the name server.
Switches, on the other hand, are capable of determining the destination of each individual
traffic element (such as an Ethernet frame) and selectively forwarding data to the one
computer thatactually needs it. By generating less network traffic in delivering messages, a
switch performs better than a hub on busy networks.
Unicast: A term used in communication to describe a piece of information to send from one
point to another. There are only sender and receiver. All LANs support unicast transfer mode
and most applications that employ TCP transport protocol uses unicast messaging.
Broadcast: A term used for describing communication that is sent a piece of information from
one point to all other points. There is one sender and multiple receivers. All LANs support
broadcast transmission.
Multicast: A term described in communicating a piece of information sent from one or more
points to a set of other points. The senders and receivers are one or more.
REFERENCES
Reference Books: