Introduction to Networking Basics
Introduction to Networking Basics
NETWORKING
Rahul Babu M P
WHOAMI();
I’m Rahul Babu M P, a college student from CS Dep, who is passionate
about technology.
He is a Learning Programmer, Cyber Security Enthusiast, Self Learning
Ethical Hacker.
Speaker and Explainer.
Skilled in C, C++, Python and have basic knowledge in HTML, CSS, JS.
Skilled in Linux, Networking, Cyber Sec Tools, Social Engineering.
Tech Communicator, Trainer, Instructor.
[Link]/rahulthewhitehat
TABLE OF CONTENTS
Networking – What & Why?
Types of Computer Networks
Data Communication over a network.
A) Circuit Switching
B) Packet Switching
Datagrams
Network Layered Architecture
Internetworking Devices
NETWORK
Computer Network :
A communication system for connecting computers / hosts
Why?
Better connectivity
Better communication
Better sharing of resources
Bring people together
TYPES OF COMPUTER
NETWORKS
Local Area Network (LAN)
Connects hosts within a relatively small geographical area.
Same room/building/campus
B D F
A
C E G H
6
CIRCUIT
SWITCHING
• A dedicated communication path is established between two stations.
• The path follows a fixed sequence of intermediate links.
• A logical channel gets defined on each physical link.
Dedicated to the connection.
B D F
A
C E G H
7
CIRCUIT SWITCHING
(CONTD.)
• Three steps are required for communication:
a) Connection establishment
• Required before data transmission.
b) Data transfer
• Can proceed at maximum speed.
c) Connection termination
• Required after data transmission is over.
• For deallocation of network resources.
8
CIRCUIT SWITCHING
(CONTD.)
• Drawbacks:
• Channel capacity is dedicated during the entire duration of
communication.
Acceptable for voice communication.
Very inefficient for bursty traffic like data.
9
PACKET
SWITCHING
• Modern form of long-distance data communication.
• Network resources are not dedicated.
• A link can be shared.
10
PACKET SWITCHING
(CONTD.)
• Data are transmitted in short packets (~ Kbytes).
• A longer message is broken up into smaller
chunks.
• The chunks are called packets.
Message
• Every packet contains a header.
Relevant information for routing, etc.
H H H
PACKETS
11
PACKET SWITCHING
(CONTD.)
• Packet switching is based on store-and-forward concept.
• Each intermediate network node receives a whole packet.
• Decides the route.
• Forwards the packet along the selected route.
12
PACKET SWITCHING
(CONTD.)
• Advantages:
• Links can be shared; so link utilization is better.
• Suitable for computer-generated (bursty) traffic.
• Buffering and data rate conversion can be performed
easily.
• Some packets may be given priority over others, if
desired.
13
PACKET SWITCHING
(CONTD.)
• How are packets transmitted?
• Two alternative
approaches:
a) Virtual Circuits
b) Datagram
14
(A) VIRTUAL CIRCUIT
APPROACH
• Similar in concept to circuit switching.
• A route is established before packet transmission
starts.
• All packets follow the same path.
• The links comprising the path are not dedicated.
Different from circuit switching in this respect.
• Analogy:
• Telephone system.
15
(A) VIRTUAL CIRCUIT
APPROACH (CONTD.)
• How it works?
• Route is established a priori.
• Packet forwarded from one node to the next using store-and-forward
scheme.
• Only the virtual circuit number need to be carried by a packet.
Each intermediate node maintains a table.
Created during route establishment.
Used for packet forwarding.
• No dynamic routing decision is taken by the intermediate nodes.
16
(B) DATAGRAM
APPROACH
• Basic concept:
• No route is established beforehand.
• Each packet is transmitted as an independent
entity.
• Does not maintain any history.
• Analogy:
• Postal system.
17
DATAGRAM APPROACH
(CONTD.)
• Every intermediate node has to take routing decisions dynamically.
• Makes use of a routing table.
• Every packet must contain source and destination addresses.
• Problems:
• Packets may be delivered out of order.
• If a node crashes momentarily, all of its queued packets are lost.
• Duplicate packets may also be generated.
18
DATAGRAM APPROACH
(CONTD.)
• Advantages:
• Faster than virtual circuit for smaller number of
packets.
No route establishment and termination.
• More flexible.
• Packets between two hosts may follow different
paths.
Can handle congestion/failed link.
B D
C E F
G H
A
19
COMPARATIVE
STUDY
• Three types of delays must be considered:
a) Propagation Delay
• Time taken by a data signal to propagate from one node
to the next.
b) Transmission Time
• Time taken to send out a packet by the transmitter.
c) Processing Delay
• Time taken by a node to process a packet.
20
CIRCUIT
SWITCHING
• After initial circuit establishment, data bits sent continuously without any delay.
21
VIRTUAL CIRCUIT PACKET
SWITCHING
• The Call Request packet sent from source to destination.
• The Call Accept packet returns back.
• Packets sent sequentially in a pipelined fashion.
• Store-and-forward approach.
22
DATAGRAM PACKET
SWITCHING
• No initial delay.
• The packets are sent out independently.
• May follow different paths.
• Also follows store-and-forward
approach.
23
LAYERED NETWORK
ARCHITECTURE
• Open systems interconnection (OSI) reference model.
• Seven layer model.
• Communication functions are partitioned into a hierarchical set of
layers.
• Objective:
• Systematic approach to design.
• Changes in one layer should not require changes in other layers.
24
THE 7-LAYER OSI
MODEL
Application
Presentation
Host-to-host
Session
Transport
Network
Datalink Point-to-point
Physical
11
LAYER Application
FUNCTIONS Presentation
Session
• Physical
Transport
• Transmit raw bit stream over a physical medium.
• Data Link Network
• Reliable transfer of frames over a point-to-point link (flow control, error Datalink
control).
Physical
• Network
• Establishing, maintaining and terminating connections.
• Routes packets through point-to-point links.
26
LAYER FUNCTIONS Application
(CONTD.) Presentation
Session
• Transport
Transport
• End-to-end reliable data transfer, with error recovery and flow
control. Network
• Session Datalink
• Manages sessions.
Physical
• Presentation
• Provides data independence.
• Application
• Interface point for user applications.
27
HOW DATA
FLOWS APPLICATION
APPLICATION
PRESENTATION PRESENTATION
SESSION SESSION
TRANSPORT TRANSPORT
NETWORK NETWORK
N N
DATA LINK DATA LINK
DL DL
PHYSICAL PHYSICAL
P P
S A B D
28
INTERNETWORKING
DEVICES
• Hub
• Extends the span of a single LAN.
• Bridge / Layer-2 Switch
• Connects two or more LANs together.
• Works at data link layer level.
• Router / Layer-3 Switch
• Connects any combination of LANs and
WANs.
• Works at network layer level.
29
TYPICAL
INTERNETWORKING
STRUCTURE
30
TCP/IP STACK
Rahul Babu M P
OBJECTIVES
TCP/IP protocol stack
Data encapsulation
IP Datagrams
IP Header fields
INTRODU
CTION
• TCP/IP is the most fundamental protocol used in the Internet.
• Allows computers to communicate / share resources.
• Used as a standard.
• To bridge the gap between non-compatible platforms.
33
NETWORK LAYERING
IN TCP/IP
• In 1978, International Standards Organization (ISO) proposed the 7-layer OSI
reference model for network services and protocols.
• TCP/IP does not strictly follow the OSI model.
• It follows a simplified 4-layer model.
34
The 7-layer OSI Model The 4-layer TCP/IP
Application Model
Application Runs on top of layers 1,2,3
Presentation
Host-to-host
Transport End-to-end message
Session
transfer
Transport
Network Packet delivery across Internet
Network
Physical
35
DATA FLOW IN 4-
LAYER MODEL
Application Application
Transport Transport
A B C
36
TCP/IP
PROTOCOL SUITE
• Refers to a family of protocols.
• The protocols are built on top of connectionless technology (datagrams).
• Data sent from one node to another as a sequence of datagrams.
• Each datagram is sent independently.
• The datagrams corresponding to the same message may follow different routes.
Variable delay, arrival order at destination.
37
TCP/IP FAMILY MEMBERS
(PARTIAL LIST)
User
FTP TFTP SMTP SNMP DNS Process
38
NETWORK PROTOCOLS
• Address Resolution Protocol (ARP)
• Map IP addresses to hardware (MAC) addresses.
TCP UDP
IP
40
WHAT DOES
IP DO?
• IP transports datagrams (packets) from a source node to a destination node.
• Responsible for routing the packets.
• Breaks a packet into smaller packets, if required.
• Unreliable service.
A packet may be lost in transit.
Packets may arrive out of order.
Duplicate packets may be generated.
41
WHAT DOES
TCP DO?
• TCP provides a connection-oriented, reliable service for sending messages.
• Split a message into packets.
• Reassemble packets at destination.
• Resend packets that were lost in transit.
42
WHAT DOES
UDP DO?
• UDP provides a connectionless, unreliable service for sending datagrams (packets).
• Messages small enough to fit in a packet (e.g., DNS query).
• Simpler (and faster) than TCP.
• Never split data into multiple packets.
• Does not care about error control.
• Interface with IP:
• Each UDP packet sent to IP for delivery.
43
ADDRESSES IN
TCP/IP
User Process User Process
Port Address
TCP UDP
(16 bits)
IP Address
IP
(32 bits)
Physical Address
Datalink and Hardware Layer (e.g., Ethernet) (48 bits)
44
ENCAPSUL
ATION
• Basic concept:
• As data flows down the protocol hierarchy, headers (and trailers) get appended to it.
• As data moves up the hierarchy, headers (and trailers) get stripped off.
TFTP client TFTP server
• An example to illustrate:
• Trivial file transfer protocol (TFTP). UDP UDP
• TFTP client transfers 200 bytes of data. IP IP
• 4 bytes of TFTP header gets added.
Ethernet Ethernet
45
ENCAPSULATION
IN TFTP
Data
46
THE IP
LAYER
• IP layer provides a connectionless, unreliable delivery system for packets.
• Each packet is independent of one another.
• IP layer need not maintain any history.
• Each IP packet must contain the source and destination addresses.
• IP layer does not guarantee delivery of packets.
• IP layer encapsulation
• Receives a data chunk from the higher layer (TCP or UDP).
• Prepends a header of minimum 20 bytes.
Containing relevant information for handling routing and flow control.
47
ILLUSTRATIO
N
Data
48
FORMAT OF IP
0 4 8
DATAGRAM
15 31
VER HLEN Service type 16 Total Length
Source IP Address
Destination IP Address
Options
DATA
49
IP HEADER
FIELDS
• VER (4 bits)
• Version of the IP protocol in use (typically 4).
• HLEN (4 bits)
• Length of the header, expressed as the number of 32-bit words.
• Minimum size is 5, and maximum 15.
• Total Length (16 bits)
• Length in bytes of the datagram, including headers.
• Maximum datagram size :: 216 = 65536 bytes.
50
IP HEADER FIELDS
(CONTD.)
• Service Type (8 bits)
• Allows packet to be assigned a priority.
• Router can use this field to route packets.
• Time to Live (8 bits)
• Prevents a packet from traveling in a loop.
• Senders sets a value, that is decremented at each hop. If it reaches zero, packet is
discarded.
• Protocol (8 bits)
• Identifies the higher layer protocol being used.
51
IP HEADER FIELDS
(CONTD.)
• Source IP address (32 bits)
• Internet address of the sender.
52
IP HEADER FIELDS
(CONTD.)
• Header Checksum (16 bits)
• Covers only the IP header.
• How computed?
Header treated as a sequence of 16-bit integers.
The integers are all added using ones complement arithmetic.
Ones complement of the final sum is taken as the checksum.
• A mismatch in checksum causes the datagram to be discarded.
53
VIEWING IP
PACKETS
• We can use packet sniffers to view IP packets.
• Some popular packet sniffers:
• Wireshark
• Windump
• tcpdump
• Tshark
• SolarWinds
• …. and many more
54
WIRESHA
RK …
55
IPV6 – AN
INTRO
Rahul babu m p
OBJECTIVES
Features of IPv6
Address translation
INTRODUCTION
3
PROBLEMS WITH IPV4
4
MAIN FEATURES OF IPV6
•Something is common with IPv4:
•IPv6 is connectionless – each datagram contains destination address and is
routed independently.
•Header contains the maximum number of hops a datagram can make before
being discarded.
•Some of the other general characteristics are also retained.
IPV6
•Address size: 128‐bit addresses are used.
2128 total addresses.
6 x 1023 unique addresses per square meter of the earth’s surface.
•Header format:
IPv6 uses a series of fixed‐length headers to handle optional
information.
A datagram consists of a base header followed by zero or more
extension headers.
6
IPV6
•Support for real‐time traffic:
Allows a pair of stations to establish a high quality path between them.
All datagrams flow through this path.
•Increased flexibility in addressing:
Includes the concept of an anycast address, where a packet is delivered
to one of a set of nodes.
Provides for dynamic assignment of IP addresses.
7
IPV6 DATAGRAM FORMAT
•An IP datagram begins with a base header, followed by zero or more extension headers,
followed by data (transport‐layer PDU).
•40 bytes base header
9
THE FIELDS
•Version (4 bits): contains the value 6.
•Priority (8 bits): specifies routing priority class.
•Flow Label (20 bits): used with applications that require performance guarantee.
•Payload Length (16 bits): total length of the extension headers and the transport‐level PDU.
•Next Header (8 bits): identifies the type of information that immediately follows the current
header (IP extension, TCP or UDP).
•Hop Limit: decremented by 1 at each hop; discarded when it reaches 0.
•Source/destination addresses: 16 octets (128 bits) each.
11
10
IPV6 EXTENSION HEADERS
•Routing Header
•Provides source routing.
•Hop‐by‐hop Options Header
•Defines special options that are processed at each hop.
•Fragment Header
•For fragmentation and reassembly.
•Authentication Header
•For packet integrity & authentication.
All Extension headers are chained in a linked list.
•Through Next Hdr field.
13
A POINT ABOUT FRAGMENTATION
14
IPV6 ADDRESSING
•Addresses do not have defined classes.
•A prefix length associated with each address (flexibility).
•Three types of addresses:
•Unicast: corresponds to a single computer.
•Multicast: Refers to a set of computers, possibly at different locations. Packet delivered to
every member of the set.
•Anycast: Refers to a set of computers with the same address prefix. Packet delivered to exactly
one of the computers in the set.
Required to support replication of services.
15
COLON HEXADECIMAL NOTATION
16
AGGREGATE GLOBAL UNICAST
ADDRESS
•TLA: top‐level aggregation
•NLA: next‐level aggregation
•SLA: site‐level aggregation
•Interface Id: typically based on hardware MAC address
• Allow a host that supports both IPv4 and IPv6 to communicate with a host that supports
only IPv4.
• IPv6 address is based on IPv4 address.
• 80 0’s, followed by 16 1’s, followed by a 32‐bit IPv4 address.
18
IPV4 COMPATIBLE IPV6 ADDRESSES
•Allows a host supporting IPv6 to talk IPv6 even if the local routers do not talk IPv6.
•Tell endpoint software to create a tunnel by encapsulating the IPv6 packet in an IPv4 packet.
•80 0’s, followed by 16 0’s, followed by a 32‐bit IP address.
19
TUNNELLING
•Done automatically by the OS kernel when IPv4‐compatible IPv6 addresses are used.
•Encapsulates IPv6 packets in IPv4 packets.
•Use a IPv4 network for packet delivery.
TUNNELLING
IPv6 Datagram
TRANSITION FROM IPV4 TO IPV6
21
IP ADDRESSING
& ROUTING
Rahul Babu M P
OBJECTIVES
IP Packets Fragmentation
Transparent/Non Transparent Fragmentation
IP Addressing Basics
FRAGMENTATION
•Why needed?
•The IP layer injects a packet into the datalink layer.
•Not responsible for the reliable transport of these packets.
•Each layer imposes some maximum size of packets, due to various
reasons.
•Called Maximum Transfer Unit (MTU).
•Suppose a large packet travels through a network whose MTU is too
small.
•Fragmentation (and also reassembly) is required.
•Each fragment is transmitted as a separate IP packet.
•Fragmentation is typically done by routers.
•Fragments reassembled later: transparent or non‐transparent
CONNECTION OF
NETWORKS
R N2 R
R
N1 R N3
H
H
R R
N4
TRANSPARENT
FRAGMENTATION
•Fragmentation is transparent to subsequent networks, through
which the packet pass.
•Basic concept:
•An oversized packet reaches a router, which breaks it up into
fragments.
•All fragments sent to the same exit router (say, RE).
•RE reassembles the fragments before forwarding to the next
network.
•Why called transparent?
•Subsequent networks are not even aware that fragmentation had
occurred.
•A packet may get fragmented several times.
TRANSPARENT
FRAGMENTATION (CONTD.)
•Drawbacks:
•All packets must be routed via the same exit router.
•Exit router must know when all the pieces have been received.
•Either a count field or end‐of‐packet field must be stored in each
packet.
•Lot of overhead.
•A large packet may be fragmented and reassembled repeatedly.
NON‐TRANSPARENT FRAGMENTATION
8
NON‐TRANSPARENT
FRAGMENTATION (CONTD.)
•Advantage:
•Multiple exit routers may be used.
•Higher throughput.
•Drawback:
•When a large packet is fragmented, overhead increases.
•Each fragment must have a header (minimum 20 bytes).
•IP protocol uses non‐transparent fragmentation.
FORMAT OF IP
0 4 8
DATAGRAM
15 31
VER HLEN Service type 16 Total Length
Source IP Address
Destination IP Address
Options
DATA
84
WHAT DOES IP DO?
•To allow fragment reassembly at the final destination, IP uses
the following fields in the header:
•Identification (16 bits)
A datagram id set by the source.
•Fragment offset (13 bits)
Indicates where in the original datagram this fragment
belongs to.
Specified in multiple of 8 bytes.
•Flags (3 bits) ‐‐‐ two flags are defined
D bit :: don’t fragment; prevents fragmentation from
taking place.
M bit :: more fragment; specifies if this fragment is the
last one in the original packet or not.
EXAMPLE :: IP
FRAGMENTATION
N1 N2
1000 Bytes of
data
MTU of 600 MTU of 400
Bytes of data Bytes of data
BASIC IP ADDRESSING
•Each host connected to the Internet is identified by a unique IP address.
•An IP address is a 32‐bit quantity.
•Expressed as a dotted‐decimal notation W.X.Y.Z, where dots are
used to separate each of the four octets of the address.
•Consists of two logical parts:
a)A network number
b)A host number
•This partition defines the IP address classes.
HIERARCHICAL ADDRESSING
•A computer on the Internet is addressed using a two‐tuple:
number
is looked at.
SPECIAL‐PURPOSE IP
ADDRESSES
Reserved for private use
•10.x.x.x (Class A)
•172.16.x.x – 172.31.x.x (Class B)
•192.168.x.x (Class C)
•Loopback/local address
•[Link] – [Link]
•Default network
•[Link]
•Limited broadcast => [Link]
12
SOME CONVENTIONS
•Within a particular network (Class A, B or C), the first and last
addresses serve special functions.
•The first address represents the network number.
For example, [Link]
•The last address represents the directed broadcast address of
the network.
For example, [Link]
CLASSES OF IP
Rahul Babu M P
IP ADDRESS CLASSES
•There are five defined IP address classes.
•Class A UNICAST
•Class B UNICAST
•Class C UNICAST
•Class D MULTICAST
•Class E RESERVED
•Identified by the first few bits in the IP address.
•There also exists some special‐purpose IP addresses.
•The class‐based addressing is also known as the classful model.
6
CLASS A ADDRESS
Class A Address
•Network bits : 7
•Number of networks = 27 – 1 = 127
•Host bits: 24
•Number of hosts = 224 – 2 = 16,777,214
•Address range:
•[Link] to [Link]
CLASS B ADDRESS
Class B Address
•Network bits : 14
•Number of networks = 214 – 1 = 16,383
•Host bits: 16
•Number of hosts = 216 – 2 = 65,534
•Address range:
•[Link] to [Link]
CLASS C ADDRESS
Class C Address
110 NETWORK
Network NETWORK NETWORK HOST
•Network bits : 21
•Number of networks = 221 – 1 = 2,097,151
•Host bits: 8
•Number of hosts = 28 – 2 = 254
•Address range:
•[Link] to [Link]
CLASS D ADDRESS
Class D Address
1110 MULTICAST ADDRESS
Address range:
•[Link] to [Link]
10
IP SUBNETTING
Rahul Babu M P
OBJECTIVES
3
NATURAL MASKS
•Network mask [Link] is applied to a class A network [Link].
•In binary, the mask is a series of contiguous 1’s followed by a series of contiguous 0’s.
11111111 00000000 0000000000000000
NATURAL MASKS (CONTD.)
•Provide a mechanism to split the IP address [Link] into
•a network portion of 10, and
•a host portion of 20.
Decimal
IP address: [Link]
Mask: [Link]
Binary
00001010 00000000 00000000 00010100
11111111 00000000 00000000 00000000
Network Host
CREATING SUBNETS USING MASKS
•Masks are very flexible.
•Using masks, networks can be divided into smaller subnets.
•By extending the network portion of the address into the host portion.
•Advantage:
•We can create a large number of subnets from one network.
•Can have less number of hosts per network.
EXAMPLE: SUBNETS
TCP UDP
IP
11
5
ROLE OF TCP
•Provides a connection‐oriented, reliable, full‐duplex, byte‐stream service.
•Underlying IP layer is unreliable and provides connectionless delivery service.
•TCP provides end‐to‐end reliability using
Checksum
Positive acknowledgements
Timeouts
End‐to‐end flow control.
•TCP also handles
•Establishment and termination of connections between processes.
•Sequencing of data that might reach the destination in any arbitrary order.
5
ROLE OF UDP
•UDP provides a connectionless and unreliable datagram service.
•Very similar to IP in this respect.
•Provides two features that are not there in IP:
A checksum to verify the integrity of the UDP packet.
Port numbers to identify the processes at the two ends.
PORT NUMBERS
•Multiple user processes on a machine may use TCP or UDP at the same time.
•There is need for a mechanism to uniquely identify the data packets associated with each
process.
PORT NUMBERS (CONTD.)
•How this is done?
•Both TCP and UDP uses 16‐bit integer port numbers.
•Different applications are identified by different port numbers.
•Port numbers are stored in the headers of TCP or UDP packets.
ADDRESSES IN
TCP/IP
User Process User Process
Port Address
TCP UDP
(16 bits)
IP Address
IP
(32 bits)
Physical Address
Datalink and Hardware Layer (e.g., Ethernet) (48 bits)
12
0
PORT NUMBERS (CONTD.)
•Client‐server scenario
•By knowing the 32‐bit IP address of the server host, a client host can connect to the server.
•To identify a particular process running on the server host, the client must also know the
corresponding port number.
•Well‐known port numbers
•Predefined, and publicly known.
•FTP uses port 21, SMTP uses port 25.
11
PORT NUMBERS (CONTD.)
•Well‐known port numbers are stored in a particular file on the host machine.
•Unix:: /etc/services
•Windows:: C:\WINDOWS\system32\drivers\etc\services
•Each line has the format:
<service name> <port number>/<protocol> [aliases...] [#<comment>]
•Few lines of the file are shown next.
12
EPHEMERAL PORT NUMBERS
•A typical scenario:
•A client process sends a message to a server process located on some host at port 1534.
•How will the server know where to respond?
Client process requests an unused port number from the TCP/UDP module on its local host.
These are temporary port numbers, called ephemeral port numbers.
Send along with the TCP or UDP header.
•How are the port numbers assigned?
•Port numbers from 1 to 1023 are reserved for well‐known ports.
Has been extended to 4095.
•Numbers beyond this and up to 65535 used as ephemeral port numbers.
14
CONNECTION ESTABLISHMENT
•A hierarchical addressing scheme is used to define a connection path between two hosts.
•IP address
Identifies the communicating hosts.
•Protocol identifier
Identifies the transport later protocol being used (TCP, UDP or anything else).
•Port number
Identifies the communicating processes in the two hosts.
15
ASSOCIATION
•A set of five values that describe a unique process‐to‐process connection is called an
association.
•The protocol (TCP or UDP).
•Local host IP address (32‐bit value).
•Local port number (16‐bit value).
•Remote host IP address (32‐bit value).
•Remote port number (16‐bit value).
•Example of an association:
{TCP, [Link], 1785, [Link],21}
16
TRANSMISSION CONTROL
PROTOCOL (TCP)
•TCP supports host‐to‐host communication with the following features:
•Process‐to‐process communication
•Stream delivery service
•Full‐duplex communication
•Multiplexing and de‐multiplexing
•Connection‐oriented reliable service
TCP HEADER FIELDS
•Source port (16 bits)
•Identifies the process at the local end.
•Destination port (16 bits)
•Identifies the process at the remote end.
•Sequence number (32 bits)
•Used for reliable delivery of message.
•Each byte of message is assigned a 32‐bit number that is incremented sequentially.
•The field holds the number of the first byte in that TCP segment.
•HLEN (4 bits)
•Specifies the header length in number of 32‐bit words.
TCP HEADER FIELDS (CONTD.)
• Acknowledgement Number (32 bits)
• Used by remote host to acknowledge receipt of data.
• Contains the number of the next byte expected to be received.
• HLEN (4 bits)
• Specifies the header length in number of 32‐bit words.
• Flags (6 bits)
• There are six flags.
URG is set to 1 if the urgent pointer is in use.
A connection request is sent by making SYN=1 and ACK=0.
A connection is confirmed by sending SYN=1 and ACK=1.
When the sender has no more data, FIN=1 is sent to release the connection.
RST bit is used to reset a connection. It is also used to reject a connection attempt.
PSH bit indicates the push function. Used to indicate end of message.
TCP HEADER FIELDS (CONTD.)
•Checksum (16 bits)
•Applies to the entire segment and a pseudo‐header.
•The pseudo‐header contains the following IP header fields:
Source IP address, destination IP address, protocol, segment length.
TCP protects itself from mis delivery by IP (delivered to wrong host).
•Same algorithm as used in IP.
TCP CONNECTION
ESTABLISHMENT
UDP HEADER FIELDS
•Source port (16 bits)
•Identifies the process at the local end.
•Destination port (16 bits)
•Identifies the process at the remote end.
•Message length (16 bits)
•Specifies the size of the datagram in bytes (UDP header plus data).
•Checksum (16 bits)
•Computed in the same way as TCP.
•This is optional; set to zero if not used.
17
ROUTING
PROTOCOLS
Rahul Babu M P
OBJECTIVES
Packet delivery options
Routing Methods
4
PACKET DELIVERY OPTIONS
1. Direct Delivery
•Host‐to‐host
•Router‐to‐host
HOST N1 R1 N2 R2
HOST N3
ROUTING METHODS
7
A) NEXT‐HOP ROUTING
•Routing tables based on next hop.
H1 R1 R2 H2
R1 H2
N1 N2
H1
C) HOST‐SPECIFIC ROUTING
•Can specify the address of a host.
N1 H2
H1 R2
N3
10
D) DEFAULT ROUTING
•Follow a default path if no match found.
H1
R1
N2
N1
R2
Dest Next Hop
N2 R1
Default R2
TYPES OF ROUTING TABLE
1. Static
•Contains information inserted manually.
•Does not change with time.
2. Dynamic
•Updated periodically depending on network condition.
•Uses protocols like RIP, OSPF, BGP, etc.
12
TYPICAL FIELDS IN A ROUTING TABLE
•Subnet mask
•Destination IP address
•Next hop address
•Flags
U : router is up and running
G : destination is in another network H : host‐specific address
D : added by redirection
M : modified by redirection
•Interface
13
EXAMPLE (ROUTING TABLE FOR R1)
TABLE!!
Mask Dest NextHop Interface
[Link] [Link] ‐‐ M0
[Link] [Link] ‐‐ M1
M0
R1 [Link] R2
M1
[Link]
14
HOW TO VIEW THE ROUTING TABLE?
b) Exterior
Border Gateway Protocol (BGP)
4
AUTONOMOUS SYSTEMS (AS)
•What is an AS?
•A set of routers and networks managed by a single organization.
•The routers within the AS exchange information using a common routing protocol.
•The AS graph is connected (in the absence of failure).
•Every autonomous system is assigned a unique AS number.
•Routing protocols within an AS and across different AS’s can be different.
•Interior versus Exterior.
5
Autonomous Systems
R N
R N
N AS‐ R
N AS‐ R
2
1 N
N R
R
R N
N AS‐ R
3
N
R
MORE
7
ROUTING INFORMATION PROTOCOL
(RIP)
•It is an interior routing protocol.
•Routers within an autonomous system exchange messages.
•Distance vector routing using hop count.
•Table entries updated using values received from neighbors.
•Maintain timers to detect failed links.
•Used in first generation ARPANET.
8
PROBLEMS WITH RIP
12
OSPF HEADER FORMAT
31
Version Type Message Length
Source Address
Area Id
Checksum
Authentication Type
Authentication
13
ROUTING DATA
Authentication
OSPF PACKETS
Packet types :
1. Hello (check if neighbor is up)
2. Database Description (synchronize database at beginning)
3. Link State Request (request specific LSA)
4. Link State Update (LSAs flooded)
5. Link State Acknowledgement (flooded LSAs are explicitly ack‐ed – reliable flooding)
• Authentication type:
• Cleartext
• Encrypted (MD5 Hash, others possible)
BGP
What is BGP?
4
BGP OVERVIEW
•Currently in version 4.
•Inter‐AS routing protocol for exchanging network reachability information among
BGP routers.
•Uses TCP on port number 179 to send routing messages.
•It is a distance vector protocol.
•Unlike RIP, BGP contain complete routes.
BGP ILLUSTRATION
R N
R
BGP N R
N AS‐
2
R N
N AS‐ R
1
N
R BGP
R N
BGP N R
AS‐
3
N
R
MESSAGE TYPES IN BGP
7
THE BASIC IDEA
9
FUNCTIONAL PROCEDURES IN BGP
a)Neighbor Acquisition
•Two routers agree to be neighbors by exchanging messages.
b)Neighbor Reachability
•Check if the neighbor is still alive, and is maintaining the relationship.
c)Network Reachability
•Each router maintains a list of the networks that it can reach, and the preferred
routes.
INFO
•All modern‐day routers support BGP.
•The routers that are managed by ISPs actually run BGP.
•Organizational networks in many cases do not run BGP.
•Rely on the ISP’s routers to route packets to the outside world.
•Default route will be to the ISP router.
EXERCISES
Rahul babu m p
EXAMPLE 1
For the following routing table of a router, on which interface will the router forward packets
addressed to the destinations [Link] and [Link] ?
Destination Subnet Mask Interface
[Link] [Link] a
Rext
[Link] [Link] b
[Link] [Link] c
5
[Link] [Link] d
Default [Link] e
•How will packets with the following destination IP addresses be forwarded by the
router R?
a) [Link]
b) [Link]
c) [Link]
d) 215.1.2 200