0% found this document useful (0 votes)
15 views48 pages

CN Lab Manual Master

The document is a lab manual for the Computer Networks Lab at Meerut Institute of Engineering and Technology, outlining the vision and mission of the institute, along with various course objectives related to networking concepts and programming. It includes a list of experiments, practical objectives, and important questions related to networking devices, OSI model simulation, and Aloha protocols. The manual serves as a guide for B.Tech 3rd year students in the CSE-AIML department to gain hands-on experience in computer networking.

Uploaded by

fffcv9035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views48 pages

CN Lab Manual Master

The document is a lab manual for the Computer Networks Lab at Meerut Institute of Engineering and Technology, outlining the vision and mission of the institute, along with various course objectives related to networking concepts and programming. It includes a list of experiments, practical objectives, and important questions related to networking devices, OSI model simulation, and Aloha protocols. The manual serves as a guide for B.Tech 3rd year students in the CSE-AIML department to gain hands-on experience in computer networking.

Uploaded by

fffcv9035
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

MEERUT INSTITUTE OF ENGINEERING AND

TECHNOLOGY MEERUT

LAB MANUAL
(Computer Networks Lab)

DR. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY LUCKNOW


B. TECH 3rd YEAR
DEPARTMENT OF CSE-AIML

1
Vision of Institute

To be an outstanding institution in the country imparting technical education, providing need-


based, value-based and career-based programs and producing self-reliant, self-sufficient
technocrats capable of meeting new challenges.

Mission of Institute

The mission of the institute is to educate young aspirants in various technical fields to fulfill
global requirement of human resources by providing sustainable quality education, trai ning and
invigorating environment besides molding them into skilled competent and socially responsible
citizens who will lead the building of a powerful nation.

COs
1. To understand the basic concepts of networking devices and connectivity.

2. Implement some important functions of computer networks using C-

programming.

3. Write a C-program for IPv4: implementation of decimal to binary and binary to


decimal notations of IP addresses.
4. To implement a client/server chatting program using socket programming.

5 To design and configure a network using Cisco Packet Tracer. Also, use

Wireshark for analysis of network traffic.

2
S.No.

Name of the Experiment Page no.

Running and using services / commands like ping, trace route, nslookup, 5
arp etc. (Verify the connectivity of your workstation to the internet.)
1a

9
To study network CONNECTING DEVICES.
1b

Write a C program:

13
For OSI model simulation.
2

For ALOHA and Slotted ALOHA. 15

17

4 To count Even and Odd Parity.

For stuffing & De- stuffing of Bits. 19

For stuffing & De- stuffing of Bits. 20

To implement Cyclic Redundancy Check (CRC). 24

26
To implement RSA Algorithm (Encryption and Decryption).
8

For IPv4, implementation of decimal to binary and binary to decimal. 28

3
Value Addition:

To analyze the packet transmission in the network using Wireshark. 31

10a

Implementation of Socket programming using UDP and TCP. 37

10b

To build a network and analyzing the packet transmission using packet 45


tracer.
10c

4
Practical no. 1a

Objective: Running and using services / commands like ping, trace route, nslookup,
arp etc . (Verify the connectivity of your workstation to the internet).

Experiment
1. Verify the connectivity of your workstation to the internet.
2. Open the Command Prompt of the operating system using either of the following
methods:
Click on Start > All Programs > Accessories > Command Prompt or
Click on Start > Run, enter cmd (short for command) and click on ok.
A Command Prompt screen should open.
3. Gather TCP/IP configuration information: Type ipconfig (short for IP configuration)
and press Enter. The screen will show the IP address, subnet mask, and default
gateway for your computer’s connection.
Notice the values in the Command Prompt. The IP address and the default gateway should
be in the same network or subnet, otherwise this host would not be able to commu nicate
outside the network. In figure 1, the subnet mask tells us that the first three octets of the IP
address and the default gateway must be the same in order to be in the same network.

Fig. 1. The TCP/IP configuration information of a workstation

4. Check more detailed TCP/IP configuration information: Type ipconfig /all and
press Enter. What are the DNS and DHCP server addresses? What are their
functions? What is the MAC of the network interface card?

5
5. Ping the IP address of another computer. Note that for the ping and tracert
commands to work the PC firewalls have to be disabled. Why do you think this is so?
Ask the IP address of the workstation that is being used by another group o f
students. Then type ping, space, and the IP address that you received, then press
Enter. Notice the outputs. Figure 2 shows a successful result of a ping to a given IP
address.

Fig. 2. A successful result of a ping to a certain IP address

6. Ping the IP address of the gateway router from the details that have been observed
in the output of step 4 above. If the ping is successful, it means that there is a
physical connectivity to the router on the local network and probably the rest of the
world.
7. Ping the Loopback IP address of your computer. Type the following command: ping
127.0.0.1. The IP address 127.0.0.1 is reserved for loopback testing. If the ping is
successful, then TCP/IP is properly installed and functioning on this computer .
8. You can also ping using names like websites. Ping the IP address of the cisco
website. Type ping, space and www.cisco.com, then press Enter. Notice the

6
outputs. A DNS server will resolve the name to an IP address and the ping will be
successful only in the existence of the DNS server.
9. Ping www.ee.uct.ac.za and observe the results. Is there a difference in time between
the results shown by pinging www.cisco.com and www.ee.uct.ac.za. If so why and if
not why?
10. Trace the route to the Cisco website. Type tracert www.cisco.com and press enter.
In a successful output, you will see listings of all routers the tracert requests had to
pass through to get to the destination.
11. Trace the route to the website of the Department of Electrical Engineering. Type
tracert www.ee.uct.ac.za and press enter. The output should take less time than
that of step 9. In the same way gmail.com can be traced out as shown in figure 3.

Fig. 3. A traceroute output

7
Important Questions
1. What command is commonly used to test network connectivity and measure round-
trip time between two devices?
2. Which command provides information about the IP configuration of a computer,
including IP address, subnet mask, and default gateway?
3. What does the 'nslookup' command primarily do?
4. Which command is used to reset the Windows Sockets (Winsock) catalog to resolve
network-related issues?
5. What is the purpose of the 'tracert' command?
6. Which command is used to flush and reset the contents of the DNS client resolver
cache?
7. What does the 'ping' command measure?
8. Which command provides information about network interfaces, including MAC
addresses and connection status?
9. What does the 'netsh winsock reset' command do?
10. Which command is used to trace the route taken by packets from the source to the
destination?

8
Practical no. 1b

Objective: To study of Network CONNECTING DEVICES.

Passive Hubs
A passive hub is just a connector. It connects the wires coming from different
branches. In a star-topology Ethernet LAN, a passive hub is just a point where the
signals coming from different stations collide; the hub is the collision point. This
type of a hub is part of the media; its location in the Internet model is below the
physical layer.
Repeaters
A repeater is a device that operates only in the physical layer. Signals that carry
information within a network can travel a fixed distance before a ttenuation
endangers the integrity of the data. A repeater receives a signal and, before it
becomes too weak or corrupted, regenerates the original bit pattern. The repeater
then sends the refreshed signal as shown in figure 4.

Fig. 4. A repeater connecting two segments of a LAN

A repeater does not actually connect two LANs; it connects two segments of the same LAN.
The segments connected are still part of one single LAN. A repeater is not a device that can
connect two LANs of different protocols.

 A repeater connects segments of a LAN.


 A repeater forwards every frame
 It has no filtering capability.
 A repeater is a regenerator, not an amplifier.

Active Hubs
9
An active hub is actually a multipart repeater. It is normally used to create connections
between stations in a physical star topology. We have seen examples of hubs in some
Ethernet implementations (lOBase-T, for example). However, hubs can also be used to
create multiple levels of hierarchy, as shown in figure 5. The hierarchical use of hubs
removes the length limitation of 10Base-T (100 m).

Fig. 5. Hub Connectivity


Bridges
A bridge operates in both the physical and the data link layer. As a physical layer device, it
regenerates the signal it receives. As a data link layer device, the bridge can check the
physical (MAC) addresses (source and destination) contained in the frame.

Transparent Bridges
A transparent bridge is a bridge in which the stations are completely unaware of the
bridge's existence. If a bridge is added or deleted from the system, reconfiguration of the
stations is unnecessary. According to the IEEE 802.1 d specification, a system equipped
with transparent bridges must meet three criteria:

I. Frames must be forwarded from one station to another.


2. The forwarding table is automatically made by learning frame movements in the
network.
3. Loops in the system must be prevented.
Two-Layer Switches
When we use the term switch, we must be careful because a switch can mean two different
things. We must clarify the term by adding the level at which the device operates. We can
have a two-layer switch or a three-layer switch. A three-layer switch is used at the
10
network layer; it is a kind of router. The two-layer switch performs at the physical and
data link layers.

A two-layer switch is a bridge, a bridge with many ports and a design that allows better
(faster) performance. A bridge with a few ports can connect a few LANs together. A bridge
with many ports may be able to allocate a unique port to each station, with each station on
its own independent entity. This means no competing traffic (no collision, as we saw in
Ethernet).
A two-layer switch, as a bridge does, makes a filtering decision based on the MAC address
of the frame it received. However, a two-layer switch can be more sophisticated. It can have
a buffer to hold the frames for processing. It can have a switching factor that forwards the
frames faster. Some new two-layer switches, called cut-through switches, have been
designed to forward the frame as soon as they check the MAC addresses in the header of
the frame.

Routers
A router is a three-layer device that routes packets based on their logical addresses (host-
to-host addressing). A router normally connects LANs and WANs in the Internet and has a
routing table that is used for making decisions about the route. The routing tables are
normally dynamic and are updated using routing protocols.

Three-Layer Switches
A three-layer switch is a router, but a faster and more sophisticated. The switching fabric in
a three-layer switch allows faster table lookup and forwarding. In this book, we use the
terms router and three-layer switch interchangeably.

Gateway
A gateway is normally a computer that operates in all five layers of the Internet or seven
layers of OSI model. A gateway takes an application message, reads it, and interprets it.
11
This means that it can be used as a connecting device between two internetworks that use
different models. For example, a network designed to use the OSI model can be connected
to another network using the Internet model. The gateway connecting the two systems can
take a frame as it arrives from the first system, move it up to the OSI application layer, and
remove the message.

Important Questions:
1. What device operates at the Data Link Layer (Layer 2) of the OSI model and
connects multiple devices within the same LAN?
2. Which device is used to segment a network into different collision domains,
effectively reducing collisions in Ethernet networks?
3. What is the primary function of a router in a network?
4. Which device connects multiple networks together, typically using IP addresses to
route data between them?
5. What connecting device operates at the Physical Layer (Layer 1) of the OSI model
and regenerates signals to extend the range of a network?
6. Which device makes forwarding decisions based on MAC addresses and operates at
both Layer 2 and Layer 3 of the OSI model?
7. What is the primary purpose of a hub in a network?
8. Which connecting device is known for creating separate collision domains for each
of its ports, preventing collisions on the network?
9. What device connects devices to a network wirelessly using radio waves?
10. What connecting device is designed to regenerate signals and extend the distance of
a network by amplifying the signal strength?

12
Practical no. 2
Objective: OSI model simulation.

PROGRAM DEFINITION: This is an open system interconnection program that transmit


message from sender to receiver through server different layers.

PROGRAM DESCRIPTION:
The OSI Model deals with connecting open system. This model does not specify the exact
services and protocols to use in each layer. Therefore, the OSI Model is not a network
architecture. This model has seven layers. They are Physical layer, Data link layer,
Presentation layer, Network layer, Session layer, Transport layer and Application layer. At
sender side, each layer adds the header. The length of string i.e., number of bytes are not
restricted up to Session layer.

ALGORITHM:
1. Read the input string and address.
2. Add application header.
3. Print the string.
4. Add the presentation layer header.
5. Print the string.
6. Add the Session layer header.
7. Print the string.
8. Add the Transport layer header.
9. Print the string.
10. Add the Network layer header.
11. Print the string.
12. Add the Data link layer header.
13. Print the string
14. Add the physical layer header.
15. Print the string.

13
INPUT: Enter the string: hai

OUTPUT: TRANSMITTER:

APPLICATION LAYER: AH hai

PRESENTATION LAYER: PHAH hai

SESSION LAYER: SHPHAH hai

TRANSPORT LAYER: THSHPHAH hai

NETWORK LAYER: NHTHSHPHAH hai

DATALINK LAYER: DHNHTHSHPHAH hai

MESSAGE ENTERED INTO PHYSICAL LAYER AND TRANSMITTED.

Important Questions:

1. Which layer of the OSI model is responsible for end-to-end communication,


including addressing, routing, and flow control?
2. In the OSI model, which layer provides error detection and correction within a
single network link?
3. What is the primary function of the Presentation Layer in the OSI model?
4. Which layer of the OSI model is responsible for translating data into a format
suitable for transmission over the network?
5. In the OSI model, which layer is concerned with providing services directly to end -
users, such as email and file transfer?
6. Which layer is responsible for logical addressing, routing, and determining the best
path for data to travel between networks in the OSI model?
7. What does the Transport Layer of the OSI model provide?
8. Which layer of the OSI model deals with the establishment, maintenance, and
termination of sessions between applications?
9. What is the primary function of the Data Link Layer in the OSI model?
10. Which layer of the OSI model deals with the physical medium and transmission of
raw bits over a physical link?

14
Practical no. 3

Objective: Write C program to find the throughput of Pure Aloha and Slotted Aloha.
Problem Statement: C program to implement Pure Aloha

Problem Text: Write C program to find the throughput of Pure Aloha.

Input Description: Take input value of G (Channel load per packet time)

Output Description: Output will be a throughput of Pure Aloha.

Example: In Pure Aloha, Probability of successful transmission of data packet

= G x e-2G

Input: G=1/2

Output: S=0.184

Test Cases:

S.No Input Output

1. G=1/2 S=0.184

Question-3

Problem Statement: C program to implement Slotted Aloha

Problem Text: Write C program to find the throughput of Slotted Aloha.

Input Description: Take input value of G (Channel load per packet time)

Output Description: Output will be a throughput of Slotted Aloha.

Example: In Slotted Aloha, Probability of successful transmission of data packet

= G x e-G
Input: G=1

Output: S=0.368

15
Test Cases:

S.No Input Output

1. G=1 S=0.368

Important Questions:
1. In which multiple access protocol does a station send its data whenever it has a
frame to transmit without checking for the channel's status first?
2. What is the primary disadvantage of Pure Aloha in terms of efficiency and channel
utilization?
3. In Slotted Aloha, time is divided into fixed intervals. What is transmitted only at the
beginning of each time slot?
4. Which of the following statements is true regarding collision resolution in Pure
Aloha and Slotted Aloha?
5. In Slotted Aloha, what is the key advantage over Pure Aloha that leads to improved
channel efficiency?

16
Practical no. 4

Objective: Program to count Even and Odd Parity.

Parity: Parity of a number refers to whether it contains an odd or even number of 1 -bits.
The number has “odd parity”, if it contains odd number of 1-bits and is “even parity” if it
contains even number of 1-bits.
Main idea of the below solution is – Loop while n is not 0 and in loop unset one of the set
bits and invert parity.

Algorithm: getParity(n)
1. Initialize parity = 0
2. Loop while n != 0
a. Invert parity
parity = !parity
b. Unset rightmost set bit
n = n & (n-1)
3. return parity

Example:
Initialize: n = 13 (1101) parity = 0

n = 13 & 12 = 12 (1100) parity = 1


n = 12 & 11 = 8 (1000) parity = 0
n = 8 & 7 = 0 (0000) parity = 1

17
Important Questions:
1. In Even Parity, how is the parity bit chosen to ensure even parity for a set of data
bits?
2. Which of the following statements is true regarding Even Parity and Odd Parity?
3. In Odd Parity, how is the parity bit chosen to ensure odd parity for a set of data bits?
4. Which type of parity is more resilient to single-bit errors?
5. If a binary data sequence is 1100110, what would be the parity bit for Even Parity?

18
Practical no. 5

Objective: Program for stuffing & De- stuffing of Bits.

(1) Write a program to implement bit stuffing & De-stuffing.


(2) Write a program to implement character stuffing & De-stuffing.

(1) Write a program to implement bit stuffing & De-stuffing.


Resources: Turbo C, C++.
Bit Stuffing and Destuffing
 Include <iostream.h>,<conio.h>,<io.h> files both in transmitter & receiver programs.
 During the transmission, attach a flag pattern (01111110) at the start & end of data
unit.
 If transmitter sees five consecutive one’s in data, it stuffs zero bit in data.
 At the receiving end, whenever in data it finds five consecutive one’s and the next bit
are zero then the receiver will de stuff that zero bit. e.g. If the Pattern to be
transmitted is 00011110111110000, then at the transmitter side will be
000111101111100000 because as 5 consecutive 1’s are detected, one 0
should be stuffed and at the receiver side again as it will detect 0 after 5
consecutive 1’s , it will de-stuff it.
(2) Write a program to implement character stuffing & De-stuffing.

Resources: Turbo C, C++.


Character Stuffing and Destuffing
 Include <iostream.h>,<conio.h>,<io.h> files both in transmitter & receiver programs.
 This is type of Framing Method.
 During the transmission attach a ASCII Code pattern DLE STX at the start & DLE ETX
end of data Unit.
 If transmitter sees DLE stuff another DLE text in data.
 At the receiving end, whenever the data it finds five consecutive DLE then receiver
will destuff One DLE.

19
Important Questions:
1. What is the primary purpose of framing in networking?
2. Which framing technique uses a specific bit sequence at the beginning and end of a
frame to delineate the frame boundaries?
3. In HDLC (High-Level Data Link Control) framing, what field is used for error
detection?
4. What framing technique involves inserting a special pattern into the data stream
when a specific condition is met, such as consecutive 1s?
5. Which framing technique is commonly used in Ethernet networks and involves a
preamble, start frame delimiter, and frame check sequence?

Practical no. 6

Objective: Program to implement Cyclic Redundancy Check CRC .

CRC or Cyclic Redundancy Check is a method of detecting accidental changes/errors in


communication channel.

CRC uses Generator Polynomial which is available on both sender and receiver side. An
example generator polynomial is of the form like x3 + x + 1. This generator polynomial
represents key 1011. Another example is x 2 + 1 that represents key 101.

Sender Side (Generation of Encoded Data from Data and Generator Polynomial (or
Key)):
1. The binary data is first augmented by adding k-1 zeros in the end of the data
2. Use modulo-2 binary division to divide binary data by the key and store remainder of
division.
3. Append the remainder at the end of the data to form the encoded data and send the
same
.

20
Receiver Side (Check if there are errors introduced in transmission)
Perform modulo-2 division again and if remainder is 0, then there are no errors. In this we
will focus only on finding the remainder i.e. check word and the code word.
Modulo 2 Division:
The process of modulo-2 binary division is the same as the familiar division process we use
for decimal numbers. Just that instead of subtraction, we use XOR here.
 In each step, a copy of the divisor (or data) is XORed with the k bits of the dividend (or
key).
 The result of the XOR operation (remainder) is (n-1) bits, which is used for the next
step after 1 extra bit is pulled down to make it n bits long.
 When there are no bits left to pull down, we have a result. The (n-1)-bit remainder
which is appended at the sender side.
Illustration:

Example 1 (No error in transmission):


Data word to be sent - 100100
Key - 1101 [ Or generator polynomial x3 + x2 + 1]
Sender Side:
Therefore, the remainder is 001 and hence the encoded
data sent is 100100001.
Receiver Side:
Code word received at the receiver side 100100001
Therefore, the remainder is all zeros. Hence, the
data received has no error.
Sender Side:

21
Receiver Side:

Example 2: (Error in transmission)


Data word to be sent - 100100
Key - 1101
Sender Side:
Therefore, the remainder is 001 and hence the
code word sent is 100100001.
Receiver Side
22
Let there be error in transmission media
Code word received at the receiver side - 100000001
Since the remainder is not all zeroes, the error
is detected at the receiver side.
Sender Side:

Receiver Side:

23
Important Questions:
1. What is the primary purpose of Cyclic Redundancy Check (CRC) in networking?
2. In CRC, what type of polynomial division is used for error detection?
3. Which statement accurately describes the role of CRC in error detection?
4. What is the key advantage of using CRC for error detection in comparison to simple
parity checks?
5. In CRC, what is the remainder called after performing polynomial division for error
checking?

Practical no. 7

Objective: C code to implement RSA Algorithm (Encryption and Decryption)

RSA Algorithm in Cryptography

RSA algorithm is asymmetric cryptography algorithm. Asymmetric actually means that it


works on two different keys i.e. Public Key and Private Key. As the name describes that
the Public Key is given to everyone and Private key is kept private.
An example of asymmetric cryptography:
1. A client (for example browser) sends its public key to the server and requests for
some data.
2. The server encrypts the data using client’s public key and sends the encrypted data.
3. Client receives this data and decrypts it.
Since this is asymmetric, nobody else except browser can decrypt the data even if a third
party has public key of browser.

The idea! The idea of RSA is based on the fact that it is difficult to factorize a large integer.
The public key consists of two numbers where one number is multiplication of two large
prime numbers. And private key is also derived from the same two prime numbers. So if
somebody can factorize the large number, the private key is compromised. Therefore
encryption strength totally lies on the key size and if we double or triple the key size, the
strength of encryption increases exponentially. RSA keys can be typically 1024 or 2048 bits

24
long, but experts believe that 1024 bit keys could be broken in the near future. But till now
it seems to be an infeasible task.

25
Important Questions

1. What is the primary use of the RSA algorithm in cryptography?


2. In RSA, what is the modulus component (n) of the public and private keys
used for?
3. Which of the following keys is kept secret and used for decrypting messages
in the RSA algorithm?
4. What is the role of the Euler's totient function (φ) in the RSA algorithm?
5. What is the significance of using large prime numbers in the RSA algorithm?

Practical no. 8
Objective:
Write a C program for IPV4, Implementation of decimal to binary, and Implementation of
binary to decimal.

Resources: Turbo C, C++.

IP Addressing :- Introduction and Classful Addressing


IP address is an address having information about how to reach a specific host, especially
outside the LAN. An IP address is a 32 bit unique address having an address space of 2 32.
Generally, there are two notations in which IP address is written, dotted decimal notation
and hexadecimal notation. Dotted Decimal Notation

Hexadecimal Notation

Some points to be noted about dotted decimal notation:


1. The value of any segment (byte) is between 0 and 255 (both included).
2. There are no zeroes preceding the value in any segment (054 is wrong, 54 is correct).

26
Classful Addressing
The 32 bit IP address is divided into five sub-classes which is depicted in figure 6. These
are:

 Class A
 Class B
 Class C
 Class D
 Class E
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for
multicast and experimental purposes respectively. The order of bits in the first octet
determine the classes of IP address.

IPv4 address is divided into two parts as shown in figure 7:

 Network ID
 Host ID
The class of IP address is used to determine the bits used for network ID and host ID and
the number of total networks and hosts possible in that particular class. Each ISP or
network administrator assigns IP address to each device that is connected to its network.

Fig. 6. Different classes of IPv4 binary and decimal notation.

Fig. 7. Net ID and Host ID of IPV6

27
Important Questions:

1. What is the size of an IPv4 address in bits?


2. How many octets make up an IPv4 address?
3. In a standard IPv4 address, how are the network and host portions divided?
4. Which IPv4 address range is reserved for loopback addresses?
5. What is the purpose of the Subnet Mask in IPv4 networking?

Practical no. 9

Leaky bucket algorithm


In the network layer, before the network can make Quality of service guarantees, it must
know what traffic is being guaranteed. One of the main causes of congestion is that traffic is
often bursty.

To understand this concept first we have to know little about traffic shaping. Traffic
Shaping is a mechanism to control the amount and the rate of the traffic sent to the
network. Approach of congestion management is called Traffic shaping. Traffic shaping
helps to regulate rate of data transmission and reduces congestion.
There are 2 types of traffic shaping algorithms:

1. Leaky Bucket
2. Token Bucket
Suppose we have a bucket in which we are pouring water in a random order but we have to
get water in a fixed rate, for this we will make a hole at the bottom of the bucket. It will
ensure that water coming out is in a some fixed rate, and also if bucket will full we will stop
pouring in it.

The input rate can vary, but the output rate remains constant. Similarly, in networking, a
technique called leaky bucket can smooth out bursty traffic. Bursty chunks are stored in the
bucket and sent out at an average rate.

28
Fig. 7. Leaky bucket for shaping the traffic

In the figure, we assume that the network has committed a bandwidth of 3 Mbps for a host.
The use of the leaky bucket shapes the input traffic to make it conform to this commitment.
In figure 7 the host sends a burst of data at a rate of 12 Mbps for 2 s, f or a total of 24 Mbits
of data. The host is silent for 5 s and then sends data at a rate of 2 Mbps for 3 s, for a total of
6 Mbits of data. In all, the host has sent 30 Mbits of data in 10 s. The leaky bucket smooths
the traffic by sending out data at a rate of 3 Mbps during the same 10 s.

Without the leaky bucket, the beginning burst may have hurt the network by consuming
more bandwidth than is set aside for this host. We can also see that the leaky bucket may
prevent congestion.

A simple leaky bucket algorithm can be implemented using FIFO queue. A FIFO queue holds
the packets. If the traffic consists of fixed-size packets (e.g., cells in ATM networks), the
process removes a fixed number of packets from the queue at each tick of the clock. If the
traffic consists of variable-length packets, the fixed output rate must be based on the
number of bytes or bits.

The following is an algorithm for variable-length packets:

1. Initialize a counter to n at the tick of the clock.


2. If n is greater than the size of the packet, send the packet and decrement the counter
by the packet size. Repeat this step until n is smaller than the packet size.
3. Reset the counter and go to step 1.
Example – Let n=1000

Packet=
Since n> front of Queue i.e. n>200
29
Therefore, n=1000-200=800
Packet size of 200 is sent to the network.

Now Again n>front of the queue i.e. n > 400


Therefore, n=800-400=400
Packet size of 400 is sent to the network.

Since n< front of queue


Therefore, the procedure is stop.
Initialize n=1000 on another tick of clock.
This procedure is repeated until all the packets are sent to the network.

Important Questions:
1. What is the primary purpose of the Leaky Bucket algorithm in networking?
2. How does the Leaky Bucket algorithm control the rate of outgoing traffic?
3. In the context of the Leaky Bucket algorithm, what does the "leaky" aspect signify?
4. What is the role of the Leaky Bucket algorithm in handling bursty traffic?
5. In the Leaky Bucket algorithm, what happens if the bucket is already full and new
packets arrive?

30
Practical no. 10a

OBJECTIVE: To implement a network using Cisco Packet Tracer.


THEORY: Packet Tracer (PT) is a powerful and dynamic tool that displays the various
protocols used in networking, in either Real Time or Simulation mode. This includes layer 2
protocols such as Ethernet and PPP, layer 3 protocols such as IP, ICMP, and ARP, and layer
4 protocols such as TCP and UDP. Routing protocols can also be traced.

Steps to simulate a network:

Step 1: Start Packet Tracer You will see the start screen as shown below.

Step 2: Choose “Hub” and then select “Generic”

Step 3: After selecting “Generic” click on the main area. You will see a Hub.

Step 4: Select “End Devices” and then click at “Generic” Choosing Devices and Connections
We will begin building our network topology by selecting devices and the media in which
to connect them. Several types of devices and network connections can be used.

Step 6: Select “Connections” from Power Cycle Devices and click on “Automatically choose
Connection Type”

Step 7: Draw connections from Hub to PCs

Step 8: Double click on a PC, a box will appear. Click on the “Desktop” tab.

Step 9: Then select “IP configuration”

Step 10: Write the IP address of your network and click at the Subnet mask filed. Subnet
Mask will appear automatically.

Step11: Repeat Step 10 to set the IPs for all the PCs.

Step 12: Select “Add simple message”

31
Step 13: Drag and Drop the message to the source device and then to the Destination device
In this case my source device is PC1 and destination device is PC4.

Step 14: Select the Simulation Mode at the bottom right corner.

Step15: Click at “Auto Capture / Play” Conclusion: Connection established successfully


between Source and Destination.

Step 16: Observe the path of the Message from source to Hub, then to all devices. And then
from Destination to Hub then back to the source.

Step 17: Finally observe the marks. If the source PC is marked correct it means you have
successfully established the connection.

Some of the steps are shown in figures 11.1 to 11.15

Screenshots:

Fig. 11.1 Step 1

32
Fig. 11.2. Step 2

Fig. 11.3. Step 3

Fig. 11.4. Step 4

Fig. 11.5. Step 5

Fig. 11.6. Step 6

33
Fig. 11.7. Step 7

Fig. 11.8. Step 8

Fig. 11.9. Step 9

34
Fig. 11.10. Step 10

Fig. 11.11. Step 11

Fig. 11.12. Step 12

Fig. 11.13. Step 13

35
Fig. 11.14. Step 14

Fig. 11.15. Step 15

Important Questions:
1. What is Cisco Packet Tracer primarily used for in the context of networking
education?
2. Which of the following devices can be simulated in Cisco Packet Tracer?
3. What does the "Simulation" mode in Cisco Packet Tracer allow users to do?
4. In Cisco Packet Tracer, what feature allows users to visually represent the flow of
data through a network?
5. Which of the following protocols is commonly used in Cisco Packet Tracer for device
configuration?

36
Practical no. 10b

OBJECTIVE: To Study packet’s information through Wireshark Simulator.

THEORY
Wireshark is a tool that allows packet traces to be sniffed, captured and analyzed. Before
Wireshark (or in general, any packet capture tool) is used, careful consideration should be
given to where in the network packets are to be captured. Refer to the capture setup pages
in the wireshark.org wiki for technical details on various deployment scenarios. If it is
unclear which deployment scenario should be used to capture traces for a particular
problem, consider opening a service request with Novell Technical Services for assistance.

Part 1
1. Is your browser running HTTP version 1.0 or 1.1? What version of HTTP is the server
running?
2. What languages (if any) does your browser indicate that it can accept to the server?
3. What is the IP address of your computer?
4. What is the status code returned from the server to your browser?
5. When was the HTML file that you are retrieving last modified at the server?
6. How many bytes of content are being returned to your browser?
7. By inspecting the raw data in the packet content window, do you see any headers within
the data that are not displayed in the packet-listing window? If so, name one.

Part 2
8. Inspect the contents of the first HTTP GET request from your browser to the server.
Do you see an “IF-MODIFIED-SINCE” line in the HTTP GET?
9. Inspect the contents of the server response. Did the server explicitly return the Contents
of the file? How can you tell?
10. Now inspect the contents of the second HTTP GET request from your browser to the
server. Do you see an “IF-MODIFIED-SINCE:” line in the HTTP GET? If so, what information
follows the “IF-MODIFIED-SINCE:” header?

37
11. What is the HTTP status code and phrase returned from the server in response to this
second HTTP GET? Did the server explicitly return the contents of the file? Explain.

Part 3
12. How many HTTP GET request messages did your browser send? Which packet number
in the trace contains the GET message for the Bill or Rights?
13. Which packet number in the trace contains the status code and phrase associated with
the response to the HTTP GET request?
14. What is the status code and Phrase in the response?
15. How many data-containing TCP segments were needed to carry the single HTTP
response and the text of the Bill of Rights?
Part 4
16. How many HTTP GET request messages did your browser send? To which
Internet addresses were these GET requests sent?
17. Can you tell whether your browser downloaded the two images serially, or whether
they were downloaded from the two web sites in parallel? Explain.
Part 5
Let’s try visiting a web site that is password-protected and examine the sequence of HTTP
message exchanged for such a site. The URL http://gaia.cs.umass.edu/wireshark-
labs/protected_pages/HTTP-wireshark-file5.html is password protected. The username is
“wireshark-students” (without the quotes), and the password is “network” (again, without
the quotes). So let’s access this “secure”
Password-protected site. Do the following:
•Make sure your browser’s cache is cleared, as discussed above, and close down
your browser. Then, start up your browser
•Start up the Wireshark packet sniffer
•Enter the following URL into your browser
http://gaia.cs.umass.edu/wireshark-labs/protected_pages/HTTP-wiresharkfile5.
Html Type the requested user name and password into the pop up box.
•Stop Wireshark packet capture, and enter “http” in the display-filter-specification
window, so that only captured HTTP messages will be displayed later in the
38
packet-listing window.
•(Note: If you are unable to run Wireshark on a live network connection, you can
use the http-ethereal-trace-5 packet trace to answer the questions below; see
footnote 2. This trace file was gathered while performing the steps above on one
of the author’s computers.)
Now let’s examine the Wireshark output. You might want to first read up on HTTP
authentication by reviewing the easy-to-read material on “HTTP Access Authentication
Framework” at http://frontier.userland.com/stories/storyReader$2159
18. What is the server’s response (status code and phrase) in response to the initial HTTP
GET message from your browser?
19. When your browser’s sends the HTTP GET message for the second time, what new field
is included in the HTTP GET message?
OUTPUT

1. Version 1.1

2. Languages supported en-us and en

3. 192.168.1.102

4.200 Ok

5.73 bytes

6. Last-Modified: Tue, 23 Sep 2003 05:29:00 GMT

7.No

8. NO

9. Yes, because it return’s text/html on the webpage

10. yes, it tells the last modification date and time

11. Status code: 304 No it does not return any information explicitly as we cannot see any
line based text data or any other return type.

12. one, packet no. 8

13.Packet no: 14

39
14. status code : 200 phrase: OK

15. 4 TCP segments

16. 3 HTTP GET request

IP1: 128.119.245.12 IP2: 165.193.1.102 IP3: 134.241.6.82

17. The browser downloaded the images serially as the arrival times of both the images are
different and they are in separate tcp packet.

18. STATUS CODE: 401 PHRASES: Authorization Required

19. Authorization field

Fig.
12.1.
Snaps
hot of
questi
on 1,2

40
Fig. 12.2. Snapshot of question 3,4,16

Fig. 12.3. Snapshot of question 5,6,7,8,12,13,14

41
Fig. 12.4. Snapshot of question 9,10,11

42
Fig. 12.5. Snapshot of question 15

Fig. 12.6. Snapshot of question 17

43
Fig. 12.7. Snapshot of question 18

Fig. 12.8. Snapshot of question 19

44
Important Questions:
1. What is the main purpose of Wireshark?
2. In Wireshark, what type of information can you capture and analyze?
3. Which layer of the OSI model is Wireshark capable of capturing and analyzing?
4. What does a packet capture in Wireshark typically include?
5. How does Wireshark help troubleshoot network issues?

Practical no. 10c


OBJECTIVE: To implement socket programming using TCP.

THEORY:
Socket programming is a way of connecting two nodes on a network to communicate with
each other. One socket (node) listens on a particular port at an IP, while other socket
reaches out to the other to form a connection. Server forms the listener socket while client
reaches out to the server.

Fig. 12.1. System call used in client-server model

Stages for server


Socket creation:

45
int sockfd = socket(domain, type, protocol)

sockfd: socket descriptor, an integer (like a file-handle)


domain: integer, communication domain e.g., AF_INET (IPv4 protocol) , AF_INET6
(IPv6 protocol)
type: communication type
SOCK_STREAM: TCP(reliable, connection oriented)
SOCK_DGRAM: UDP(unreliable, connectionless)
protocol: Protocol value for Internet Protocol(IP), which is 0. This is the same
number which appears on protocol field in the IP header of a packet.(man protocols
for more details)

Setsockopt:

int setsockopt(int sockfd, int level, int optname,

const void *optval, socklen_t optlen);

This helps in manipulating options for the socket referred by the file descriptor
sockfd. This is completely optional, but it helps in reuse of address and port. Prevents
error such as: “address already in use”.

Bind:

int bind(int sockfd, const struct sockaddr *addr,

socklen_t addrlen);

After creation of the socket, bind function binds the socket to the address and port
number specified in addr(custom data structure). In the example code, we bind the
server to the localhost, hence we use INADDR_ANY to specify the IP address.

Listen:

int listen(int sockfd, int backlog);

It puts the server socket in a passive mode, where it waits for the client to approach
the server to make a connection. The backlog, defines the maximum length to which

46
the queue of pending connections for sockfd may grow. If a connection request
arrives when the queue is full, the client may receive an error with an indication of
ECONNREFUSED.

Accept:

int new_socket= accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

It extracts the first connection request on the queue of pending connections for the
listening socket, sockfd, creates a new connected socket, and returns a new file
descriptor referring to that socket. At this point, connection is established between
client and server, and they are ready to transfer data.

Stages for Client

Socket connection: Exactly same as that of server’s socket creation

Connect:

int connect(int sockfd, const struct sockaddr *addr,

socklen_t addrlen);

 The connect () system call connects the socket referred to by the file descriptor
sockfd to the address specified by addr. Server’s address and port is specified in addr.

The steps involved in establishing a socket on the client side are as follows:

1.Create a socket with the socket() system call.

2.Connect the socket to the address of the server using the connect() system call

3.Send and receive data. There are a number of ways to do this, but the simplest is to use
the read() and write() system calls.

47
The steps involved in establishing a socket on the server side are as follows:

1. Create a socket with the socket() system call

2. Bind the socket to an address using the bind() system call. For a server socket on the
Internet, an address consists of a port number on the host machine.

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 with the server.

5. Send and receive data

The interactions among the system calls is shown in figure 12.1

Important Questions:

1. What is the primary function of TCP in socket programming?


2. Which socket method is used to establish a connection in TCP socket programming?
3. In TCP socket programming, what role does the server typically play in the
connection establishment process?
4. What does the accept() method do in TCP socket programming on the server side?
5. Which of the following is a feature of TCP socket programming but not UDP?
6. What does the send() method do in TCP socket programming?
7. In TCP socket programming, what is the purpose of the recv() method?
8. Which socket method is used for closing a connection in TCP socket programming?
9. What does the term "three-way handshake" refer to in TCP socket programming?
10. Which of the following TCP socket methods is used on the client side to initiate a
connection?

The End
48

You might also like