Presentation is loading. Please wait.

Presentation is loading. Please wait.

NET 221D:Computer Networks Fundamentals

Similar presentations


Presentation on theme: "NET 221D:Computer Networks Fundamentals"— Presentation transcript:

1 NET 221D:Computer Networks Fundamentals
Lecture 5: Network Layer

2 Introduction Physical and data link layers operate locally; they know nothing about other layers, their task is limited to deliver data from one node to the next (immediate) node ,through only one link and not beyond. The network layer is responsible for the source-to- destination [host to host] delivery of a packet, possibly across multiple networks (links), and for routing the packets through the routers.

3 The network layer is responsible
for host-to-host delivery and for routing the packets through the routers or switches. Figure 20.2 shows the same internetwork with a network layer added

4 Cont. Introduction The network layer adds a header that includes the logical addresses of the sender and receiver to the packet corning from the upper layer. If a packet travels through the Internet, we need this addressing system to help distinguish the source and destination. When independent networks or links are connected together to create an internetwork , routers or switches route packets to their final destination.

5 Logical addressing

6 1-Logical Addressing We use the term internet protocol (IP) address to mean a logical address in the network layer of the TCP/IP protocol. The Internet addresses are 32 bits in length; this gives us a maximum of 2^32 addresses. These addresses are referred to as IPv4 (IP version 4) addresses. The need for more addresses, in addition to other concerns about the IP layer, motivated a new design of the IP layer called the new generation of IP or IPv6 (lP version 6). In IPv6, the Internet uses 128-bits addresses that give much greater flexibility in address allocation..

7 IPv4 An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device. For example, a computer or a router) to the Internet. Two devices in the Internet can never have the same address at the same time. An address may be assigned to a device for a time period and then taken away and assigned to another device. If a device operating at the network layer (e.g. router) has m connections to the Internet, it needs to have m IP address.

8 IPV4 has an address space: is the total number of addresses used by the protocol.
If a protocol uses N bits to define an address, the address space is 2N . IPv4 uses 32-bit addresses: The address space=232 =4,294,967,296 ( more than 4 billion)

9 IPv4 Addresses: Notations
There are two prevalent notations to show an IPv4 address: binary notation and dotted decimal notation. 1. Binary notation: Address is displayed as 32 bits. IPv4 address referred to as 32-bit address or 4-byte address Example:

10 2. Dotted-decimal notation: More compact and easier to read
Written in decimal form with a decimal point (dot) separating the bytes. Example: Each decimal value range from 0 to 255 Example: Dotted-decimal notation and binary notation for an IPv4 Address.

11 Binary-to decimal and decimal to binary

12 Example # 1 Change the following IPv4 addresses from binary notation to dotted-decimal notation. Solution We replace each group of 8 bits with its equivalent decimal number (see Appendix B) and add dots for separation.

13 Example # 2 Change the following IPv4 addresses from dotted-decimal notation to binary notation. Solution We replace each decimal number with its binary equivalent (see Appendix B).

14 Example # 3 Find the error, if any, in the following IPv4 addresses.
Solution a. There must be no leading zero (045). b. There can be no more than four numbers. c. Each number needs to be less than or equal to 255. d. A mixture of binary notation and dotted-decimal notation is not allowed.

15 A. Classful addressing Note
IPv4 addressing used the concept of classes (classful addressing). Note In classful addressing, the address space is divided into five classes: A, B, C, D, and E. We can find the class of an address in: Binary notation: the first few bits define the class Decimal-dotted notation: the first byte define the class

16 Figure 19.2 Finding the classes in binary and dotted-decimal notation
In classful addressing, an IP address in class A, B, or C is divided into netid and hostid. These parts are of varying lengths, depending on the class of the address. Figure 19.2 shows the netid is in color, the hostid is in white. Note that the concept does not apply to classes D and E

17 Example 4 Find the class of each address. a b c d Solution a. The first bit is 0. This is a class A address. b. The first 2 bits are 1; the third bit is 0. This is a class C address. c. The first byte is 14; the class is A. d. The first byte is 252; the class is E.

18 Classes and Blocks One problem with classful addressing is that each class is divided into a fixed number of blocks with each block having a fixed size as shown in Table 19.1. Table Number of blocks and block size in classful IPv4 addressing In classful addressing, a large part of the available addresses were wasted.

19 Classful Addressing: Classes and Blocks

20 Classful Addressing: Classes and Blocks
Each class is divided into a fixed number of blocks with each block having a fixed size Class A address: designed for large organizations with a large number of attached hosts or routers. (most of the addresses were wasted and not used) Class B address: designed for midsize organizations with ten of thousands of attached hosts or routers( too large for many organizations) Class C address: designed for small organizations with a small number of attached hosts or routers (too small for many organizations) Class D address: designed for multicasting. (waste of addresses) Class E address: reserved for future use (waste of addresses)

21 Classful Addressing: Network address
The network address is an address that define the network itself to the reset of the internet. The network address has the following properties: 1. All hostid bytes are 0’s 2. It is the first address in the block 3. It cannot be assigned to a host 4. Given the network address, we can find the class of the address

22 Find the network address for the following: 1. 132.6.17.85
Example : Find the network address for the following: Solution The class is B. The first 2 bytes defines the Netid. We can find the network address by replacing the hostid bytes (17.85) with 0s. Therefore, the network address is The class is A. Only the first byte defines the Netid. We can find the network address by replacing the hostid bytes ( ) with 0s. Therefore, the network address is You have this ip find the network address , first address , last address , number of host , which class

23 Classful Addressing: Network address

24 B. Classless addressing.
Note Classful addressing, which is almost obsolete, is replaced with classless addressing. In classless addressing, we can divide the address space into variable-length blocks. There are three restrictions in classless addressing: a. The number of addresses needs to be a power of 2. b. The mask needs to be included in the address to define the block. c. The starting address must be divisible by the number of addresses in the block.

25 Example Figure 19.3 shows a block of addresses, in both binary and dotted-decimal notation, granted to a small business that needs 16 addresses. We can see that the restrictions are applied to this block. The addresses are contiguous. The number of addresses is a power of 2 (16 = 24), and the first address is divisible by 16. The first address, when converted to a decimal number, is 3,440,387,360, which when divided by 16 results in 215,024,210.

26 C. Mask Although the length of the netid and hostid (in bits) is predetermined in classful addressing, we can also use a mask (called the default mask). The mask can help us to find the netid and the hostid. For example, the mask for a class A address has eight 1s, which means the first 8 bits of any address in class A define the netid; the next 24 bits define the hostid. The last column of Table shows the mask in the form /n where n can be 8, 16,or 24 in classful addressing. This notation is also called slash notation or Classless Interdomain Routing (CIDR) notation.

27 Classful Addressing: Classes and Blocks
Mask (default mask)  Help us to find the NetId and HostId  Mask: 32-bit made of 1s followed by 0s.  Does not apply to classes D and E.  CIDR(Classless Interdomain Routing): used to show the mask in the form /n (n=8,16,24)

28 Why do we need the Mask? In IPv4 addressing, a block of addresses can be defined as x.y.z.t /n in which x.y.z.t defines one of the addresses and the /n defines the mask. The first address in the block can be found by setting the rightmost 32 − n bits to 0s. The last address in the block can be found by setting the rightmost 32 − n bits to 1s. The number of addresses in the block can be found by using the formula 2 32−𝑛

29 Example # 1 a. A block of addresses is granted to a small organization. We know that one of the addresses is /28. What is the first address in the block? Solution The binary representation of the given address is If we set 32−28 rightmost bits to 0, we get or This is actually the block shown in Figure 19.3.

30 Example cont. b. Find the last address for the block in Example 19.6.
Solution The binary representation of the given address is If we set 32 − 28 rightmost bits to 1, we get or c. Find the number of addresses in Example 1. Solution The value of n is 28, which means that number of addresses is 2 32−28 or 16.

31 Example # 2 Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32-bit binary (or 8-digit hexadecimal) number. This is particularly useful when we are writing a program to find these pieces of information. In Example 19.5 the /28 can be represented as (twenty-eight 1s and four 0s). Find a. The first address b. The last address c. The number of addresses.

32 Example (continued) Solution
a. The first address can be found by ANDing the given addresses with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise.

33 Example (continued) b. The last address can be found by ORing the given addresses with the complement of the mask. ORing here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each to 0 and each 0 to 1.

34 Example (continued) c. The number of addresses can be found by complementing the mask, interpreting it as a decimal number, and adding 1 to it. Note The first address in a block is normally not assigned to any device; it is used as the network address that represents the organization to the rest of the world.

35 Figure 19.6 two levels of hierarchy in an ipv4 address
D. Hierarchy An IP address can define only two levels of hierarchy when not subnetted. The n leftmost bits of the address x.y.z.t/n define the network (organization network); the 32 – n rightmost bits define the particular host (computer or router) to the network. An example of hierarchy is a telephone network that has three level of hierarchy The two common terms used are prefix and suffix. The part of the address that defines the network is called the prefix; the part that defines the host is called the suffix. Figure two levels of hierarchy in an ipv4 address

36 1. Subnetting in Classful Addressing
If an organization was granted a large block in classes A or B It could divide the addresses into several contiguous groups and assign each group to smaller networks ( subnets) It increases the number of 1s in the mask To make a subnet mask , we change some of the leftmost 0s in mask to 1s The number of subnets is determine by the number of extra1s. If the number of extra 1 is n, the number of subnets is 2n. If the number of subnets is N, the number of extra 1s is log2N

37 For 4 subnets : (log 2 4 = 2; need 2-extra bits )
Example Class B address mask : or /16 For 4 subnets : (log 2 4 = 2; need 2-extra bits ) Subnet mask: or /18 For 8 subnets: (log 2 8 = 3; need 3-extra bits ) subnet mask : or /19 16 11 2 14 111 3 12

38 2. Subnetting in Classless addressing
An organization that is granted a large block of addresses may want to create clusters of networks (called subnets) and divide the addresses between the different subnets. As an example, suppose an organization is given the block /26, which contains 64 addresses. The organization has three offices and needs to divide the addresses into three subblocks of 32, 16, and 16 addresses. We can find the new masks by using the following arguments: 1. Suppose the mask for the first subnet is n1, then 2^(32- n1) must be 32, which means that n1 =27. 2. Suppose the mask for the second subnet is n2, then 2^(32- n2) must be 16, which means that n2 = 28. 3. Suppose the mask for the third subnet is n3, then 2^(32- n3) must be 16, which means that n3 =28. This means that we have the masks 27, 28, 28 with the organization mask being 26.

39 Configuration and addresses in a subnetted network

40 Figure 19.7 Configuration and addresses in a subnetted network
Three-Levels of Hierarchy: Subnetting Figure Configuration and addresses in a subnetted network

41 3. Supernetting Huge demand for midsize blocks.
Although class A and B addresses are almost depleted, class C addresses are still available( size of block= 256 address did not satisfy the needs). In supernetting, an organization can combine several class C blocks to create a larger range of addresses. Several networks are combined to create a supernetwork ( supernet). e.g. Organization needs 1000 address can be granted 4 contiguous class C blocks to create one supernetwork. Decreases the number of 1s in the mask. E.g. The mask changes from /24 to /22 for 4 class C block

42 The Internet Protocol version 4 (IPv4)
It is the current and common delivery mechanism used by the TCP/IP protocols. IPv4 is an unreliable connectionless protocol responsible for source-to-destination delivery. Packets in IPv4 layer are known as Datagram which consists of two parts: a header and data (payload). The length of the header is 20 – 60 bytes and it contains essential information for routing and packet delivery.

43 The Internet Protocol version 4 (IPv4)
It is a layer 3 protocol Host-to-host network layer delivery protocol for the internet. It is unreliable and connectionless protocol. No error control. No flow control. It has error detection (discard) If reliability is of concern, the IP has to be tied to a connection-oriented protocol (i.e. TCP) In reality, each packet (datagram) is handled independently: Each packet can follow different rout to destination. Thus, Packets may arrive out of order, dropped and/or lost.  IP relies on higher level protocols to take care of all these problems.

44 Figure 20.5 IPv4 datagram format
A datagram is a variable-length packet consisting of two parts: header and data. Figure IPv4 datagram format

45 Internet Protocol (IPv4): Header Format
Field Length Description Version 4 bit Identifies the version of IP used to generate the datagram HLEN Specifies the length of the IP header, including the length of any options and padding. The normal value of this field when no options are used is (20 bytes) value must be multiplied by 4 to give the length in bytes Service (TOS) 8 bit Type of Service (TOS): A field designed to carry information to provide quality of service features, such as prioritized delivery, for IP datagram. Total Length (TL) 16 bit Specifies the total length of the IP datagram, in bytes. Since this field is 16 bits, the maximum length of an IP datagram is 65,535 bytes (2^16 – 1) of which byte is the header. Identification This field is used by the receiver to reassemble messages without mixing fragments from different messages. Flags 3 bit Control flags to manage fragmentation Fragmentation offset 13 bit This field specifies the offset, or position, in the overall message where the data in this fragment goes. Time to live (TTL) 8 bits Specifies how long the datagram is allowed to “live” on the network, in terms of router hops. Each router decrements the value of the TTL by one prior to transmitting it. If the TTL =0, the datagram is discarded.

46 Internet Protocol (IPv4): Header Format
Field Length Description Protocol 8 bit Identifies the higher layers protocols (transport or encapsulated network layer protocols) carried in the datagram Header checksum 16 A checksum computed over the header to provide basic protection against corruption in transmission Source address 32 bit The 32-bit IP address of the originator of the datagram (intermediate device will not change it) Destination address The 32-bit IP address of the intended recipient of the datagram. (intermediate device will not change it) options var One or more of several types of options may be included after the standard headers in certain IP datagram Note The total length field defines the total length of the datagram including the header. Since the field length is 16 bits, the total length (header + data) is bytes. 20 to 60 bytes are used as header. Thus, length of data = total length - header

47 Example An IPv4 packet has arrived with the first 8 bits as shown:
The receiver discards the packet. Why? Solution There is an error in this packet. The 4 leftmost bits (0100) show the version, which is correct. The next 4 bits (0010) show an invalid header length (2 × 4 = 8). The minimum number of bytes in the header must be 20. The packet has been corrupted in transmission.

48 Fragmentation Figure 20.10 Flags used in fragmentation
Figure Fragmentation example Fragmentation is the division of a datagram into smaller units to accommodate the MTU of a data link protocol.

49 Figure 20.12 Detailed fragmentation example

50 Examples 1. A packet has arrived with an M bit value of 0. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented? Solution If the M bit is 0, it means that there are no more fragments; the fragment is the last one. However, we cannot say if the original packet was fragmented or not. A non-fragmented packet is considered the last fragment.

51 Examples 2. A packet has arrived with an M bit value of 1. Is this the first fragment, the last fragment, or a middle fragment? Do we know if the packet was fragmented? Solution If the M bit is 1, it means that there is at least one more fragment. This fragment can be the first one or a middle one, but not the last one. We don’t know if it is the first one or a middle one; we need more information (the value of the fragmentation offset). 3. A packet has arrived with an M bit value of 1 and a fragmentation offset value of 0. Is this the first fragment, the last fragment, or a middle fragment? Solution Because the M bit is 1, it is either the first fragment or a middle one. Because the offset value is 0, it is the first fragment.

52 4. A packet has arrived in which the offset value is 100
4. A packet has arrived in which the offset value is 100. What is the number of the first byte? Do we know the number of the last byte? Solution To find the number of the first byte, we multiply the offset value by 8. This means that the first byte number is 800. We cannot determine the number of the last byte unless we know the length. 5. A packet has arrived in which the offset value is 100, the value of HLEN is 5, and the value of the total length field is 100. What are the numbers of the first byte and the last byte? Solution The first byte number is 100 × 8 = 800. The total length is 100 bytes, and the header length is 20 bytes (5 × 4), which means that there are 80 bytes in this datagram. If the first byte number is 800, the last byte number must be 879.

53 Network Routing Algorithms

54 Routing Algorithms Routing – main function of network layer Routing algorithm decides which output line incoming packet should be transmitted on. fills up and updates routing tables. Routing protocols are used to continuously update the routing tables that are consulted for routing and forwarding. 16-Sep-18 Networks and Communication Department

55 2. Routing algorithm

56 Two Major Classes Non‐adaptive/static routing Adaptive routing
Routing decisions not based on traffic, topology . instead, routes are computed in advance Adaptive routing Change their decisions to reflect changes in the topology and traffic Differ in: information source and update frequency

57 The Optimality Principle
Each portion of a best path is also a best path; the union of them to a router is a tree called the sink tree (with out loops) Best means fewest hops in the example

58 a) Flooding A simple method to send a packet to all network nodes
Each node floods a new packet received on an incoming link by sending it out all of the other links Nodes need to keep track of flooded packets to stop the flood; even using a hop limit can blow up exponentially

59 b. Shortest Path Routing (a nonadaptive routing algorithm)
Shortest path algorithm first developed by E. W. Dijkstra Given a network topology and a set of weights describing the cost to send data across each link in the network. Build a graph of network. Each node represent a router. Each arc represent a link. Find shortest path between the two nodes Find the shortest path from a specified source to all other destinations in the network. The algorithm divides the nodes into two sets: tentative and permanent. It finds the neighbors of a current node, makes them tentative, examines them, and if they pass the criteria, makes them permanent.

60 Cont. Steps : Mark the source node as permanent.
Designate the source node as the working node. Set the tentative distance to all other nodes to infinity. While some nodes are not marked permanent Compute the tentative distance from the source to all nodes adjacent to the working node. If this is shorter than the current tentative distance replace the tentative distance of the destination and record the label of the working node there. Examine ALL tentatively labeled nodes in the graph. Select the node with the smallest value and make it the new working node Designate the node permanent.

61 Figure 22.23 Example of formation of shortest path tree

62 Permanent Tentative Empty A(0) B(5),C(2),D(3) A(0), C(2) B(5),D(3),E(6) A(0), C(2) ,D(3) B(5),E(6) A(0), B(5), C(2) ,D(3) E(6) A(0), B(5), C(2) ,D(3), E(6)

63 Table 22.2 Routing table for node A

64 c. Distance Vector Routing (an adaptive routing algorithm)
It is Bellman-Ford Routing Distance vector is a distributed routing algorithm • Shortest path computation is split across nodes Algorithm: Each node knows distance of links to its neighbors Each node advertises vector of lowest known distances to all neighbors Each node uses received vectors to update its own Repeat periodically

65 Distance Vector Routing (an adaptive routing algorithm)
Neighboring routers periodically exchange information from their routing tables. Routers replace routes in their own routing tables anytime that neighbors have found better routes. Information provided from neighbors Outgoing line used for destination Estimate of time or distance can be number of hops, time delay, packet queue length, etc.

66 1. Distance Vector Routing
In distance vector routing, the least-cost route between any two nodes is the route with minimum distance. In this protocol, as the name implies, each node maintains a vector (table) of minimum distances to every node. The table at each node also guides the packets to the desired node by showing the next stop in the route (next-hop routing). We can think of nodes as the cities in an area and the lines as the roads connecting them A table can show a tourist the minimum distance between cities. 16-Sep-18 Networks and Communication Department

67 1. Distance Vector Routing cont.
Steps (phases) : Initialization Sharing Updating 16-Sep-18 Networks and Communication Department

68 Figure 22.15 Initialization of tables in distance vector routing

69 Figure 22.16 Sharing in distance vector routing

70 Figure 22.14 Updating Distance vector routing tables

71


Download ppt "NET 221D:Computer Networks Fundamentals"

Similar presentations


Ads by Google