Computer Network
Computer Network
Answer: The main aim of transport layer is to be delivered the entire message from source to
destination. Transport layer ensures whole message arrives intact and in order, ensuring both
error control and flow control at the source to destination level. It decides if data transmission
should be on parallel path or single path
Transport layer breaks the message (data) into small units so that they are handled more
efficiently by the network layer and ensures that message arrives in order by checking error and
flow control.
1. Service Point Addressing : Transport Layer header includes service point address which is
port address. This layer gets the message to the correct process on the computer unlike
contains sequence number, which enables this layer in reassembling the message. Message
is reassembled correctly upon arrival at the destination and replaces packets which were lost
in transmission.
5. Error Control : Error Control is performed end to end in this layer to ensure that the
complete message arrives at the receiving transport layer without any error. Error
Comparison
Let us compare symmetric-key and asymmetric-key cryptography. Encryption can be thought of
as electronic locking; decryption as electronic unlocking. The sender puts the message in a box
and locks the box by using a key; the receiver unlocks the box with a key and takes out the
message. The difference lies in the mechanism of the locking and unlocking and the type of keys
used.
In symmetric-key cryptography, the same key locks and unlocks the box. In asymmetric-key
cryptography, one key locks the box, but another key is needed to unlock it.
Answer: The primary goal of this layer is to take care of the syntax and semantics of the
information exchanged between two communicating systems. Presentation layer takes care that
the data is sent in such a way that the receiver will understand the information (data) and will be
able to use the data. Languages (syntax) can be different of the two communicating systems.
Under this condition presentation layer plays a role translator.
2. Encryption : It carries out encryption at the transmitter and decryption at the receiver.
3. Compression : It carries out data compression to reduce the bandwidth of the data to be
transmitted. The primary role of Data compression is to reduce the number of bits to be
0transmitted. It is important in transmitting multimedia such as audio, video, text etc.
Session Layer
Its main aim is to establish, maintain and synchronize the interaction between communicating
systems. Session layer manages and synchronize the conversation between two different
applications. Transfer of data from one destination to another session layer streams of data are
marked and are resynchronized properly, so that the ends of the messages are not cut prematurely
and data loss is avoided.
1. Dialog Control : This layer allows two systems to start communication with each other in
half-duplex or full-duplex.
2. Synchronization : This layer allows a process to add checkpoints which are considered as
synchronization points into stream of data. Example: If a system is sending a file of 800
pages, adding checkpoints after every 50 pages is recommended. This ensures that 50 page
unit is successfully received and acknowledged. This is beneficial at the time of crash as if a
crash happens at page number 110; there is no need to retransmit 1 to100 pages.
Answer: The most common public key algorithm is RSA, named for its inventors Rivest,
Shamir, and Adleman (RSA). It uses two numbers, e and d, as the public and private keys.
Bob use the following steps to select the private and public keys:
1. Bob chooses two very large prime numbers p and q. Remember that a prime number is one
that can be divided evenly only by 1 and itself.
2. Bob multiplies the above two primes to find n, the modulus for encryption and decryption. In
other words, n = p X q.
3. Bob calculates another number Ф=(p -1) X (q - 1).
4. Bob chooses a random integer e. He then calculates d so that d x e= 1 mod Ф.
5. Bob announces e and n to the public; he keeps Ф and d secret.
In RSA, e and n are announced to the public; d and Ф are kept secret.
Encryption
Anyone who needs to send a message to Bob can use n and e. For example, if Alice needs to
send a message to Bob, she can change the message, usually a short one, to an integer. This is the
plaintext. She then calculates the ciphertext, using e and n.
C=p^e(mod n)
Alice sends C, the ciphertext, to Bob.
Decryption
Bob keeps Ф and d private. When he receives the ciphertext, he uses his private key d to decrypt
the message:
P= C ^d(mod n)
Example
Bob chooses 7 and 11 as p and q and calculates n = 7. 11 = 77. The value of Ф = (7 - 1) (11 - 1)
or 60. Now he chooses two keys, e and d. If he chooses e to be 13, then d is 37. Now imagine
Alice sends the plaintext 5 to Bob. She uses the public key 13 to encrypt 5.
Plaintext: 5
C=5^13 =26 mod 77
Cipher text: 26
Bob receives the ciphertext 26 and uses the private key 37 to decipher the cipher text:
Cipher text: 26
P = 26^37 =5 mod 77
Plaintext: 5
The plaintext 5 sent by Alice is received as plaintext 5 by Bob.
Answer: Data compression is the function of presentation layer in OSI reference model.
Compression is often used to maximize the use of bandwidth across a network or to optimize
disk space when saving data . Data compression is about storing and sending a smaller number
of bits.
1. Lossless compression
2. Lossy compression
In lossless methods, original data and the data after compression and decompression are
exactly the same.
Lossless methods are used when we can’t afford to lose any data: legal and medical documents,
computer programs
Lossless Compression Algorithms
The various algorithms used to implement lossless data compression are :
JPEG Encoding
In JPEG, a grayscale picture is divided into 8x8 pixel blocks to decrease the number of
calculations.
Basic idea:
Change the picture into a linear (vector) sets of numbers that reveals the
redundancies.
MPEG Encoding
Basic idea:
Each video is a rapid sequence of a set of frames. Each frame is a spatial
combination of pixels, or a picture.
Compressing video =
Spatial Compression
• Temporal Compression
Audio Compression
Predictive encoding
Perceptual encoding
Audio Encoding
Predictive Encoding
Only the differences between samples are encoded, not the whole sample
values.
Several standards: GSM (13 kbps), G.729 (8 kbps), and G.723.3 (6.4 or
5.3 kbps)
CD-quality audio needs at least 1.411 Mbps and cannot be sent over the
Internet without compression.
Connection establishment:
The three steps in this phase are as follows.
• The client sends the first segment, a SYN segment, in which only the SYN flag is set.
This segment is for synchronization of sequence numbers. It consumes one sequence
number.When the data transfer starts, the sequence number is incremented by 1.
• A SYN segment cannot carry data, but it consumes one sequence number.
• The server sends the second segment, a SYN +ACK segment, with 2 flag bits set: SYN
and ACK. This segment has a dual purpose.
• A SYN +ACK segment cannot carry data, but does consume one sequence number.
• The client sends the third segment. This is just an ACK segment. It acknowledges the
receipt of the second segment with the ACK flag and acknowledgment number field.
• An ACK segment, if carrying no data, consumes no sequence number.
Data Transfer
After connection is established, bidirectional data transfer can take place. The client and server
can both send data and acknowledgments.
Data traveling in the same direction as an acknowledgment are carried on the same segment. The
acknowledgment is piggybacked with the data.
Connection Termination
• Any of the two parties involved in exchanging data (client or server) can close the
connection, although it is usually initiated by the client.
• In a normal situation, the client TCP, after receiving a close command from the client
process, sends the first segment, a FIN segment in which the FIN flag is set. a FIN
segment can include the last chunk of data sent by the client, or it can be just a control
segment
• If it is only a control segment, it consumes only one sequence number.
• The server TCP, after receiving the FIN segment, informs its process of the situation and
sends the second segment, a FIN +ACK segment, to confirm the receipt of the FIN
segment from the client and at the same time to announce the closing of the connection in
the other direction. This segment can also contain the last chunk of data from the server.
If it does not carry data, it consumes only one sequence number.
• The client TCP sends the last segment, an ACK segment, to confirm the receipt of the
FIN segment from the TCP server. This segment contains the acknowledgment number,
which is 1 plus the sequence number received in the FIN segment from the server. This
segment cannot carry data and consumes no sequence numbers.
•
UDP (user datagram protocol)