Computer Networking Network Layer Notes
Computer Networking Network Layer Notes
The site must have only one single connection to the global internet.
ADDRESS TRANSLATION
The source address of all the outgoing packets is replaced by the global NAT address
by the NAT router
All incoming packets also pass through the NAT router which replaces the
destination address in the packet with the appropriate private address.
NAT Translation Table
Has 2 columns the private address and the external address (destination address of
the packet).
When the router translates the source address of the outgoing packet, it also makes
note of the destination address-where the packet is going. When the response comes
back from the destination, the router uses the source address of the packet (as the
external address) to find the private address of the packet.
In this strategy communication must always be initiated by the private network.
NAT router has multiple global address so that multiple internal private hosts can
communicate at the same time.
There are some drawbacks to this system
No more than the maximum number of external(global) addresses in the NAT can
make connections to the same destination.
Also no private network host can access 2 external server programs at once.
IPv6 ADDRESSES
Address depletion is still a problem despite many of the measures taken to solve it such as
classless addressing, Dynamic Host configuration (DHCP),NAT etc.
IPv4 had other problems such as lack of accommodation of real time audio and video transmission
encryption and authentication of data for some applications.
To make it more readable IPv6 specifies hexadecimal colon notation. 128 bits are divided into 8
sections each 2 bytes in length. 2 bytes in hex requires 4 hex digits
Re-expansion of the abbreviated address is simple just replace the empty places with 0s.
ADDRESS SPACE
o much larger address space. 2128 addresses are available.
o Packet sent to a unicast address must be sent to the specific computer itself.
Geographically based
Provider-based
Multicast addresses
o Defines a group of host instead of just one
o Packet sent to multicast address must be sent to each member of that group.
o Multicast addresses can be either permanent or transient (defined by the flag field)
Unspecified – when host does not know its own address an send an enquiry to find it.
Loopback – used by a host to test itself without going into the network
Compatible – used during transition from IPv4 to IPv6
Mapped – also used during transition but from IPv6 to IPv4
Local address
o These addresses are used when an organization wants to use IPv6 without being connected to the
global internet.
o They provide addressing for private networks.
INTERNET PROTOCOL
Switching at the network layer in the internet uses the datagram approach to packet switching.
packet switching :
a mode of data transmission in which a message is broken into a number of parts which are sent
over whatever route is optimum, and reassembled at the destination.
Connection at the network layer in the internet is CONNECTIONLESS.
IPv4
delivery mechanism used by the TCP/IP protocol
o Unreliable and connectionless datagram protocol.
o It provides no error control or flow control (except error detection on the header).
DATAGRAM
o A datagram is a variable length packet consisting of 2 parts : header and data.
o HEADER
20 – 60 bytes in length
Contains information essential to routing and delivery
Customary in TCP/IP to show the header in 4-byte sections
o VERSION (VER)
This 4 bit field defines the version of this IP protocol ( 4 in case of IPv4).
If processing machine is using some other version of IP then the datagram is
discarded rather than interpreting it incorrectly.
o HEADER LENGTH (HLEN)
This 4 bit field defines the total length of the datagram header in 4 byte words
Needed because the length of the header is variable
When there is no options the header length is 20
When the option field is at its max header length is 60.
o SERVICES
IETF changed the interpretation and name of this 8 bit field
Previously called service type
Now it’s called differentiated services.
SERVICE TYPE
o One and only one bit can have a value of 1 in each datagram.
First 6 bits make up the codepoint subfield and the last 2 bits are not used
Codepoint subfield can be used in 2 different ways
o when 3 right most bits are 0 the 3 leftmost are interpreted as
precedence bits in the service type interpretation(compatible with the
old interpretation).
o When they are not 0s all 6 bits define 64 services based on the priority
assignment by the internet.
o The first category contains 32 service types
o TOTAL LENGTH
N-bit field that defines the total length (IPv4 header plus data) of the IPv4 datagram
in bytes.
To find length of data coming from the upper layer subtract the header length from
the total length.
Header length can be found by multiplying the value in HLEN field by 4
8 bit field
Helps define higher level protocols that uses services of the IPv4 layer.
Since IPv4 carries data from several other protocols the value of this field helps the
receiving network layer know which protocol the data belongs to.
o CHECKSUM
discussed later in the document.
o SOURCE ADDRESS
32 bit field
Defines IPv4 address of the source
Remains unchanged throughout the travel of the packet.
o DESTINATION ADDRESS
32 bit field.
Defines IPv4 address of the destination.
Remains unchanged throughout the travel of the packet.
FRAGMENTATION
o Max length of IPv4 datagram is 65,535 bytes but this amount of data cannot be transmitted
through the physical layers this they need to be fragmented.
o The transport later will segment the data into a size that can be accommodated by IPv4 and
the data link layer in use.
o Fragmented datagrams has their own headers with most of the fields repeated but with
some changed.
o A fragmented datagram can be further fragmented based on the needs of the MTU
(maximum transfer unit).
o The host router that fragments the datagram must change 3 fields
Flags , Fragmentation Offset , and total Length.
o Rest of the fields must be copied.
Identification
16 bit field that identifies the datagram
When a datagram is fragmented the value of this field is copied in all the
fragments
This later helps in reassembling the datagram.
Flags
3 bit field
First bit is reserved, second bit is called DoNotFragment bit. If its value is 1
the machine must not fragment the datagram. If 0 datagram can be
fragmented if necessary.
3rd bit is called the more fragment bit
if its value is 1 then its not the last fragment there are more after this one.
if its 0 then it’s the last fragment of the datagram.
Fragmentation Offset
13 bit field
Shows relative position of the fragment with respect to the whole datagram.
CHECKSUM
o Checksum in IPv4 covers only the header
o The data encapsulated already has a checksum from the previous layers
o Header of the packet changes with each visited router but data does not so checksum
includes only the part that changed. Which decreases the checksum calculation time.
OPTIONS
o The variable part of the IPv4 header.
o Not required for the datagram but can be used for network testing and debugging.
o Taxonomy of
options
No options
one byte option used a filler between options.
End of Options
1 byte option used for padding at the end of the option field. However can only be
used as the last option.
Record route
used to record the internet routers that handle the datagram
can list up to 9 router addresses. Used for debugging and management purposes.
Strict Source route
used by the source to pre-determine a route for the datagram as it travels through
the internet
Loose Source route
same as a strict source route but less rigid. Each router in the list must be visited but
datagram can visit other routers as well.
Timestamp
used to record the time of the datagram processing by the router.
expressed in ms from midnight.
IPv6
o IPv6 or IPng (internet protocol new generation) was developed to address the issues and
drawbacks of IPv4.
o Advantages of IPv6 over IPv4
DUAL STACK
o Before migrating completely to v6, have a dual stack of protocols. Run both versions
simultaneously.
o To determine which to use source queries the DNS if DNS returns v4 address source sends a v4
packet and v6 if so.
TUNNELING
o When 2 hosts using v6 has to communicate through a region that uses v4.
HEADER TRANSLATION
o For communication between a host running a v6 and a host running v4
o Because the sender does not know the physical address of the receiver the query is
broadcasted on the network.
o Intended recipient recognizes its IP and sends back a ARP response packet. The packet is
unicast directly to the inquirer using the physical address received in the query packet.
o Cache Memory
ARP is useful if ARP reply is cached because system normally sends many packets to
the same destination.
System that receives an ARP reply keeps the info for 20-30 mins.
Before sending an ARP the system checks this cache to see if it can find a mapping.
o Packet format
Hardware type
16 bit. Defines the type of network the ARP is running on. Each LAN is assigned an
integer given on its type eg ethernet is 1
Protocol type
16 bit. Defining the protocol. Eg for IPv4 its ( 0800 )16.
Hardware length
8 bit. Defining the length of the physical address in bytes.
Protocol length
8 bit. Defining the length of the logical address in the bytes.
Operation
16 bit field defining the type of packet
ARP request (1)
ARP reply (2)
Sender hardware address
variable length field defining the physical address of the sender.
Sender protocol address
variable length field defining the logical address of the sender.
Target hardware address
variable length field defining the physical address of the target.
Target protocol address
variable length field defining the physical address of the Target
o Encapsulation
A diskless station is booted station can find its physical address by checking the
interface but it does not know the IP address.
Org doesn’t hv enough IP addresses so it has to assign them on lease. The station can
send its physical address and ask for an IP.
can provide both dynamic and static address allocation that can be manual or
automatic.
Static address allocation
In this capacity DHCP acts as BOOTP.
Its backward compatible with BOOTP therefore a BOOTP client can request a
static address from a DHCP server.
Has a database that statically binds physical addresses to IP address.
Error Reporting
o One of the main responsibilities of ICMP
o Error messages are always sent to the original source because the only information
available is source and destination address
o Important points about ICMP error messages
o Destination Unreachable
If router or host discovers an ambiguity or missing value in any field of the datagram
it discards the datagram and sends a parameter-problem message back to the
source
o Redirection
To update routing table of the host redirection msg is sent to the host.
Query Messages
o ICMP can diagnose some network problems.
o This is accomplished through the query messages, a group of four different pairs of
messages.
Use to determine round trip time needed for an IP datagram to travel between them.
Can also be used to sync clocks in 2 machines.
o Address mask request and reply
o Checksum
o IGMP protocols gives the multicast routers information about the membership status of
hosts connected to the network.
IGMP Message types
Message format
o Maximum response time: 8 bit defines the amount of time in which a query must be
answered value is in 10th s of a second
o Group address : value is 0 for general query message
defines the group id in the special query, the membership report and the leave report
messages.
IGMP Operation
o Joining a group
o Leaving a group
o Monitoring membership
o Delayed response
o Query Router
Encapsulation
o IGMP message is encapsulated in the IP datagram which is itself encapsulated in a frame
Netstat Utility
o Can be used to find the multicast addresses supported by and interface.
ICMPv6
o The ARP and IGMP protocols are combined in ICMPv6. The RARP protocol is dropped from
the suite as it was rarely used. And BOOTP has the same functionality.
o Messages are also divided into 2 categories however each category has more types now.
o Error reporting
Destination unreachable
Packet too big
if router receives a datagram that is larger than MTU first the router discards the
message and then sends a packet-to-big message.
Time exceeded
Parameter problem
Redirection
o Query
DELIVERY
Network layer supervises the handling of the packets by the underlying physical networks.
this is defined as delivery of a packet.
It is of 2 types
o Direct Delivery
Occurs when the source and the destination are in the same physical network or when the
delivery is between the router and the host.
o Indirect Delivery
Destination host is not on the same physical network the packet is delivered indirectly
here packet goes from router to router before reaching the destination host.
Last delivery of an Indirect delivery is always Direct delivery.
FORWARDING
Means to place the packet in its route to its destination.
Requires a host or a router to have a routing table
Forwarding techniques
o Next hop method vs route method
The routing table holds the address of only the next hop instead of information
about the complete route.
o Network-specific method vs host-specific method
Instead of having an entry for every destination host connected to the same physical
network, we have only one entry that defines the address of the destination network
itself.
All hosts connected to the same network are treated as one entity.
o Default method
Instead of listing all the networks of the entire Internet a host cant just have one
entry called the default ( normally defined as the network address 0.0.0.0 ).
Forwarding process
in classless routing we need at least 4 columns in a routing table ( one for mask).
o Address aggregation
o Hierarchical routing
o Geographical routing
ROUTING TABLE
Routing tables has an entry for each destination or combination of destinations to route IP
packets.
2 types of routing tables :
o Static routing table
contains info entered manually by the administrator,
tables cannot update on their own
can be used in a small network that does not change very often
o Dynamic routing table
o Network address defines the network address to which the packet is finally delivered.
in the case of host-specific routing it defines the address of the destination host.
o Next hop defines the address of the next hop router to which the packet is delivered.
o Use this field shows the number of packets transmitted through this router for the
corresponding destination.
o The distance of the nodes that are not immediate neighbours are assigned ∞
Sharing
o Main idea of DVR is sharing of information between neighbours
o Only the distance vector of the vector table is shared with the neighbours
Updating
o When a node revives the distance vector from the neighbours table the distances are
recalculated based on the received distance vector.
o If there are 2 routes to a node then both the routes are calculated and the route with the
least distance is added to the vector table.
When to share
o Periodically and when there is a change in the table
o Periodic update
sends its vector table every 30s ( generally )
depends on the protocol.
o Triggered update
whenever there is a change in the vector table change can occur from
1 . Node receives a table from the neighbour resulting in changes
2. Node detects a failure in the neighbour links which results to distance change to ∞.
o Two-Node Loop instability
also called the Count to infinity problem
lets assume 3 nodes
1 1 1 1 INTERNET
node 3 node 2 node 1
Defining infinity
redefine infinity to a smaller number such as 100 but this means the distance
vector routing cannot be used in large systems.
Split Horizon
instead of flooding the table through each interface, each node sends only part of
its table through each interface.
if node 2 thinks that the optimum route to reach internet is through node 3 it
doesn’t need to advertise this info. Thus avoiding the problem
Split horizon and poison reverse
normally the DV protocol uses a timer and if there is no news about a route the
node deletes the route from its table.
RIP ( Routing Information Protocol)
o Intradomain routing protocol
o Specifics
Distance in RIP is defined as the number of links to reach destination. For this
reason metric in RIP is called hop count.
Infinity is defines as 16 which means the AS using RIP cannot have more that 15
hops
o Areas
To handle routing efficiently ASs are divided into smaller parts called areas.
Routers inside an area flood the area with routing information. At the border of area
special routers called AREA BORDER ROUTERS summarize the info and send it to
other areas
There is a special area called backbone. It’s the primary area all other are secondary
area. All areas must be connected to the backbone. Routers inside the backbone are
called backbone routers.
If connection between an area and backbone router is broken then a virtual link is
made by the administrator to allow continuity.
Each area has an identification the identification of the backbone is zero.
o Metric
An administrator assigned cost . can be based on service ( minimum delay, max throughput
etc.) routers can have multiple routing tables based on different services.
o Types of links
a connection is called a link there are 4 types of links defined
point -to-point, transient , stub and virtual.
Point to point
connects 2 routers without any other host or router in between.
no need to assign network address to this types of link.
Transient link
network with several routers attached to it.
all WANs and LANs with more that 2 routers are of this type
Stub link
network that is connected to only one router.
data packets are received and transmitted through this single router.
special case of transient network
Virtual link
when the link between 2 routers is broken a virtual link is created by the
administrator.
a longer path that goes through other several routers.
PATH VECTOR ROUTING
It is an exterior routing protocol used for interdomain routing.
We assume that there is only one node (speaker node)
Speaker node in AS creates the routing tables and addresses the speaker nodes in neighbouring
Ass idea is same as DVR except that only speaker nodes in each AS can communicate.
Loop prevention
when a router receives a message it checks to see if its autonomous system is in the path list to the
destination. If looping is involved the message is ignored.
Policy routing
if one of the autonomous systems listed in the path is against its policy it can ignore that path and
that destination.
Optimum path
Stub AS
a stub has only one connection to another AS.
it is either a source or sink.
Multihomed AS
has more connection to other AS.
still only a sink or source for data traffic.
does not allow transient traffic.
Transit AS
is a multihomed AS that also allow transient traffic.
examples are International and national ISPs.
o Path attributes
every path is actually a list of attributes that help the receiving router make more well
informed decisions.
attributes are divided into 2 categories well known and optional
Well known attribute must be recognised by every BGP router.
Well-known mandatory attribute must appear in the description of a route
Well-known discretionary attribute must be recognised by each router.
but not required to be included in the description.
Optional attribute need not be recognised by every router.
o BGP sessions
exchange of information between 2 routers takes place in a session
To create a reliable environment BGP uses the services of TCP.
BGP sessions are sometimes reffered to as Semi-permanent connections.
because TCP connection for BGP can last for a long time until something unusual
happens.