Introduction To TCP Congestion Control

Congestion window and a congestion policy that avoid congestion is used by TCP at transport layer.
                     If the network cannot deliver the data as fast as it is created by the sender, it must tell the sender to slow down. In other words, in addition to the receiver, the network is a second entity that determines the size of the sender’s window.

TCP congestion control Algorithm 
Slow Start Phase: starts slowly with 1MSS and grow till the  threshold in exponential manner.
Congestion Avoidance Phase: After reaching the threshold increment is by 1 till you reached the max receiver window size.
Congestion Detection Phase: Sender goes back to Slow start phase or Congestion avoidance phase.i.e

1) Retransmission due to Timeout – In this case congestion possibility is high.

(a) ssthresh is reduced to half of the current window size.
(b) set cwnd = 1
(c) start with slow start phase again.

2) Retransmission due to 3 Acknowledgement Duplicates – In this case congestion possibility is less.

(a) ssthresh value reduces to half of the current window size.
(b) set cwnd= ssthresh
(c) start with congestion avoidance phase









1 2 4 8 16 32(threshold arrive) 33 34 35 ------------------------------64

now suppose at MSS 34 TO occure then Threshold =floor(Wc/2)

       i.e 17 now slow start phase start with threshold 17 

1 2 4 8 16 17 18 19 20

now at MSS 20  3 duplicate acknowldegement occure the threshold =floor(Wc/2)

sender window size will be equl to threshold i.e 10 and start in congestion Avoidance phase

10 11 12 13...........................

Retransmission in TCP

Tcp use both SR(selective repeat) and GBN (Go backN).Actually it is 75% SR and 25% GBN. In case of acknowledgement it is GBN because of cummulative acknowledgement.

Now it is SR also because it have equal sender window size and receiver window size and along with this it can accept out of order packet.


Re transmission after TO:

Here assume that we have send one segment and it get lost.




Suppose ,now  if we have send 5 segment and second segment get lost and rest are accepted then there is a concept of early retransmission come to the picture  i.e  retransmit before time out. It is also called as Retransmission after three duplicate acknowledgement.



If all three duplicate acknowledgement lost or any of them lost the time out will occure and this can be handled.

UDP(User Datagram Protocol)

UDP is a transport layer protocol provides an unreliable, connectionless and fast services .

It is a very simple protocol and has very less overhead.


Despite being unreliable why it is used??

Let's say we have to send a very small message and we are not very much concerning about reliability so we can use UDP.


UDP is used in the following applications:

  • DNS
  • SNMP
  • NTP etc.

UDP packets are called user datagram and have the fixed-sized header of 8 Bytes.


1.Source port number: This is the port number used by the process running on the source host. It is 16 bits long, which means that the port number can range from 0 to65,535.


2.Destination port number: This is the port number used by the process running on the destination host. It is also 16 bits long. 

If in some case destination is some server then that must be a well-known port number.

3. Total length: It is  16 bit long and 

total length= UDP datagram length + header 

Actually, the length field is not necessary for UDP datagram because UDP datagram is carried in IP datagram and if we subtract IP header from total IP length we will get UDP length.

UDP length = IP length - IP header's length



UDP checksum has three sections fields:

  • Pseudo-header
  • The UDP header
  • The data coming from the application layer
  1. The Pseudo header is the part of the IP header in which UDP datagram is going to encapsulate and entries in this are all 0's.
  2. If the checksum does not include Pseudo header it means user datagram may arrive safe and unaffected.
  3. There is also a protocol field that tells that packets belong to UDP and the value of the protocol field for UDP is 17.


Some operations of UDP:-

1. Connectionless:

Connectionless in UDP means:-

  1. No reservation of resources.
  2. datagram from the same source can take a different path even they are going to the same destination.
  3. There is no relation between datagrams of the same source and they are not numbered.
  4. It does not chop large data into small data so data size should be such that it can fit into one UDP datagram.

 2. NO flow and Error control:-

Since there is no flow control, it may happen that the receiver is overflow with incoming messages.

NO error control means: sender doesn't know whether the packet is lost or reached. if the receiver gets the wrong packest it silently discards.


To send a message from one process to another, the UDP protocol encapsulates and decapsulates messages in an IP datagram.


Some important applications of UDP:-

  1. It is useful in applications that require simple little request-response communication.
  2. Multicasting is the capability of UDP not TCP.
  3. All routing algorithms use UDP.
  4. TFTP uses UDP.
  5. RIP(Route Information Protocol) uses UDP.



Connection Termination In TCP

Client has sent FIN segment to the server and moves to FIN-WAIT-1,i.e. waiting for ACK for own FIN segment.There are two possibilities here:

1)If Client receives ACK for its FIN then client will move to FIN WAIT-2 and will wait for matching FIN from server side .After receiving the FIN from server,client will send ACK and move to TIME-WAIT sate.


2)Client has sent FIN segment but didn't get ACK till the time.Instead of ACK ,client received FIN from server side.client will acknowledge this FIN and move to CLOSE state.Here Client will wait for the ACK for its own FIN. After receiving ACK ,client will move to TIME-WAIT state.

Connection establishment In TCP

TCP is a connection oriented protocol and every connection oriented protocol needs to establish connection in order to reserve resources at both the communicating ends.

Connection Establishment –



Sender starts the process with following:

Sequence number (Seq=521): contains the random initial sequence number which generated at sender side.

Syn flag (Syn=1): request receiver to synchronize its sequence number with the above provided sequence number.

Maximum segment size (MSS=1460 B): sender tells its maximum segment size, so that receiver sends datagram which won’t require any fragmentation. MSS field is present inside Option field in TCP header.

Window size (window=14600 B): sender tells about his buffer capacity in which he has to store messages from receiver.

TCP is a full duplex protocol so both sender and receiver require a window for receiving messages from one another.


Sequence number (Seq=2000): contains the random initial sequence number which generated at receiver side.

Syn flag (Syn=1): request sender to synchronize its sequence number with the above provided sequence number.

Maximum segment size (MSS=500 B): sender tells its maximum segment size, so that receiver sends datagram which won’t require any fragmentation. MSS field is present inside Option field in TCP header.
Since MSSreceiver < MSSsender, both parties agree for minimum MSS i.e., 500 B to avoid fragmentation of packets at both ends.

Therefore, receiver can send maximum of 14600/500 = 29 packets. This is the receiver's sending window size.

Window size (window=10000 B): receiver tells about his buffer capacity in which he has to store messages from sender.

Therefore, sender can send a maximum of 10000/500 = 20 packets. This is the sender's sending window size.

Acknoledgement Number (Ack no.=522): Since sequence number 521 is received by receiver so, it makes a request of next sequence number with Ack no.=522 which is the next packet expected by receiver since Syn flag consumes 1 sequence no.

ACK flag (ACk=1): tells that acknowledgement number field contains the next sequence expected by receiver.

Sender makes the final reply for connection establishment in following way:

Sequence number (Seq=522): since sequence number = 521 in 1st step and SYN flag consumes one sequence number hence, next sequence number will be 522.

Acknowledgement Number (Ack no.=2001): since sender is acknowledging SYN=1 packet from the receiver with sequence number 2000 so, the next sequence number expected is 2001.

ACK flag (ACK=1): tells that acknowledgement number field contains the next sequence expected by sender.



TCP Header : 

TCP operates in two phases:
Slow Start Phase: the period when TCP has no information about the current network status.
In particular, TCP does not know how much traffic the network can handle safely (i.e., withput causing congestion).
Congestion Avoidance Phase: the period when TCP knows that it is transmitting at a data rate that is very close to a rate that can cause congestion.

Wrap around time and problem on wrap around time

Wrap Around : It is nothing but using up all the sequence number present and reusing the same sequence number which has already been used that is called wrap around and from this we get a time called as wrap around time.


let band width is 1MBps,

that means in 1 sec i can have 1MB data

⇒106B  in  1 sec

⇒106 Seq number in 1 sec 

⇒1 Seq number in 1/106 sec 

∴  for 232 seq num we have 232/106 sec

⇒ WAT= 4294967296/106


we know that life time of a packet is 180 sec.

      therefor to reuse a seq num       WAT>LT

Now take Bandwidth as 1GBps


that means in 1 sec i can have 1GB data

⇒109B  in  1 sec

⇒109 Seq number in 1 sec 

⇒1 Seq number in 1/109sec 

∴  for 232 seq num we have 232/109sec

               WAT= 4294967296/109


here WAT<LT  

when first packet is still alive with some sequence no we are generating more packet with same seq no.  then at destination there are many packet which are having same seq no.( for eg.100 ) and the destination doesn't know which is 1st 100,2nd 100 its a problem.

solution to this problem is to increase the no of seq number

band width is 1MBps,

LT=180 sec

1 sec--------1 GB



1 sec----------1G seq num

180 sec ----------180*1G seq num


min seq num required to avoid Wrap around with in LT

=180*1G seq num

ceil(log2 180*109 )

42 bit

so we need 10 bit extra and these bits  can be get from option field in the header.


Fermat's Theorem

Fermat little theorem :

The public key ,private key  cryptography is based on prime number.


Fermat's little theorem states that if p is a prime number, then for any integer a, the number ap − a is an integer multiple of p. In the notation of modular arithmetic, this is expressed as. For example, if a = 2 and p = 7, then 27 = 128, and 128 − 2 = 126 = 7 × 18 is an integer multiple of 7

or we can say ,

ap-1≅ 1(modp)

or ap≅ a(modp)



P = an integer Prime number

a = an integer which is not multiple of P

Let a = 2 and P = 17

According to Fermat's little theorem 2 17 - 1 ≡ 1 mod(17) we got 65536 % 17 ≡ 1 that mean (65536-1) is an multiple of 17

Network Security and Some Impotent Terms

                                                          Network Security
a. Message Confidentiality (Privacy)
The transmitted message must make sense to only the intended receiver. To all others, the message must be garbage.
b. Message Integrity
Message integrity means that the data must arrive at the receiver exactly as they were sent.
There must be no changes during the transmission, neither accidentally nor maliciously. As more and more monetary exchanges occur over the Internet, integrity is crucial.
c. Message Authentication
In message authentication the receiver needs to be sure of the sender's identity and that an  imposter has not sent the message.
d. Message Nonrepudiation
A sender must not be able to deny sending a message that he or she, in fact, did send. For example, when a customer sends a message to transfer money from one account to another, the bank must have proof that the customer actually requested this transaction.
e. Entity Authentication
The entity or user is verified prior to access to the system resources.



Some point related to network security

a. A(n) message digest can be used to preserve the integrity of a document or a message.
b. A(n) hash function creates a message digest out of a message.
c. A conventional signature is included in the document; a digital signature is a separate entity.

d. Digital signature can provide Authentication, Nonrepudiation,Integrity 

e. If confidentiality is needed, a cryptosystem must be applied over the scheme.
f. The secret key between members needs to be created as a session key when two members contact KDC.



Digital Signature:
Although a MAC (message authentication code) use a keyed hash function which can provide message integrity and message authentication, it has a drawback. It needs a symmetric key that must be established between the sender and the receiver.
A digital signature can use a pair of asymmetric keys (a public one and a private one) which proves authenticity of sender.

A conventional signature is included in the document; it is part of the document. When we sign a document digitally, we send the signature as a separate document. The sender sends two documents: the message and the signature. The recipient receives both documents and verifies that
the signature belongs to the supposed sender. If this is proved, the message is kept; otherwise, it is rejected.


Verification Method
In conventional signature, when the recipient receives a document, she compares the signature on the document with the signature on file. If they are the same, the document is authentic. The recipient needs to have a copy of this signature on file for comparison. In digital signature, the recipient receives the message and the signature. A copy of the signature is not stored anywhere.
The recipient needs to apply a verification technique to the combination of the message and the signature to verify the authenticity.

In conventional signature, there is normally a one-to-many relationship between a signature and documents. A person, for example, has a signature that is used to sign many checks, many documents, etc. In digital signature, there is a one-to-one relationship between a signature and a message. Each message has its own signature. The signature of one message cannot be used in
another message


                  “In digital signature, the signer uses his/ her private key, applied to a signing algorithm, to sign the document. The verifier, on the other hand, uses the public key of the signer, applied to the verifying algorithm, to verify the document.” 



  1. A bridge has two layers: Physical layer and the data link layer.
  2. It can perform all the task that device with the physical layer performs additional because of the data link layer it can perform some other tasks.
  3. It is used to connect two different types of LANs.
  4. It is a store and forward device. Inside a bridge, a collision domain is very less.

Because of the data link layer, it has some other functionality:-

  1. It can see the mac address contained in the frame.
  2. It has filtering capacity so Collison is very less or negligible.
  3. It can't change the mac address.

A bridge has two types of tables:  static table and dynamic table.

Bridge uses tables to map the incoming frames to respective ports.


Transparent Bridges:

As the name suggests a transparent, all the other stations are unaware of the existence of that bridge.

A system with a transparent bridge must meet the following criteria:-

Forwarding Learning and No looping.

1. Forwarding: means bridge should forward the frame to the correct destination.


2. Learning: means automatically updating the table with the help of flooding. To make a table dynamic, we need a bridge that gradually learns from the frame movements. To do this, the bridge inspects both the destination and the
source addresses.


3. Looping:


When two LANs are connected using two bridges looping problem happens.

Bridges use a spanning tree algorithm to solve the looping problem.

let's understand this looping problem with one diagram: