0% found this document useful (0 votes)
130 views188 pages

CN Bookmarked Note Part 3

Uploaded by

Pavan
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)
130 views188 pages

CN Bookmarked Note Part 3

Uploaded by

Pavan
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/ 188

GATE CSE NOTES

by
Joyoshish Saha

Downloaded from https://gatecsebyjs.github.io/


With best wishes from Joyoshish Saha
Silly Window Syndrome | Nagle’s Algorithm
Computer Networks

Silly Window Syndrome-

Silly Window Syndrome is a problem that arises due to the poor implementation of TCP.
It degrades the TCP performance and makes the data transmission extremely inefficient.

Why This Name?

The problem is called so because-

It causes the sender window size to shrink to a silly value.


The window size shrinks to such an extent where the data being transmitted is smaller than TCP Header.

Causes-

The problem arises due to following causes-

1. Sender transmitting data in small segments repeatedly


2. Receiver accepting only few bytes at a time repeatedly

Cause-01: Sender Transmitting Data In Small Segments Repeatedly-

Consider application generates one byte of data to send at a time.


The poor implementation of TCP causes the sender to send each byte of data in an individual TCP segment.

This problem is solved using Nagle’s Algorithm.

Nagle’s Algorithm-

Nagle’s Algorithm tries to solve the problem

caused by the sender delivering 1 data byte at a time.


Nagle’s algorithm suggests-

Sender should send only the first byte on receiving one byte data from the application.
Sender should buffer all the rest bytes until the outstanding byte gets acknowledged.
In other words, sender should wait for 1 RTT.
After receiving the acknowledgement, sender should send the buffered data in one TCP segment.
Then, sender should buffer the data again until the previously sent data gets acknowledged.

Cause-02: Receiver Accepting Only Few Bytes Repeatedly-

Consider the receiver continues to be unable to process all the incoming data.
In such a case, its window size becomes smaller and smaller.
A stage arrives when it repeatedly sends the window size of 1 byte to the sender.

This problem is solved using Clark’s Solution.

Clark’s Solution-

Clark’s Solution tries to solve the problem

caused by the receiver sucking up one data byte at a time.

Clark’s solution suggests-

Receiver should not send a window update for 1 byte.


Receiver should wait until it has a decent amount of space available.
Receiver should then advertise that window size to the sender.

Specifically, the receiver should not send a window update-

Until it can handle the MSS it advertised during Three Way Handshake
Or until its buffer is half empty, whichever is smaller.

Important Notes-

Note-01:

Nagle’s algorithm is turned off for the applications that require data to be sent immediately.

This is because-

Nagle’s algorithm sends only one segment per round trip time.
This impacts the latency by introducing a delay.

Note-02:
Nagle’s algorithm and Clark’s solution are complementary.

Both Nagle’s solution and Clark’s solution can work together.


The ultimate goal is sender should not send the small segments and receiver should not ask for them.

PRACTICE PROBLEM BASED ON NAGLE’S ALGORITHM-

Problem-

A fast typist can do 100 words a minute and each word has an average of 6 characters. Demonstrate Nagle’s algorithm by showing the sequence
of TCP segment exchanges between a client with input from our fast typist and a server. Indicate how many characters are contained in each
segment sent from the client.

Consider the following two cases-

1. The client and server are in the same LAN and the RTT is 20 ms.
2. The client and server are connected across a WAN and the RTT is 100 ms.

Solution-

Nagle’s algorithm suggests-

Sender should wait for 1 RTT before sending the data.


The amount of data received from the application layer in 1 RTT should be sent to the receiver.

Case-01:

Amount of data accumulated in 1 RTT

= (600 characters / 1 minute) x 20 msec

= (600 characters / 60 sec) x 20 msec

= (10 characters / 103 msec) x 20 msec

= 0.2 characters

From here, we observe-


Even if the sender waits for 1 RTT, not even a single character is produced.
So, sender will have to wait till it receives at least 1 character.
Then, sender sends it in one segment.

Thus, one character will be sent per segment.

Assuming the TCP header length is 20 bytes, 41 bytes of data will be sent in each segment.

Case-02:

Amount of data accumulated in 1 RTT

= (600 characters / 1 minute) x 100 msec

= (600 characters / 60 sec) x 100 msec

= (10 characters / 103 msec) x 100 msec

= 1 character

From here, we observe that one character is produced in 1 RTT.

Thus, one character will be sent per segment.

Assuming the TCP header length is 20 bytes, 41 bytes of data will be sent in each segment.

Next Article- User Datagram Protocol | UDP Header

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary

Article Name Silly Window Syndrome | Nagle's Algorithm

Description Silly Window Syndrome is a problem that arises due to


the poor implementation of TCP. Nagle's Algorithm and
Clark's solution tries to solve the problems caused due to
silly window syndrome.

Author Akshay Singhal

Publisher Name Gate Vidyalay

Publisher Logo
Transmission Control Protocol | Practice Problems
Computer Networks

PRACTICE PROBLEMS BASED ON TRANSMISSION CONTROL PROTOCOL-

Problem-01:

How many TCP connections can be opened between two ports?

1. Multiple
2. Single
3. Zero
4. None

Solution-

Option (B) is correct.

Problem-02:

TCP protects itself from miss delivery by IP with the help of-

1. Source IP Address in IP header


2. Destination IP Address in IP header
3. Pseudo header
4. Source port and Destination port

Solution-

Option (C) is correct.

Problem-03:

What addressing system has topological significance?

1. Logical or Network Address


2. LAN or Physical Address
3. Port Addressing System
4. Multicast Addressing System

Solution-

Option (A) is correct.

Problem-04:
If WAN link is 2 Mbps and RTT between source and destination is 300 msec, what would be the optimal TCP window size needed to fully utilize
the line?

1. 60,000 bits
2. 75,000 bytes
3. 75,000 bits
4. 60,000 bytes

Solution-

Given-

Bandwidth = 2 Mbps
RTT = 300 msec

Optimal TCP Window Size-

Optimal TCP window size

= Maximum amount of data that can be sent in 1 RTT

= 2 Mbps x 300 msec

= 600 x 103 bits

= 60,0000 bits

= 75,000 bytes

Thus, Option (B) is correct.

Problem-05:

Suppose host A is sending a large file to host B over a TCP connection. The two end hosts are 10 msec apart (20 msec RTT) connected by a 1
Gbps link. Assume that they are using a packet size of 1000 bytes to transmit the file. For simplicity, ignore ack packets. At least how big would the
window size (in packets) have to be for the channel utilization to be greater than 80%?

1. 1000
2. 1500
3. 2000
4. 2500
Solution-

Given-

RTT = 20 msec
Bandwidth = 1 Gbps
Packet size = 1000 bytes
Efficiency >= 80%

Window Size For 100% E ciency-

For 100% efficiency,

Window size

= Maximum number of bits that can be transmitted in 1 RTT

= 1 Gbps x 20 msec

= (109 bits per sec) x 20 x 10-3 sec

= 20 x 106 bits

= 2 x 107 bits

Window Size For 80% E ciency-

For 80% efficiency,

Window size

= 0.8 x 2 x 107 bits

= 1.6 x 107 bits

In terms of packets,

Window size

= 1.6 x 107 bits / Packet size

= 1.6 x 107 bits / (1000 x 8 bits)

= 0.2 x 104 packets

= 2000 packets

Thus, Option (C) is correct.

Problem-06:

A TCP machine is sending windows of 65535 B over a 1 Gbps channel that has a 10 msec one way delay.

1. What is the maximum throughput achievable?


2. What is the line efficiency?

Solution-

Given-

Window size = 65535 bytes


Bandwidth = 1 Gbps
One way delay = 10 msec

Method-01:

Maximum amount of data that can be sent in 1 RTT

= 1 Gbps x (2 x 10 msec)

= (109 bits per sec) x 20 x 10-3 sec

= 20 x 106 bits

= 25 x 105 bytes

Amount of data that is actually being sent in 1 RTT = 65535 bytes

Thus,

Line Efficiency(η)

= Amount of data being sent in 1 RTT / Maximum amount of data that can be sent in 1 RTT

= 65535 bytes / 25 x 105 bytes

= 0.026214

= 2.62%

Now,

Maximum Achievable Throughput

= Efficiency x Bandwidth

= 0.0262 x 1 Gbps

= 26.214 Mbps

Method-02:

Maximum Achievable Throughput

= Number of bits sent per second

= 65535 B / 20 msec

= (65535 x 8 bits) / (20 x 10-3 sec)

= 26.214 Mbps
Now,

Line Efficiency

= Throughput / Bandwidth

= 26.214 Mbps / 1 Gbps

= 26.214 x 10-3

= 0.026214

= 2.62%

Next Article- TCP Congestion Control

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary

Article Name Transmission Control Protocol | Practice Problems

Description Practice Problems based on Transmission Control


Protocol. TCP Protocol is a transport layer protocol. TCP
header format specifies various fields required for
transmission. TCP congestion control policy is used for
handling congestion.

Author Akshay Singhal

Publisher Name Gate Vidyalay

Publisher Logo

Liked this article? Share it with your friends and classmates now-
250 CHAPTER 3 • TRANSPORT LAYER

A proposed modification to TCP, the so-called selective acknowledgment


[RFC 2018], allows a TCP receiver to acknowledge out-of-order segments selec-
tively rather than just cumulatively acknowledging the last correctly received, in-
order segment. When combined with selective retransmission—skipping the
retransmission of segments that have already been selectively acknowledged by the
receiver—TCP looks a lot like our generic SR protocol. Thus, TCP’s error-recovery
mechanism is probably best categorized as a hybrid of GBN and SR protocols.

3.5.5 Flow Control


Recall that the hosts on each side of a TCP connection set aside a receive buffer for
the connection. When the TCP connection receives bytes that are correct and in
sequence, it places the data in the receive buffer. The associated application process
will read data from this buffer, but not necessarily at the instant the data arrives.
Indeed, the receiving application may be busy with some other task and may not
even attempt to read the data until long after it has arrived. If the application is rela-
tively slow at reading the data, the sender can very easily overflow the connection’s
receive buffer by sending too much data too quickly.
TCP provides a flow-control service to its applications to eliminate the possibility
of the sender overflowing the receiver’s buffer. Flow control is thus a speed-matching
service—matching the rate at which the sender is sending against the rate at which the
receiving application is reading. As noted earlier, a TCP sender can also be throttled
due to congestion within the IP network; this form of sender control is referred to as
congestion control, a topic we will explore in detail in Sections 3.6 and 3.7. Even
though the actions taken by flow and congestion control are similar (the throttling of
the sender), they are obviously taken for very different reasons. Unfortunately, many
authors use the terms interchangeably, and the savvy reader would be wise to distin-
guish between them. Let’s now discuss how TCP provides its flow-control service. In
order to see the forest for the trees, we suppose throughout this section that the TCP
implementation is such that the TCP receiver discards out-of-order segments.
TCP provides flow control by having the sender maintain a variable called the
receive window. Informally, the receive window is used to give the sender an idea of
how much free buffer space is available at the receiver. Because TCP is full-duplex, the
sender at each side of the connection maintains a distinct receive window. Let’s investi-
gate the receive window in the context of a file transfer. Suppose that Host A is sending
a large file to Host B over a TCP connection. Host B allocates a receive buffer to this
connection; denote its size by RcvBuffer. From time to time, the application process
in Host B reads from the buffer. Define the following variables:

• LastByteRead: the number of the last byte in the data stream read from the
buffer by the application process in B
• LastByteRcvd: the number of the last byte in the data stream that has arrived
from the network and has been placed in the receive buffer at B
3.5 • CONNECTION-ORIENTED TRANSPORT: TCP 251

RcvBuffer

rwnd

Data Application
from IP process
TCP data
Spare room
in buffer

Figure 3.38 � The receive window (rwnd) and the receive buffer
(RcvBuffer)

Because TCP is not permitted to overflow the allocated buffer, we must have

LastByteRcvd – LastByteRead � RcvBuffer

The receive window, denoted rwnd is set to the amount of spare room in the buffer:

rwnd = RcvBuffer – [LastByteRcvd – LastByteRead]

Because the spare room changes with time, rwnd is dynamic. The variable rwnd is
illustrated in Figure 3.38.
How does the connection use the variable rwnd to provide the flow-control
service? Host B tells Host A how much spare room it has in the connection buffer
by placing its current value of rwnd in the receive window field of every segment it
sends to A. Initially, Host B sets rwnd = RcvBuffer. Note that to pull this off,
Host B must keep track of several connection-specific variables.
Host A in turn keeps track of two variables, LastByteSent and Last-
ByteAcked, which have obvious meanings. Note that the difference between these
two variables, LastByteSent – LastByteAcked, is the amount of unac-
knowledged data that A has sent into the connection. By keeping the amount of
unacknowledged data less than the value of rwnd, Host A is assured that it is not
overflowing the receive buffer at Host B. Thus, Host A makes sure throughout the
connection’s life that

LastByteSent – LastByteAcked � rwnd


252 CHAPTER 3 • TRANSPORT LAYER

There is one minor technical problem with this scheme. To see this, suppose
Host B’s receive buffer becomes full so that rwnd = 0. After advertising rwnd = 0
to Host A, also suppose that B has nothing to send to A. Now consider what hap-
pens. As the application process at B empties the buffer, TCP does not send new seg-
ments with new rwnd values to Host A; indeed, TCP sends a segment to Host A
only if it has data to send or if it has an acknowledgment to send. Therefore, Host A
is never informed that some space has opened up in Host B’s receive buffer—Host
A is blocked and can transmit no more data! To solve this problem, the TCP specifi-
cation requires Host A to continue to send segments with one data byte when B’s
receive window is zero. These segments will be acknowledged by the receiver.
Eventually the buffer will begin to empty and the acknowledgments will contain a
nonzero rwnd value.
The online site at http://www.awl.com/kurose-ross for this book provides an
interactive Java applet that illustrates the operation of the TCP receive window.
Having described TCP’s flow-control service, we briefly mention here that UDP
does not provide flow control. To understand the issue, consider sending a series of
UDP segments from a process on Host A to a process on Host B. For a typical UDP
implementation, UDP will append the segments in a finite-sized buffer that “precedes”
the corresponding socket (that is, the door to the process). The process reads one entire
segment at a time from the buffer. If the process does not read the segments fast
enough from the buffer, the buffer will overflow and segments will get dropped.

3.5.6 TCP Connection Management


In this subsection we take a closer look at how a TCP connection is established and
torn down. Although this topic may not seem particularly thrilling, it is important
because TCP connection establishment can significantly add to perceived delays
(for example, when surfing the Web). Furthermore, many of the most common net-
work attacks—including the incredibly popular SYN flood attack—exploit vulnera-
bilities in TCP connection management. Let’s first take a look at how a TCP
connection is established. Suppose a process running in one host (client) wants to
initiate a connection with another process in another host (server). The client appli-
cation process first informs the client TCP that it wants to establish a connection to
a process in the server. The TCP in the client then proceeds to establish a TCP con-
nection with the TCP in the server in the following manner:

• Step 1. The client-side TCP first sends a special TCP segment to the server-side
TCP. This special segment contains no application-layer data. But one of the flag
bits in the segment’s header (see Figure 3.29), the SYN bit, is set to 1. For this
reason, this special segment is referred to as a SYN segment. In addition, the
client randomly chooses an initial sequence number (client_isn) and puts
this number in the sequence number field of the initial TCP SYN segment. This
segment is encapsulated within an IP datagram and sent to the server. There has
(/)

TCP vs UDP: What's the Di erence?


What is TCP?
TCP/IP helps you to determine how a specific computer should be connected to the internet and how you can transmit data
between them. It helps you to create a virtual network when multiple computer networks are connected.

TCP/IP stands for Transmission Control Protocol/ Internet Protocol. It is specifically designed as a model to offer highly reliable
and end-to-end byte stream over an unreliable internetwork.

In this tutorial, you will learn:


TCP is best suited to be used for UDP is best suited for applications that
applications that require high reliability require speed and efficiency.
What is TCP?
where timing is less of a concern.
What is UDP? VPN tunneling,
Streaming videos,
How TCP work? World Wide Web (HTTP, HTTPS),
Secure Shell (SSH), Online games,
How UDP work? Live broadcasts,
File Transfer Protocol (FTP),
Features of TCP Email (SMTP, IMAP/POP) Domain Name System (DNS),
Voice over Internet Protocol (VoIP),
Difference between TCP and UDP
Trivial File Transfer Protocol (TFTP),
Application of TCP Broadcasting and Multicasting services
Application of UDP
Advantage of TCP
Advantage of UDP
Disadvantages of TCP
Disadvantages of UDP
When to use UDP and TCP?

What is UDP?
UDP is a Datagram oriented protocol. It is used for broadcast and multicast type of network transmission. The full form of UDP
is User Datagram Protocol (A datagram is a transfer unit associated with a packet-switched network.) The UDP protocol works
almost similar to TCP, but it throws all the error-checking stuff out, all the back-and-forth communication and deliverability.

How TCP work?


A TCP connection is established with the help of three-way handshake. It is a process of initiating and acknowledging a
connection. Once the connection is established, data transfer begins, and when the transmission process is finished, the
connection is terminated by the closing of an established virtual circuit.

How UDP work?


UDP uses a simple transmission method without implied hand-shaking dialogues for ordering, reliability, or data integrity. UDP
also assumes that error checking and correction is not important or performed in the application, to avoid the overhead of
such processing at the network interface level. It is also compatible with packet broadcasts and multicasting.

Features of TCP
Here, are some important features of TCP

Delivery Acknowledgements
Re transmission
Delays transmission when the network is congested
Easy Error detection
Here, are some important feature of UDP:

Supports bandwidth-intensive applications that tolerate packet loss


Less delay
It sends the bulk quantity of packets.
Possibility of the Data loss
Allows small transaction ( DNS lookup)

Di erence between TCP and UDP


Here, are the differences between TCP and UDP

(/images/1/011720_0714_TCPvsUDPWha1.png)

TCP UDP

It is a connection-oriented protocol. It is a connectionless protocol.

TCP reads data as streams of bytes, and the message is UDP messages contain packets that were sent one by one. It
transmitted to segment boundaries. also checks for integrity at the arrival time.

TCP messages make their way across the internet from one It is not connection-based, so one program can send lots of
computer to another. packets to another.

TCP rearranges data packets in the specific order. UDP protocol has no fixed order because all packets are
independent of each other.

The speed for TCP is slower. UDP is faster as error recovery is not attempted.

Header size is 20 bytes Header size is 8 bytes.

TCP is heavy-weight. TCP needs three packets to set up a UDP is lightweight. There are no tracking connections,
socket connection before any user data can be sent. ordering of messages, etc.

TCP does error checking and also makes error recovery. UDP performs error checking, but it discards erroneous
packets.

Acknowledgment segments No Acknowledgment segments

Using handshake protocol like SYN, SYN-ACK, ACK No handshake (so connectionless protocol)

TCP is reliable as it guarantees delivery of data to the The delivery of data to the destination can't be guaranteed in
destination router. UDP.

TCP offers extensive error checking mechanisms because it UDP has just a single error checking mechanism which is
provides flow control and acknowledgment of data. used for checksums.

Application of TCP
Here, are pros/benefits of using the TCP/IP model:

It helps you to establish/set up a connection between different types of computers.


Operates independently of the operating system
Supports many routing-protocols.
It enables the internetworking between the organizations.
It can be operated independently.
Supports several routing protocols.
TCP can be used to establish a connection between two computers.

Application of UDP

UDP method is largely used by time-sensitive applications as well as by servers that answer small queries from a larger
client base.
UDP is compatible with packet broadcasts for sending all over the network and for multicasting sending.
It is also used in Domain Name System, Voice over IP, and online games.

Advantage of TCP
Here, are pros/benefits of TCP:

It helps you to establish/set up a connection between different types of computers.


It operates independently of the operating system.
It supports many routing-protocols.
It enables the internetworking between the organizations.
TCP/IP model has a highly scalable client-server architecture.
It can be operated independently.
Supports several routing protocols.
It can be used to establish a connection between two computers.

Advantage of UDP
Here are the pros/benefits of UDP:

It never restricts you to a connection-based communication model; that's why startup latency in distributed applications is
low.
The recipient of UDP packets gets them unmanaged, which also includes block boundaries.
Broadcast and multicast transmission are also available with UDP
Data loss can be made
Small transaction ( DNS lookup)
Bandwidth intensive app which endures packet loss

Disadvantages of TCP
Here, are disadvantage of using TCP:

TCP never conclude a transmission without all data in motion being explicitly asked.
You can't use for broadcast or multicast transmission.
TCP has no block boundaries, so you need to create your own.
TCP offers many features that you don't want. It may waste bandwidth, time, or effort.
In this, model the transport layer does not guarantee delivery of packets.
Replacing protocol in TCP/IP is not easy.
It doesn't offer clear separation from its services, interfaces, and protocols.

Disadvantages of UDP
Here, are important cons/drawback of UDP:

In UDP protocol, a packet may not be delivered or delivered twice. It may be delivered out of order, so you get no indication.
Routers are quite careless with UDP, so they never retransmit it if it collides.
UDP has no Congestion Control, and flow control, so implementation is the job of a user application.
UDP mostly like to suffer from worse packet loss
When to use UDP and TCP?

TCP is an ideal choice, and even it has associated overhead, Therefore, when most of the overhead is in the connection,
your application stays connected for any length of time.
UDP is ideal to use with multimedia like VoIP.
Use TCP sockets when both client and server independently send packets at that time; an occasional delay is acceptable.
(e.g., Online Poker).
You should use user UDP if both client and server may separately send packets, and occasional delay is also not acceptable.
(e.g., Multiplayer games).

KEY DIFFERENCES:

TCP is a connection-oriented protocol, whereas UDP is a connectionless protocol.


The speed for TCP is slower while the speed of UDP is faster
TCP uses handshake protocol like SYN, SYN-ACK, ACK while UDP uses no handshake protocols
TCP does error checking and also makes error recovery, on the other hand, UDP performs error checking, but it discards
erroneous packets.
TCP has acknowledgment segments, but UDP does not have any acknowledgment segment.
TCP is heavy-weight, and UDP is lightweight.

 Prev (/difference-tcp-ip-vs-osi-model.html) Report a Bug


Next  (/hub-vs-switch.html)

YOU MIGHT LIKE:

ETHICAL HACKING ETHICAL HACKING ETHICAL HACKING

(/cybercrime-types-tools- (/ethical-hacking-interview- (/comptia-certification-guide.html)


examples.html) (/cybercrime- questions.html) (/ethical- (/comptia-certification-
types-tools-examples.html) hacking-interview- guide.html)
What is Cybercrime? Types, Tools, questions.html) CompTIA Certification Guide: Career
Examples Top 25 Ethical Hacking Interview Paths & Study Material
(/cybercrime-types-tools- Questions & Answers (/comptia-certification-guide.html)
examples.html) (/ethical-hacking-interview-
questions.html)

ETHICAL HACKING ETHICAL HACKING ETHICAL HACKING

(/vulnerability-scanning-tools- (/best-ethical-hacking-books.html) (/ethical-hacking-tutorial-pdf.html)


websites-network.html) (/best-ethical-hacking- (/ethical-hacking-tutorial-
(/vulnerability-scanning-tools- books.html) pdf.html)
websites-network.html) 16 BEST Ethical Hacking Books (2020 Ethical Hacking Tutorial for Beginners
13 BEST Vulnerability Assessment Update) PDF
Scanners for Websites, Network (/best-ethical-hacking-books.html) (/ethical-hacking-tutorial-pdf.html)
(/vulnerability-scanning-tools-
websites-network.html)

Networking Tutorial
5) TCP 3-Way Handshake (/tcp-3-way-handshake.html)
UDP Protocol | UDP Header | UDP Header Format
Computer Networks

Transport Layer Protocols-

There are mainly two transport layer protocols that are used on the Internet-

1. Transmission Control Protocol (TCP)


2. User Datagram Protocol (UDP)

In this article, we will discuss about User Datagram Protocol (UDP).

Learn about Transmission Control Protocol.

UDP Protocol-

UDP is short for User Datagram Protocol.


It is the simplest transport layer protocol.
It has been designed to send data packets over the Internet.
It simply takes the datagram from the network layer, attaches its header and sends it to the user.

Characteristics of UDP-

It is a connectionless protocol.
It is a stateless protocol.
It is an unreliable protocol.
It is a fast protocol.
It offers the minimal transport service.
It is almost a null protocol.
It does not guarantee in order delivery.
It does not provide congestion control mechanism.
It is a good protocol for data flowing in one direction.

Need of UDP-

TCP proves to be an overhead for certain kinds of applications.


The Connection Establishment Phase, Connection Termination Phase etc of TCP are time consuming.
To avoid this overhead, certain applications which require fast speed and less overhead use UDP.
UDP Header-

The following diagram represents the UDP Header Format-

1. Source Port-

Source Port is a 16 bit field.


It identifies the port of the sending application.

2. Destination Port-

Destination Port is a 16 bit field.


It identifies the port of the receiving application.

3. Length-

Length is a 16 bit field.


It identifies the combined length of UDP Header and Encapsulated data.

Length = Length of UDP Header + Length of encapsulated data

4. Checksum-

Checksum is a 16 bit field used for error control.


It is calculated on UDP Header, encapsulated data and IP pseudo header.
Checksum calculation is not mandatory in UDP.

Applications Using UDP-

Following applications use UDP-

Applications which require one response for one request use UDP. Example- DNS.
Routing Protocols like RIP and OSPF use UDP because they have very small amount of data to be transmitted.
Trivial File Transfer Protocol (TFTP) uses UDP to send very small sized files.
Broadcasting and multicasting applications use UDP.
Streaming applications like multimedia, video conferencing etc use UDP since they require speed over reliability.
Real time applications like chatting and online games use UDP.
Management protocols like SNMP (Simple Network Management Protocol) use UDP.
Bootp / DHCP uses UDP.
Other protocols that use UDP are- Kerberos, Network Time Protocol (NTP), Network News Protocol (NNP), Quote of the day protocol etc.

Important Notes-

Note-01:

Size of UDP Header= 8 bytes

Unlike TCP header, the size of UDP header is fixed.


This is because in UDP header, all the fields are of definite size.
Size of UDP Header = Sum of the size of all the fields = 8 bytes.

Note-02:

UDP is almost a null protocol.

This is because-

UDP provides very limited services.


The only services it provides are checksumming of data and multiplexing by port number.

Note-03:

UDP is an unreliable protocol.

This is because-

UDP does not guarantee the delivery of datagram to its respective user (application).
The lost datagrams are not retransmitted by UDP.

Note-04:

Checksum calculation is not mandatory in UDP.

This is because-

UDP is already an unreliable protocol and error checking does not make much sense.
Also, time is saved and transmission becomes faster by avoiding to calculate it.
It may be noted-

To disable the checksum, the field value is set to all 0’s.


If the computed checksum is zero, the field value is set to all 1’s.

Note-05:

UDP does not guarantee in order delivery.

This is because-

UDP allows out of order delivery to ensure better performance.


If some data is lost on the way, it does not call for retransmission and keeps transmitting data.

Note-06:

Application layer can perform some tasks through UDP.

Application layer can do the following tasks through UDP-

1. Trace Route
2. Record Route
3. Time stamp

When required,

Application layer conveys to the UDP which conveys to the IP datagram.


UDP acts like a messenger between the application layer and the IP datagram.

Also Read- TCP Header | IPv4 Header

PRACTICE PROBLEMS BASED ON UDP HEADER-

Problem-01:
Which field is optional in UDP?

1. Checksum
2. Destination port
3. Length
4. None

Solution-

Checksum calculation is not mandatory in UDP.


Thus, Option (A) is correct.

Problem-02:

The pseudo header of IP is used in-

1. Only TCP
2. Only UDP
3. Both TCP and UDP
4. None

Solution-

IP Pseudo header is used in both TCP and UDP while calculating checksum.
Thus, Option (C) is correct.

Problem-03:

Broadcasting applications like WHOD (who daemon on UNIX) uses what transport layer protocol?

1. TCP
2. UDP
3. Either TCP or UDP
4. IGMP

Solution-

Broadcasting and multicasting applications use UDP.


Thus, Option (B) is correct.

To gain better understanding about UDP Header,

Watch this Video Lecture

Next Article- Application Layer Protocols


go to: https://www.pearsonhighered.com/assets/samplechapter/0/7/8/9/0789732548.pdf
DNS HTTP SMTP POP FTP

Stateful /
Stateless Stateless Stateless Stateful Stateful
Stateless

Transport
UDP TCP TCP TCP TCP
Protocol Used

Connectionless
Connection Connection Connection
/ Connection Connectionless Connectionless
Oriented Oriented Oriented
Oriented

Control
connection
HTTP 1.0 is is
non-persistent. persistent.
Persistent /
Non-persistent Persistent Persistent
Non-persistent HTTP 1.1 is Data
persistent. connection
is non-
persistent.

20 for data
connection.
Port Number
53 80 25 110 21 for
Used
control
connection.

In band / Out- Out-of-


In band In band In band In band
of-band band

Next Article- Cryptography and Network Security

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary
(/)

IPv4 vs IPv6: What’s the Di erence?


What is IP?
An Internet Protocol address is also known as IP address. It is a numerical label which assigned to each device connected to
a computer network which uses the IP for communication.

IP address act as an identifier for a specific machine on a particular network. The IP address is also called IP number and
internet address. IP address specifies the technical format of the addressing and packets scheme. Most networks combine
IP with a TCP (Transmission Control Protocol). It also allows developing a virtual connection between a destination and a
source.

What is IPv4?
IPv4 was the first version of IP. It was deployed for production in the ARPANET in 1983. Today it is most widely used IP
version. It is used to identify devices on a network using an addressing system.

The IPv4 uses a 32-bit address scheme allowing to store 2^32 addresses which is more than 4 billion addresses. Till date, it
is considered the primary Internet Protocol and carries 94% of Internet traffic.

What is IPv6?
It is the most recent version of the Internet Protocol. Internet Engineer Taskforce initiated it in early 1994. The design and
development of that suite is now called IPv6.

This new IP address version is being deployed to fulfill the need for more Internet addresses. It was aimed to resolve issues
which are associated with IPv4. With 128-bit address space, it allows 340 undecillion unique address space. IPv6 also called
IPng (Internet Protocol next generation).

Features of IPv4

Connectionless Protocol
Allow creating a simple virtual communication layer over diversified devices
It requires less memory, and ease of remembering addresses
Already supported protocol by millions of devices
Offers video libraries and conferences

Features of IPv6

Hierarchical addressing and routing infrastructure


Stateful and Stateless configuration
Support for quality of service (QoS)
An ideal protocol for neighboring node interaction
(/images/1/053018_0657_IPv4vsIPv6W1.png)

Di erence Between IPv4 and IPv6 Addresses


IPv4 & IPv6 are both IP addresses that are binary numbers. IPv4 is 32 bit binary number while IPv6 is 128 bit binary number
address. IPv4 address are separated by periods while IPv6 address are separated by colons.

Both are used to identify machines connected to a network. In principle, they are the same, but they are different in how
they work.

Basis for
IPv4 IPv6
differences

Size of IP
IPv4 is a 32-Bit IP Address. IPv6 is 128 Bit IP Address.
address

IPv6 is an alphanumeric address whose


Addressing IPv4 is a numeric address, and its binary bits are separated
binary bits are separated by a colon (:). It
method by a dot (.)
also contains hexadecimal.

Number of
12 8
header fields

Length of
20 40
header filed

Checksum Has checksum fields Does not have checksum fields

Example 12.244.233.165 2001:0db8:0000:0000:0000:ff00:0042:7879

Type of
Unicast, broadcast, and multicast. Unicast, multicast, and anycast.
Addresses

Number of lPv6 allows storing an unlimited number


IPv4 offers five different classes of IP Address. Class A to E.
classes of IP Address.

You have to configure a newly installed system before it can In IPv6, the configuration is optional,
Configuration
communicate with other systems. depending upon on functions needed.

VLSM support IPv4 support VLSM (Virtual Length Subnet Mask). IPv6 does not offer support for VLSM.

Fragmentation Fragmentation is done by sending and forwarding routes. Fragmentation is done by the sender.

Routing
RIP does not support IPv6. It uses static
Information RIP is a routing protocol supported by the routed daemon.
routes.
Protocol (RIP)

Networks need to be configured either manually or with


Network IPv6 support autoconfiguration
DHCP. IPv4 had several overlays to handle Internet growth,
Configuration capabilities.
which require more maintenance efforts.
Basis for
IPv4 IPv6
differences

Widespread use of NAT (Network address translation)


devices which allows single NAT address can mask It allows direct addressing because of
Best feature
thousands of non-routable addresses, making end-to-end vast address Space.
integrity achievable.

Address Mask Use for the designated network from host portion. Not used.

SNMP SNMP is a protocol used for system management. SNMP does not support IPv6.

IPv6 provides interoperability and


Mobility & Relatively constrained network topologies to which move
mobility capabilities which are
Interoperability restrict mobility and interoperability capabilities.
embedded in network devices.

IPSec(Internet Protocol Security) is built


Security is dependent on applications - IPv4 was not
Security into the IPv6 protocol, usable with a
designed with security in mind.
proper key infrastructure.

1208 bytes required without


Packet size Packet size 576 bytes required, fragmentation optional
fragmentation

Packet
Allows from routers and sending host Sending hosts only
fragmentation

Packet head contains Flow Label field


Does not identify packet flow for QoS handling which
Packet header that specifies packet flow for QoS
includes checksum options.
handling

DNS records Address (A) records, maps hostnames Address (AAAA) records, maps hostnames

Stateless address autoconfiguration using


Address
Manual or via DHCP Internet Control Message Protocol
configuration
version 6 (ICMPv6) or DHCPv6

IP to MAC
Broadcast ARP Multicast Neighbour Solicitation
resolution

Local subnet
Group Internet Group Management Protocol GMP) Multicast Listener Discovery (MLD)
management

Does not have optional fields. But


Optional Fields Has Optional Fields
Extension headers are available.

Internet Protocol Security (IPSec)


Internet Protocol Security (IPSec) concerning network
IPSec Concerning network security is
security is optional
mandatory

Dynamic host A Client does not have to approach any


Clients have approach DHCS (Dynamic Host Configuration
configuration such server as they are given permanent
server) whenever they want to connect to a network.
Server addresses.

Uses ARP(Address Resolution Protocol) to map to MAC Uses NDP(Neighbour Discovery Protocol)
Mapping
address to map to MAC address
Basis for
IPv4 IPv6
differences

Combability IPv6 address is represented in


IPv4 address uses the dot-decimal notation. That's why it is
with mobile hexadecimal, colon- separated notation.
not suitable for mobile networks.
devices IPv6 is better suited to mobile networks.
IPv4 and IPv6 cannot communicate with other but can exist together on the same network. This is known as Dual Stack.

KEY DIFFERENCE

IPv4 is 32-Bit IP address whereas IPv6 is a 128-Bit IP address.


IPv4 is a numeric addressing method whereas IPv6 is an alphanumeric addressing method.
IPv4 binary bits are separated by a dot(.) whereas IPv6 binary bits are separated by a colon(:).
IPv4 offers 12 header fields whereas IPv6 offers 8 header fields.
IPv4 supports broadcast whereas IPv6 doesn’t support broadcast.
IPv4 has checksum fields while IPv6 doesn’t have checksum fields
IPv4 supports VLSM (Virtual Length Subnet Mask) whereas IPv6 doesn’t support VLSM.
IPv4 uses ARP (Address Resolution Protocol) to map to MAC address whereas IPv6 uses NDP (Neighbour Discovery
Protocol) to map to MAC address.

 Prev (/introduction-ccna.html) Report a Bug


Next  (/difference-http-vs-https.html)

YOU MIGHT LIKE:

ETHICAL HACKING ETHICAL HACKING ETHICAL HACKING

(/cissp-certification.html) (/ip-network-scanner-tool.html) (/ip- (/wireshark-alternative.html)


(/cissp-certification.html) network-scanner-tool.html) (/wireshark-alternative.html)
CISSP Certification Guide: What is, 11 Best Wireshark Alternatives in 2020
Prerequisites, Cost, CISSP Salary 17 Best IP & Network Scanning Tools in (/wireshark-alternative.html)
(/cissp-certification.html) 2020 (Free/Paid)
(/ip-network-scanner-tool.html)

ETHICAL HACKING ETHICAL HACKING ETHICAL HACKING

(/cyber-security-interview- (/bug-bounty-programs.html) (/computer-forensics-tools.html)


questions.html) (/cyber- (/bug-bounty-programs.html) (/computer-forensics-
security-interview- Top 30 Bug Bounty Programs in 2020 tools.html)
questions.html) (/bug-bounty-programs.html) 15 BEST Digital Forensic Tools in 2020
Top 110 Cyber Security Interview [Free/Paid]
Questions & Answers (/computer-forensics-tools.html)
(/cyber-security-interview-
questions.html)

CCNA Tutorial
1) CCNA Certification Tutorial (/introduction-ccna.html)

2) IPv4 Vs IPv6 (/difference-ipv4-vs-ipv6.html)


WiFi Basics

WiFi is the marketing name for IEEE standard 802.11. It is a standard for both Level 1 (physical) and Level 2 (data link) of a wireless data transmission
protocol.

802.11 defines many Level 1 variants. 802.11g is the new, high-speed Level 1 standard, versus 802.11b, the first generation WiFi. The radio frequency
band is around 3 Gigahertz, same as a microwave oven. As you can see in your WiFi setup, there are channels within the band. These channels overlap
so that at most 3 channels can be in use at the same time.

WiFi Concepts

There are two general types of WiFi transmission: DCF (Distributed Coordination Function) and PCF (Point Coordination Function). DCF is
ethernet in the air. It employs a very similar packet structure, and many of the same concepts. There are two problems that make wireless different then
wired.

The hidden substation problem.


High error rate.

These problems demand that a DCF WiFI be a CSMA/CA network (Collision Avoidance) rather than a CSMA/CD network (Collision Detect). The
result are the following protocol elements,

Positive Acknowledgement. Every packet sent is positively acknowledged by the receiver. The next packet is not sent until receiving a positive
acknowledgement for the previous packet.
Channel clearning. A transmission begins with a RTS (Request to Send) and the destination or receiver responds with a CTS (Clear to Send).
Then the data packets flow. For the channel is cleared by these two messages. All that hear the CTS squelch. This helps with the hidden
substation problem.
Channel reservation. Each packet has a NAV (Network Allocation Vector) containing a number X. The channel is reserved to the correspondents
(the sender and receiver of this packet) for an additonal X milliseconds after this packet. Once you have the channel, you can hold it with the
NAV. The last ACK contains NAV zero, to immediately release the channel.

As for PCF, it is a polling, token-ring type communcation system. We shall skip the details. It isn't much used.

Network topologies, bridging

A group of corresponding stations is called a BSS (Basic Service Set). The BSS can be organized in several ways.

Independent BSS, or ad hoc. The network is only the members of the BSS, they talk between themselves directly, they self-organize, there is not
central autority.
Infrastructure BSS. The BSS is organized around an Access Point which can bridge traffic out the BSS onto a distribution network. Members of
the BSS talk to the AP only. You can often understand a domain by answering the question "who will hear a broadcast". A BSS (data link layer) is
defined by who will hear a broadcast from the AP (but not by a station which is not an AP, because of the hidden station problem!).
ESS (Extended Service Set). A bunch of BSS's connected by a distribution network. The distribution network connects the Access Points. WiFi
doesn't specify the protocol that builds ESS's.

We will skip ad hoc and concentrate on Infrastructure.

Since this is ethernet on the air, each transmitter/receiver has a 48 bit MAC consistent with the ethernet address. That is, same address space, OUI's, and
so on. An AP is a bridge between wired and unwired ethernet, so it has two interfaces. As the leader of a BSS, it gives names the BSS by the ethernet
address of its air interface. This is called the BSSID.

An ESS is given a name, called the SSID (Service Set ID). This is the thing you type into your network configuration to join a WiFi network.

A packet on the air will have three addresses, source, destination and BSSID (access point address, essentially). The AP takes traffic it receives off the
air that has its address and drops it onto its wired interface, eliting its own address. That is, on the wired side, only the source and destination addresses
are seen. The address of the AP is not used, either its wired or unwired addresses.

When an AP sends a packet into the air, it uses the source and destination address of the packet it is bridging as found, and adds its own wireless
address as the BSSID. A wired station sending to a wireless station uses the wireless stations's ethernet address just as if it were a wired station. The AP
picks the packet off the wire, carries it across to its wireless interface, inserting its wireless address as the extra, third address, and sends it out to the
destination.

Association and so on

Definitions:

BSS
Basic Service Set. A bunch of machines forming a cell.
ESS
Extended Service Set. Using WiFi beyond a BSS, gluing together several BSS
BSSID
A 48 bit identifier for a BSS. If an infrastructure BSS, it is the MAC of the 802.11 side of the Acess Point. Else the local bit is set and a 48-bit
identifier is randomly selected.
SSID
Service set Identifier. An character string identifier for a ESS.
NAV
Network Access Vector. A time slot reservation, in microseconds.
RTS/CTS
Request To Send, Clear To Send. Reservation mechanism. Source,
Quick description

1. WiFi is standard 802.11, with various letters added. The standard includes a large number of physical variants.
2. The link levels can either be an Independent BSS (IBSS) or an infrastructure BSS. An infra. BSS can be contention based or coordinated (Point
Coordination Function).
3. Infrastructure BSS uses AP (access points) and a distribution medium, e.g. ethernet (802.2), either the AP acting as bridges. In a simple example,
the packet has three addresses, the two "transparent" endpoints and the BBSID, which is the way-point for the packet between air and wire.
4. In an infra. BSS, the AP either Beacons or responds to a probe from a node. An association (after possible authentication) occurs, so that traffic
from the host is bridged onto the distribution by the AP.
5. Gratuitous ARPs open up switches to L2 forward traffic to associated AP.
6. There are mobility issues, which are not part of the standard.
7. It is a positive acknowledge system. Each packet is positively acknowledge (an ACK packet) before the next packet is sent.
8. Packets carry NAV's which hold the channel clear for the time stated in the NAV.
9. RTS/CTS pair with NAV covering up to the end of the ACK of the data packet are exchanged. The ACK has a NAV of 0.
10. There are not NACKs.
HOME OFFICIAL  BOOKS STUDY MATERIAL  QUIZ ISRO ANALYSIS TOPPERS STRATEGY 

GATE CUTOFF

Basics of Wi-Fi SEARCH BLOG

 January 29, 2018  Anup Patel  CN, Resources


Search … 
WiFi stands for Wireless Fidelity.

LOGIN/REGISTER
It is Based on 802.11 and primarily a LAN Technology. Wi-Fi operates at the physical
and data link layers of the OSI model

Username or E-mail *
Wi-Fi is Half Duplex.
Ethernet is more secure than WiFi
There is Collision avoidance in wi and collision detection in Ethernet.
Password *

 Keep me signed in

Login

Register

Forgot your password?

GET UPDATES

Enter your email address to Get All


latest updates in your Mailbox:
Important Points

Devices in Same BSS can connect Directly.


Devices in di erent BSS can connect through Access Point.
802.11a uses the 5 GHz U-NII band, which o ers at least 23 non-overlapping SUBSCRIBE
channels rather than the 2.4 GHz ISM frequency band which o er only three non-
overlapping channels. Delivered by FeedBurner
RTS and CTS mechanism is used for Collision Avoidance.
RTS and CTS Also solve hidden node problem or hidden terminal problem.
Access point consisting of antenna and routers are main source that transmit and
UPDATES
receive radio waves.
Bandwidth :  COAP 2020 Details and Important
Dates March 18, 2020
25 MHZ for 802.11b
IISc Bangalore Interview
20 MHz for 802.11a
Experience by Eklavya Sharma|
AIR 86 GATE CS 2018 March 18,
According to distributed control function , a wi station will transmit only when
2020
channel is clear. All transmissions are Acknowledged. So, if a station does not receive
an ACK , it assume collision and retry after random amount of time. IISc Bangalore Interview
Experience by Ravi Raja | AIR 888
GATE CS 2019 March 18, 2020

There are 2 General type of Wi Transmission IIT’s and IISc Cuto Gate 2019
March 18, 2020
1. DCF (Distributed Coordination Function)
IISc Bangalore GATE 2019 Cuto s
2. PCF (Point coordination Function) – Not much used
March 18, 2020

There are 2 Problem that makes wireless di erent than Wired :

1. Hidden Substation Problem


2. High Error Rate

Important Notes

Every packet sent is positively acknowledged by receiver. Next packet is not sent
until receiving a positive acknowledgment for previous Packet.
A Transmission begin with a RTS (Request to send) & Receiver respond with CTS
(Clear to send). then the data packet ow. This help in hidden substation problem.

A group of corresponding station is called a BSS (Basic Service set).

Independent BSS, or ad hoc :  The network is only the members of the BSS, they talk
between themselves directly, they self-organize, there is no central autority.

Infrastructure BSS :  The BSS is organized around an Access Point which can bridge
tra c out the BSS onto a distribution network. Members of the BSS talk to the
AP(Access Point) only.  A BSS (data link layer) is de ned by who will hear a broadcast
from the AP (but not by a station which is not an AP, because of the hidden station
problem!).
ESS (Extended Service Set) :  A bunch of BSS’s connected by a distribution network.
The distribution network connects the Access Points. WiFi doesn’t specify the protocol
that builds ESS’s.

When a mobile host move beyond the range of one base station and into range
of another. It will change its point of attachment into larger network . This is
Hando .

References

Wikipedia
http://www.cs.miami.edu/home/burt/learning/Csc524.052/notes/wi .html
Kurose

Check Also : IPv4 Vs IPv6

If you like GatePoint and would like to contribute, you can also write an article and
mail your article to gatecsepoint@gmail.com. See your article appearing on the
GatePoint main page and help other Gate Aspirants.

Anup Patel
M.Tech Student at Indian Institute of Science
AIR 2 ISRO SC Written Test Dec 2017
AIR 142 GATE 2018

Please write comments if you nd anything incorrect, or you want to share more
information about the topic discussed above.
Public Key Cryptography | RSA Algorithm Example
Computer Networks

Cryptography in Network Security-

Before you go through this article, make sure that you have gone through the previous article on Cryptography.

We have discussed-

Cryptography is a method of storing and transmitting data in a particular form.


Cryptography techniques are-

In this article, we will discuss about Asymmetric Key Cryptography.

Asymmetric Key Cryptography-

In this technique,

Sender and receiver use different keys to encrypt and decrypt the message.
It is called so because sender and receiver use different keys.
It is also called as public key cryptography.

Working-

The message exchange using public key cryptography involves the following steps-

Step-01:
At sender side,

Sender encrypts the message using receiver’s public key.


The public key of receiver is publicly available and known to everyone.
Encryption converts the message into a cipher text.
This cipher text can be decrypted only using the receiver’s private key.

Step-02:

The cipher text is sent to the receiver over the communication channel.

Step-03:

At receiver side,

Receiver decrypts the cipher text using his private key.


The private key of the receiver is known only to the receiver.
Using the public key, it is not possible for anyone to determine the receiver’s private key.
After decryption, cipher text converts back into a readable format.

Advantages-

The advantages of public key cryptography are-

It is more robust.
It is less susceptible to third-party security breach attempts.

Disadvantages-

The disadvantages of public key cryptography are-

It involves high computational requirements.


It is slower than symmetric key cryptography.

Number of Keys Required-

To use public key cryptography,

Each individual requires two keys- one public key and one private key.
For n individuals to communicate, number of keys required = 2 x n = 2n keys.

Asymmetric Encryption Algorithms-

The famous asymmetric encryption algorithms are-

1. RSA Algorithm
2. Diffie-Hellman Key Exchange

In this article, we will discuss about RSA Algorithm.

RSA Algorithm-

Let-

Public key of the receiver = (e , n)


Private key of the receiver = (d , n)

Then, RSA Algorithm works in the following steps-

Step-01:

At sender side,

Sender represents the message to be sent as an integer between 0 and n-1.


Sender encrypts the message using the public key of receiver.

It raises the plain text message ‘P’ to the eth power modulo n.
This converts the message into cipher text ‘C’.

C = Pe mod n

Step-02:

The cipher text ‘C’ is sent to the receiver over the communication channel.

Step-03:
At receiver side,

Receiver decrypts the cipher text using his private key.

It raises the cipher text ‘C’ to the dth power modulo n.


This converts the cipher text back into the plain text ‘P’.

P = Cd mod n

NOTE-

‘e’ and ‘d’ must be multiplicative inverses modulo Ø(n)

After decryption, receiver must have-

P = Cd mod n

P = (Pe mod n)d mod n

P = Ped mod n

For this equation to be true, by Euler’s Theorem, we must have-

ed = 1 mod Ø(n)

OR

ed = kØ(n) + 1

Thus, e and d must be multiplicative inverses modulo Ø(n).

Steps to Generate Public Key And Private Key-

An individual can generate his public key and private key using the following steps-

Step-01:

Choose any two prime numbers p and q such that-

They are different.


They are very large.

Step-02:

Calculate ‘n’ and toilent function Ø(n) where-

n=pxq
Ø(n) = (p-1) x (q-1)

Step-03:
Choose any value of ‘e’ such that-

1 < e < Ø(n)


gcd (e, Ø(n)) = 1

Step-04:

Determine ‘d’ such that-

You already know the value of ‘e’ and Ø(n).


Choose the least positive integer value of ‘k’ which gives the integer value of ‘d’ as a result.
Use trial and error method.
Start substituting different values of ‘k’ from 0.

PRACTICE PROBLEMS BASED ON RSA ALGORITHM-

Problem-01:

In a RSA cryptosystem, a participant A uses two prime numbers p = 13 and q = 17 to generate her public and private keys. If the public key of A is
35, then the private key of A is _______.

Solution-

Given-

Prime numbers p = 13 and q = 17


Public key = 35

Step-01:

Calculate ‘n’ and toilent function Ø(n).

Value of n,

n=pxq

n = 13 x 17

∴ n = 221
Toilent function,

Ø(n) = (p-1) x (q-1)

Ø(n) = (13-1) x (17-1)

∴ Ø(n) = 192

Step-02:

We are already given the value of e = 35.


Thus, public key = (e , n) = (35 , 221)

Step-03:

Determine ‘d’ such that-

Here,

The least value of ‘k’ which gives the integer value of ‘d’ is k = 2.
On substituting k = 2, we get d = 11.

Thus, private key of participant A = (d , n) = (11, 221).

Problem-02:

In the RSA public key cryptosystem, the private and public keys are (e, n) and (d, n) respectively, where n = p x q and p and q are large primes.
Besides, n is public and p and q are private. Let M be an integer such that 0 < M < n and f(n) = (p-1)(q-1).

Now consider the following equations-

I. M’ = Me mod n and M = (M’)d mod n

II. ed ≡ 1 mod n

III. ed = 1 mod f(n)

IV. M’ = Me mod f(n) and M = (M’)d mod f(n)

Which of the above equations correctly represent RSA cryptosystem?


1. I and II
2. I and III
3. II and IV
4. III and IV

Solution-

Clearly, Option (B) is correct.

To gain better understanding about RSA Algorithm,

Watch this Video Lecture

Next Article- Diffie Hellman Key Exchange Algorithm

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary

Article Name Public Key Cryptography | RSA Algorithm Example

Description Public key cryptography or Asymmetric key cryptography


use different keys for encryption and decryption. RSA
Algorithm Examples. RSA Algorithm and Diffie Hellman
Key Exchange are asymmetric key algorithms.

Author Akshay Singhal

Publisher Name Gate Vidyalay

Publisher Logo

Liked this article? Share it with your friends and classmates now-
Di e Hellman Key Exchange | Asymmetric Encryption
Computer Networks

Asymmetric Encryption-

Before you go through this article, make sure that you have gone through the previous article on Asymmetric Key Cryptography.

In asymmetric encryption,

Sender and receiver use different keys to encrypt and decrypt the message.
The famous asymmetric encryption algorithms are-

In this article, we will discuss about Diffie Hellman Key Exchange Algorithm.

Symmetric Key Cryptography-

In symmetric key cryptography,

Both sender and receiver use a common secret key to encrypt and decrypt the message.
The major issue is exchanging the secret key between the sender and the receiver.
Attackers might intrude and know the secret key while exchanging it.

Read More- Symmetric Key Cryptography

Di e Hellman Key Exchange-

As the name suggests,

This algorithm is used to exchange the secret key between the sender and the receiver.
This algorithm facilitates the exchange of secret key without actually transmitting it.

Di e Hellman Key Exchange Algorithm-

Let-

Private key of the sender = Xs

Public key of the sender = Ys

Private key of the receiver = Xr

Public key of the receiver = Yr


Using Diffie Hellman Algorithm, the key is exchanged in the following steps-

Step-01:

One of the parties choose two numbers ‘a’ and ‘n’ and exchange with the other party.
‘a’ is the primitive root of prime number ‘n’.
After this exchange, both the parties know the value of ‘a’ and ‘n’.

Step-02:

Both the parties already know their own private key.


Both the parties calculate the value of their public key and exchange with each other.

Sender calculate its public key as-

Ys = aXs mod n

Receiver calculate its public key as-

Yr = aXr mod n

Step-03:

Both the parties receive public key of each other.


Now, both the parties calculate the value of secret key.

Sender calculates secret key as-

Secret key = (Yr)Xs mod n

Receiver calculates secret key as-

Secret key = (Ys)Xr mod n

Finally, both the parties obtain the same value of secret key.

PRACTICE PROBLEMS BASED ON DIFFIE HELLMAN KEY EXCHANGE-


Problem-01:

Suppose that two parties A and B wish to set up a common secret key (D-H key) between themselves using the Diffie Hellman key exchange
technique. They agree on 7 as the modulus and 3 as the primitive root. Party A chooses 2 and party B chooses 5 as their respective secrets. Their
D-H key is-

1. 3
2. 4
3. 5
4. 6

Solution-

Given-

n=7
a=3
Private key of A = 2
Private key of B = 5

Step-01:

Both the parties calculate the value of their public key and exchange with each other.

Public key of A

= 3private key of A mod 7

= 32 mod 7

=2

Public key of B

= 3private key of B mod 7

= 35 mod 7

=5

Step-02:

Both the parties calculate the value of secret key at their respective side.

Secret key obtained by A

= 5private key of A mod 7

= 52 mod 7

=4
Secret key obtained by B

= 2private key of B mod 7

= 25 mod 7

=4

Finally, both the parties obtain the same value of secret key.

The value of common secret key = 4.

Thus, Option (B) is correct.

Problem-02:

In a Diffie-Hellman Key Exchange, Alice and Bob have chosen prime value q = 17 and primitive root = 5. If Alice’s secret key is 4 and Bob’s secret
key is 6, what is the secret key they exchanged?

1. 16
2. 17
3. 18
4. 19

Solution-

Given-

n = 17
a=5
Private key of Alice = 4
Private key of Bob = 6

Step-01:

Both Alice and Bob calculate the value of their public key and exchange with each other.

Public key of Alice

= 5private key of Alice mod 17

= 54 mod 17

= 13

Public key of Bob

= 5private key of Bob mod 17

= 56 mod 17

=2
Step-02:

Both the parties calculate the value of secret key at their respective side.

Secret key obtained by Alice

= 2private key of Alice mod 7

= 24 mod 17

= 16

Secret key obtained by Bob

= 13private key of Bob mod 7

= 136 mod 17

= 16

Finally, both the parties obtain the same value of secret key.

The value of common secret key = 16.

Thus, Option (A) is correct.

To gain better understanding about Diffie Hellman Key Exchange Algorithm,

Watch this Video Lecture

Next Article- Digital Signatures

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary
How Digital Signature Works | Algorithm
Computer Networks

Digital Signatures-

The signature on a document is the proof to the receiver that the document is coming from the correct entity.
A digital signature guarantees the authenticity of an electronic document in digital communication.

How Digital Signature Works?

The sender of the document digitally signs the document.


The receiver of the document verifies the signature.

The steps involved in the digital signature algorithm are-

At Sender Side-

At sender side,

Using a hash function, sender converts the message to be sent into a digested form.
There are various hash functions that may be used like SHA-1, MD5 etc.
The message in digested form is called as message digest.
Sender encrypts the message digest using his private key.
The encrypted message digest is called as signed digest or signature of the sender.
Sender sends the signed digest along with the original message to the receiver.

At Receiver Side-

At receiver side,

Receiver receives the original message and the signed digest.


Using a hash function, receiver converts the original message into a message digest.
Also, receiver decrypts the received signed digest using the sender’s public key.
On decryption, receiver obtains the message digest.
Now, receiver compares both the message digests.
If they are same, then it is proved that the document is coming from the correct entity.

Also Read- RSA Algorithm

Important Points-

Point-01:

After digitally signing the document, sender sends the following two things to the receiver-

Signed digest or signature


Original message

Point-02:

Sender uses his private key to digitally sign the document.


Receiver uses the sender’s public key to verify the signature.
Point-03:

Digital signature of a person varies from document to document.


This ensures authenticity of the document.

Point-04:

In digital signature,

There is one to one relationship between a message and a signature.


Each message has its own signature.

Point-05:

Digital signature verifies-

Authenticity
Integrity
Non-repudiation

Also Read- Diffie Hellman Key Exchange Algorithm

PRACTICE PROBLEMS BASED ON DIGITAL SIGNATURES-

Problem-01:

Anarkali digitally signs a message and sends it to Salim. Verification of the signature by Salim requires-

1. Anarkali’s public key


2. Salim’s public key
3. Salim’s private key
4. Anarkali’s private key

Solution-

Clearly, Option (A) is correct.


Problem-02:

Consider that B wants to send a message m that is digitally signed to A. Let the pair of private and public keys for A and B be denoted by Kx– and
Kx+ for x = A, B respectively. Let Kx(m) represent the operation of encrypting m with a key Kx and H(m) represent the message digest. Which one
of the following indicates the correct way of sending the message m along with the digital signature to A?

1. {m, KB+(H(m))}

2. {m, KB–(H(m))}

3. {m, KA–(H(m))}

4. {m, KA+(H(m))}

Solution-

Clearly, Option (B) is correct.

To gain better understanding about Digital Signatures,

Watch this Video Lecture

Get more notes and other study material of Computer Networks.

Watch video lectures by visiting our YouTube channel LearnVidFun.

Summary

Article Name How Digital Signature Works | Algorithm

Description A digital signature guarantees the authenticity of an


electronic document. How digital signature works? The
digital signature algorithm describes how digital signature
works.

Author Akshay Singhal

Publisher Name Gate Vidyalay

Publisher Logo

Liked this article? Share it with your friends and classmates now-
Introduction to Firewalls v1.01 – Aaron Balchunas 1

- Introduction to Firewalls -
Firewall Basics
Traditionally, a firewall is defined as any device (or software) used to filter
or control the flow of traffic. Firewalls are typically implemented on the
network perimeter, and function by defining trusted and untrusted zones:

Most firewalls will permit traffic from the trusted zone to the untrusted
zone, without any explicit configuration. However, traffic from the
untrusted zone to the trusted zone must be explicitly permitted. Thus, any
traffic that is not explicitly permitted from the untrusted to trusted zone will
be implicitly denied (by default on most firewall systems).
A firewall is not limited to only two zones, but can contain multiple ‘less
trusted’ zones, often referred to as Demilitarized Zones (DMZ’s).

To control the trust value of each zone, each firewall interface is assigned a
security level, which is often represented as a numerical value or even color.
For example, in the above diagram, the Trusted Zone could be assigned a
security value of 100, the Less Trusted Zone a value of 75, and the
Untrusted Zone a value of 0.
As stated previously, traffic from a higher security to lower security zone is
(generally) allowed by default, while traffic from a lower security to higher
security zone requires explicit permission.
***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 2

Firewall Services
Firewalls perform the following services:
• Packet Filtering
• Stateful Packet Inspection
• Proxying
• Network Address Translation (NAT)
Each will be covered in some detail in this guide.

Packet Filtering
Packet Filtering is one of the core services provided by firewalls. Packets
can be filtered (permitted or denied) based on a wide range of criteria:
• Source address
• Destination address
• Protocol Type (IP, TCP, UDP, ICMP, ESP, etc.)
• Source Port
• Destination Port
Packet filtering is implemented as a rule-list:
Number Action Protocol Source Add. Source Port Destination Add. Destination Port

1. Deny TCP Any Any 172.16.1.5 666


2. Permit IP Any Any 172.16.1.5 Any
3. Permit TCP Any Any 172.16.1.1 443
4. Permit TCP Any Any 172.16.1.1 80
5. Permit TCP Any Any 172.16.1.10 25
6. Deny TCP 66.1.1.5 Any 172.16.1.10 110
7. Permit TCP Any Any 172.16.1.10 110

The order of the rule-list is a critical consideration. The rule-list is always


parsed from top-to-bottom. Thus, more specific rules should always be
placed near the top of the rule-list, otherwise they may be negated by a
previous, more encompassing rule.
Also, an implicit ‘deny any’ rule usually exists at the bottom of a rule-list,
which often can’t be removed. Thus, rule-lists that contain only deny
statements will prevent all traffic.

***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 3

Stateful Packet Inspection


Stateful packet inspection provides services beyond simple packet-
filtering, by additionally tracking TCP or UDP sessions between devices.
For example, stateful inspection can track connections that originate from
the trusted network. This session information is kept in a state session table,
which allows temporary holes to be opened in the firewall for the return
traffic, which might otherwise be denied.
Connections from the untrusted network to the trusted network are also
monitored, to prevent Denial of Service (DoS) attacks. If a high number of
half-open sessions are detected, the firewall can be configured to drop the
session (and even block the source), or send an alert message indicating an
attack is occurring.
A half-open TCP session indicates that the three-way handshake has not yet
completed. A half-open UDP session indicates that no return UDP traffic
has been detected. A large number of half-opened sessions will chew up
resources, while preventing legitimate connections from being established.

Proxy Services
A proxy server, by definition, is used to make a request on behalf of another
device. It essentially serves as a middle-man for communication between
devices.
This provides an element of security, by hiding the actual requesting source.
All traffic will seem to be originated from the proxy itself.
Traditionally, proxy servers were used to cache a local copy of requested
external data. This improved performance in limited-bandwidth
environments, allowing clients to request data from the proxy, instead of the
actual external source.
Other services that proxy servers can provide:
• Logging
• Content Filtering
• Authentication

***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 4

NAT (Network Address Translation)


The rapid growth of the Internet resulted in a shortage of IPv4 addresses. In
response, the powers that be designated a specific subset of the IPv4 address
space to be private, to temporarily alleviate this problem.
A public address can be routed on the Internet. Thus, devices that should be
Internet accessible (such web or email servers) must be configured with
public addresses.
A private address is only intended for use within an organization, and can
never be routed on the internet. Three private addressing ranges were
allocated, one for each IPv4 class:
• Class A - 10.x.x.x
• Class B - 172.16-31.x.x
• Class C - 192.168.x.x
NAT (Network Address Translation) is used to translate between private
addresses and public addresses. NAT allows devices configured with a
private address to be stamped with a public address, thus allowing those
devices to communicate across the Internet.
NAT is not restricted to just public-to-private address translations, though
this is the most common application of NAT. NAT can perform a public-to-
public address translation, or a private-to-private address translation as well.
NAT provides an additional benefit – hiding the specific addresses and
addressing structure of the internal network.

(Reference: http://www.cisco.com/en/US/tech/tk648/tk361/technologies_white_paper09186a0080194af8.shtml)

***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 5

Types of NAT
NAT can be implemented using one of three methods:
Static NAT – performs a static one-to-one translation between two
addresses, or between a port on one address to a port on another address.
Static NAT is most often used to assign a public address to a device behind a
NAT-enabled firewall/router.
Dynamic NAT – utilizes a pool of global addresses to dynamically translate
the outbound traffic of clients behind a NAT-enabled device.
NAT Overload or Port Address Translation (PAT) – translates the
outbound traffic of clients to unique port numbers off of a single global
address. PAT is necessary when the number of internal clients exceeds the
available global addresses.

NAT Terminology
Specific terms are used to identify the various NAT addresses:
• Inside Local – the specific IP address assigned to an inside host
behind a NAT-enabled device (usually a private address).
• Inside Global – the address that identifies an inside host to the
outside world (usually a public address). Essentially, this is the
dynamically or statically-assigned public address assigned to a private
host.
• Outside Global – the address assigned to an outside host (usually a
public address).
• Outside Local – the address that identifies an outside host to the
inside network. Often, this is the same address as the Outside Global.
However, it is occasionally necessary to translate an outside (usually
public) address to an inside (usually private) address.
For simplicity sake, it is generally acceptable to associate global addresses
with public addresses, and local addresses with private addresses.
However, remember that public-to-public and private-to-private translation
is still possible. Inside hosts are within the local network, while outside
hosts are external to the local network.
***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 6

NAT Terminology Example

Consider the above example. For a connection from HostA to HostB, the
NAT addresses are identified as follows:
• Inside Local Address - 10.1.1.10
• Inside Global Address - 55.1.1.1
• Outside Global Address – 99.1.1.2
• Outside Local Address – 99.1.1.2
HostA’s configured address is 10.1.1.10, and is identified as its Inside Local
address. When HostA communicates with the Internet, it is stamped with
RouterA’s public address, using PAT. Thus, HostA’s Inside Global address
will become 55.1.1.1.
When HostA communicates with HostB, it will access HostB’s Outside
Global address of 99.1.1.2. In this instance, the Outside Local address is also
99.1.1.2. HostA is never aware of HostB’s configured address.
It is possible to map an address from the local network (such as 10.1.1.5) to
the global address of the remote device (in this case, 99.1.1.2). This may be
required if a legacy device exists that will only communicate with the local
subnet. In this instance, the Outside Local address would be 10.1.1.5.
Static NAT Translation
99.1.1.2 = 192.168.1.5

10.1.1.1 55.1.1.1 99.1.1.1 192.168.1.1


Internet
RouterA RouterA
HostA NAT-Enabled NAT-Enabled HostB
10.1.1.10 192.168.1.5

SRC Address = 10.1.1.10 SRC Address = 55.1.1.1:31092 SRC Address = 55.1.1.1:31092


DST Address = 99.1.1.2 DST Address = 99.1.1.2 DST Address = 192.168.1.5

The above example demonstrates how the source (SRC) and destination
(DST) IP addresses within the Network-Layer header are translated by NAT.

(Reference: http://www.cisco.com/warp/public/556/8.html)
***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.
Introduction to Firewalls v1.01 – Aaron Balchunas 7

Implementing a DMZ
As briefly described earlier, a DMZ is essentially a less trusted zone that
sits between the trusted zone (generally the LAN) and the untrusted zone
(generally the Internet). Devices that provide services to the untrusted world
are generally placed in the DMZ, to provide separation from the trusted
network.
A single firewall with multiple ports can be used to implement a logical
DMZ:

A more secure DMZ (referred to as a screened subnet) utilizes multiple


firewalls:

***
All original material copyright © 2007 by Aaron Balchunas (aaron@routeralley.com),
unless otherwise noted. All other material copyright © of their respective owners.
This material may be copied and used freely, but may not be altered or sold without the expressed written
consent of the owner of the above copyright. Updated material may be found at http://www.routeralley.com.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy