Curs 3
Curs 3
provides a datagram
(connectionless) transport
service across a network.
Key characteristics
• universally addressed:
• IP defines the addressing mechanism for the network
• uses these addresses for delivery purposes.
• underlying protocol-independent:
• IP allows the transmission of data across any type of underlying network that is designed to work with a TCP/IP stack
• it adapts to the requirements of various lower-level protocols, run on the special data link protocols
• has the ability to fragment large blocks of data into smaller ones in order to match the size limitations of physical networks, and then have
the recipient reassemble the pieces again as needed
• connectionless protocol:
• when a device A wants to send data to a device B, it doesn’t set up a connection to device B before sending the data, it just makes the
datagram and sends it
• unreliable delivery
• when device A sends datagrams to device B, it just sends each one and then moves on to the next; IP doesn’t keep track of the ones it
sent.
• unacknowledged delivery
• IP doesn’t use acknowledgements
IP functions
Data encapsulation and formatting/packaging: IP accepts data from the transport layer protocols UDP and TCP and it
encapsulates it into an IP datagram using a special format prior to transmission
Fragmentation and reassembly: IP has the ability to fragment IP datagrams into pieces, so that they can each be carried on the
local network, since the maximum frame size of each physical and data link network using IP may be different; at the destination,
the receiving device uses the reassembly function to recreate the original IP datagram.
Routing and indirect delivery: if the final destination is on a distant network that isn’t directly attached to the source, the
datagram must be delivered indirectly; this is done by routing the datagram through intermediate devices (routers)
IP version 4
(IPv4)
The IP Header
IP Header Fields (1)
• Version—is set to the value 4, which is the IPv4 version of IP (version 6 IP has a different header.)
• IHL (IP Header Length)—a 4-bit field that contains the number of binary words (a word is 32 bits or 4 bytes)
forming the header.
• ToS (Type of Service)—also known as DSCP (Differential Services Code Point); the ToS is an 8-bit field,
usually set to 0, but that may indicate particular QoS needs from the network; defines the way routers
should queue packets while they are waiting to be forwarded and in some cases provides for packets to be
forwarded along different paths based on priority.
• Total Length—A 16-bit field specifying the total length of the packet, including the header, in octets (bytes).
The combined length of the header and the data can be at most 65,535 octets because this is the largest
possible decimal number that can be described by 16 bits in binary.
• Identification—A 16-bit number that, together with the source address, uniquely identifies this packet;
used during the reassembly of fragmented datagrams.
• Flags—sequence of two flags (one of the 3 bits is unused) that controls whether routers are allowed to
fragment a packet (i.e., the Don’t Fragment, or DF flag), and to indicate the parts of a packet to the receiver
via the More Fragment (MF) flag.
IP Header Fields (2)
• Fragmentation Offset—offset from the start of the original sent packet, set by any router that performs IP
fragmentation; unused if fragmentation is not performed.
• Time to Live (TTL)—number of hops/links that the packet may be routed over, decremented by most
routers (used to prevent accidental routing loops); TTL ensures that all IP packets have a limited lifetime.
• Protocol—a 8-bit field that indicates the type of transport data being carried.
• Header Checksum—is used for detecting errors in the IP header;
• it is calculated by the transmitting router based on the contents of the IP header;
• it is calculated again by the receiver and compared with the value in the header: if they are different, the packet is
discarded;
• the checksum is updated whenever the packet header is modified by a router.
• Source Address—32-bit IP address of the original sender of the packet.
• Destination Address—32-bit IP address of the final destination of the packet.
• Options—not normally used, but when used, the IP header length is greater than five 32-bit words to
indicate the size of the options field. Originally one of the most common was the strict source route or
loose source route.
IP Addressing
• an address is 32 bits long in binary format.
• it is normally expressed as four decimal numbers as a simpler representation for
humans.
• each decimal number is separated by a dot.
• this format is called dotted-decimal notation.
• the dotted-decimal format divides the 32-bit IP address into four octets of 8 bits each
(1 octet = 8 bits).
• these octets specify the value of each field as a decimal number;
• the range of each octet (byte) is from 0 to 255 decimal, or 00000000 - 11111111 binary.
IP address
• the first part of an IP address identifies the network that a host will reside in.
• this is sometimes called a network prefix.
• the second part of an IP address identifies an individual host inside that network.
• all hosts in a given network share the same network prefix, while the host numbers must be unique to each host.
• it is exactly like a phone number.
Types of IP Addresses
• Unicast-refers to a specific IP address; a packet sent from a source to a
specific destination address is referred to as a unicast packet; this packet is
delivered to a single host or a single interface on the router;
• Broadcast - refers to all IP addresses in the broadcast domain; a packet sent
from a source to all hosts in a broadcast domain (such as Ethernet) is referred
to as a broadcast packet.
• Multicast - is reserved for group membership applications; multicast
technology is an efficient way to deliver traffic to a group of destinations that
want to receive that particular traffic.
Class-Based
IP
Addressing
Subnetting
Address Resolution Protocol
(ARP)
• is a network-specific standard protocol.
• is responsible for converting the higher-level protocol addresses (IP
addresses) to physical network addresses.
• it is described in RFC 826.
• layer 3 devices need ARP to map IP network addresses to MAC
hardware addresses so that IP packets can be sent across networks.
• the protocol can be used for any broadcast network.
ARP operation
• Anytime a host, or a router, needs to find the physical address of another host or router on
its network, it sends an ARP query packet that includes the physical and IP addresses of the
sender and the IP address of the receiver.
• The sender does not know the physical address of the receiver and thus the query is
broadcast over the network.
• Every host or router on the network receives and processes the ARP query packet, but only
the intended recipient recognizes its IP address and sends back an ARP response packet.
• The response packet contains the recipient’s IP and physical addresses.
• The packet is unicast directly to the inquirer using the physical address received in the query
packet.
ARP operation: ARP request is multicast, ARP reply is
unicast
ARP packet
format
ARP request message – fields:
• HLN (Hardware address length) - specifies how long the hardware addresses are in the message.
• PLN (Protocol address length) - specifies how long the protocol (Layer 3) addresses are in the message. For IPv4, the
value is 4.
• OP (Opcode) - specifies the nature of the message by code:
• 1—ARP request.
• 2—ARP reply.
• 3 through 9—RARP and Inverse ARP requests and replies
• SHA (Sender hardware address) - specifies the Layer 2 hardware address of the device sending the message.
• SPA (Sender protocol address) - specifies the IP address of the sending device.
• THA (Target hardware address) -specifies the Layer 2 hardware address of the receiving device.
• TPA (Target protocol address) – specifies the IP address of the receiving device.
Encapsulation of ARP packet
Reverse Address Resolution
Protocol (RARP)
• defined by RFC 903
• works the same way as the ARP, except that the RARP request packet requests
an IP address instead of a media access control (MAC) address.
• is often used by diskless workstations because this type of device has no way
to store IP addresses to use when they boot.
• RARP requires a RARP server on the same network segment as the device
interface.
• because of the limitations with RARP, most businesses use Dynamic Host
Configuration Protocol (DHCP) to assign IP addresses dynamically.
RARP
1. Ping
• Ping uses the ICMP Echo and Echo Reply messages to
determine whether a host is reachable;
• The word ping, which is used as a noun and a verb, is taken
from the sonar operation to locate an underwater object.
• It is also an abbreviation for Packet InterNet Groper.
• the first test of reachability for a host is to attempt to ping
it; if you can successfully ping a host, other applications
such as Telnet or FTP should be able to reach that host.
2. Traceroute.
• is used to determine the route IP datagrams follow through
the network.
• Traceroute is based on ICMP and UDP.