0% found this document useful (0 votes)
14 views

TCP Header & UDP Header

Uploaded by

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

TCP Header & UDP Header

Uploaded by

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

 Routed Protocol

o Those protocols which help for encapsulation and Decapsulation.


 TCP and UDP
 Routing Protocol
o Those Protocols which help to find best direction

TCP Header
Transmission Control Protocol
Its protocol number is 6
Reliable and connection oriented

TCP :- 3 way handshake


i) Peer is available or not
ii) Compare mss and then start sending segments
iii) If peer is busy or not available then 3 way handshake will not
done.
Reliability
o Using sequence number and acknowledgement.
What are the port numbers at transport layer?
o These port numbers are used to define an application layer services.
o It is also known as Service-point address
o 16 bits value = 2^16 = 65536 ( 0 – 65535 )
1) Well know ports :- Those port numbers are used for specific layer 7 protocol or services
a) Range ( 1 – 1023 )
b) Http (80) , HTTPS (443 ) , FTP (20, 21) , dhcp ( 67 , 68 ) , dns (53) , tftp (69) , snmp ( 161, 162) ,
smtp (25) , telnet (23) , ssh (22)
2) Random port numbers
o Those are used by end user.
o It is also known as registered port number / ephemeral source ports.
o Range = 1024 – 49151
o HSRP = 1985 , GLBP = 3222 , RDP = 3389 etc
3) Random
a) These are used for private use case.
b) It is also known as unregistered port number / dynamic port number.
c) Range 49152 – 65535

Source Port  Source field is a 16 bit filed. It is identifies the port of the sending Application
ports. Port Number from services request sent.

Destination port  Destination Port is a 16 bit filed. It is identified the port of the receiving
application. Port number which is used to identify service requested by user.

Sequence Number It is not only used to rearrange the data in correct order but also carry
the size of data inside the segments. It is also used for retransmission if any segment is lost.

“Seq num is a 32 bit field”

R1 R2

10.0.0.1 10.0.0.2

-------- SYN Seq = 0(MSS = 1460, WIN= 4128, LEN=0)

SYN (Seq=0) +ACK (Seq=1) (MSS = 1460, WIN= 4128, LEN=0) ---------
---------ACK (Seq =1) (WIN= 4128, LEN=0)

----------------------------------------------Telnet data = 12 bytes (LEN)

Last Seq=1

Next Seq num= 12+1 = 13

ACK = (Seq) 1

Telnet data = 12 bytes (LEN) -------------------

Last Seq =1

Next Seq= 13

Ack = 13 (data + last seq number)

----------------------------------------Telnet data = 3 bytes (LEN)

Last seq = 13

Next Seq num = 13+3 = 16

Ack= 13 (Last data received by


R1)

----------------------------------------Telnet data = 3 bytes (LEN)

Last seq = 16

Next Seq num = 16+3 = 19

Ack= 13 (Last data received by


R1)

Telnet data = 42 bytes (LEN) -------------------

Last Seq =13


Next Seq= 42+13 = 55

Ack = 19 (data + last seq number)

Acknowledgement Number 
a) Acknowledgement num is 32 bit field.
b) It tells the sender to send the next data with this sequence number.
c) It is always sequence number of the last received data bytes increment by 1.

Header length / DATA OFFSET  SIZE OF HEADER


Bit= 4* [value]
1) Header length is a 4 bit field.
2) It contains the length of tcp header.
3) It helps in knowing from where the actual data begins.

Minimum & Maximum header length


 The length of TCP header always lies in the Range [ 20 bytes, 60 bytes]
 The initials 5th rows of the tcp header are always used.
 So, minimum length of tcp header= 5*4 = 20 bytes.
 The Size of the 6th row representing the options field.
 So, minimum length of tcp header = 6*4=24 bytes
 The size of options fields can go up to 40 bytes.
 So, maximum length of tcp header = 20 bytes+ 40 bytes= 60 bytes

Concepts of scaling factor


o Header Length is a 4bit field
o So, the range of hexadecimal value that can be represent in [5 , 15]
o But, the range of header length is [20 bytes,60 bytes]
o So, to represent the header length, we use a scaling factor of 4 In general

Header length = Header length field value x 4


a) If header length field contains decimal value 5 ( represent as 0101), then
Header length = 5x4 = 20 bytes

NOTES it is important to note.


a) Header length and header length field value are two different things.
b) The range of header length field value is always [ 5,15]
c) The range of header length is always [ 20,60]

Reserved Bits

a) The 6 bits are reserved.


b) These bits are not used.

Flags / Control bits


o It defines which type of packet is this in TCP header.
o Nonce, CWR (Congestion Window Reduced), ECE (Explicit Congestion Notification -Echo)
are also reserved.

a) Urgent [URG bit] 


i) If bit is 1 data will not wait into buffer and will get proceed immediately.
ii) If bit is 0 data is not urgent

b) ACK bit
i) If bit is 1the packet is an acknowledgement packet.
ii) If bit is 0the packet is not acknowledge packet.

c) Pushto make the data stream speedily.


i) 1to speed up the data stream.
ii) 0not need to speed up data stream.

d) RST Bit
 RST bit is used to reset the TCP Connection
 Denying a connection
o When Destination port for which service is required is not
available.
 Aborting a connection
o Due to abnormal situation
 Terminating a connection
o Idle
 When RST bit is set to 1.
 For these cases flag will be 1(set)
 Otherwise flag will be ZERO

e) FIN BIT FIN bit is used to terminate the TCP Connection


 Session has been logout

f) SYN Segment in which you want to share connection parameters


g) CWR (Congestion window reduce )  This flag is used when receiver is getting a lot of
segments and want to avoid congestion then send packet with this bit to make tcp slow
start.
Window size 
o 16 bits value
o It’s used to exchange how much data can receive by a client or Server.
o It represents the number of bytes the sender is willing to transmit before receiving an
acknowledgement.
 Windowing
 Window scaling ( option)
o This feature is used to extend window size.
o Window size = 16 bits = 0-65535
o 14 bits will be use to scale window from option field
o R2(config)#ip tcp window-size < window size>
Flow control
o Data transfer rate is negotiated to prevent congestion.
Checksum 
o 16 bits value , that is used to check data integrity
o This is calculated over data and header.
o One algorithm will run on the Header, and will come with a checksum value in hex
format when their again verified by receiver.
o The receiver will again run algorithm on the header received.
o IF value of the receiver and sender matches then the data will be accepted otherwise
will be dropped.
o Error-control
 It ensures that data delivered to the destination should be free.
 To recover data sender will re transmit same data to the receiver.

Urgent Pointerurgent flag = 1

 When URG flag is set (1). It indicate that URGENT data has to send immediately to wire from
sender side and on receiving and the urgent data has to be sent immediately to application.
 Urgent Pointer in TCP segment is used to indicate that amount of urgent data present in TCP
segment.

Multiplexing
o Many to One
De-multiplexing
o One too many
Option
o 0 to 40 bytes
o NOP = No operation
o EOP = End of operation
o MSS = Maximum segment Size
 Size in option field is 4 bytes
 Kind ( 1 bytes) = which tcp option is being used
 Length ( 1 bytes) = length of this field
 MSS ( 2 bytes)
 Maximum amount of data that can be encapsulated with TCP header.
 Maximum size of segment = 1460 bytes ( data)
 R2(config-if)#ip tcp adjust-mss
o <500-1460> Maximum segment size in bytes
 R2(config)#ip tcp mss
o <68-10000> MSS
 If any device will not negotiate mss each other they will use default mss 536
bytes.
o Window scaling
 3 bytes
o Time stamp
 10 bytes
o S ACK
 2 bytes
o S Ack permitted

UDP

 Its connectionless and not reliable


 Bcoz there is no 3 way handshake and no sequence and ack number
 According to the requirement it depend on protocols types which need reliability use tcp and if
any application don’t need reliability then use UDP

TCP UDP
Reliable Protocol Unreliable Protocol
Connection Oriented Connection less Protocol
Flow control is supported No flow control is supported
Only unicast transmission is supported It support multicast , unicast and broadcast
Http , HTTPS , telnet , SSH , FTP Tftp , dns , dhcp

You might also like