Process Layer Process Process CSCE 515: Computer Network Transport Layer TCP UDP Programming ------ IP routing ICMP, ARP Network Layer IP & Wenyuan Xu RARP Department of Computer Science and Engineering University of South Carolina Data-Link Layer 802.3 CSCE515 – Computer Network Programming IP - Network Layer Internet Protocol (IP) � Provide delivery of packets from Regional Network 1 � Provide unreliable and connectionless datagram one host in the Internet to any delivery service other host in the Internet, even if the hosts are on different networks � Internet packets are called “datagrams” and may � Problems: be up to 64 kilobytes in length (although they are � Heterogeneity (addressing, Backbones packet size and format, routing) typically much smaller e.g. 1500 bytes) Regional � Handling this problem and efficiently route packets across Network 2 several networks � Upper layer data (TCP, UDP, ICMP, IGMP, etc.) � Loops, oscillations, islands � Solutions are transmitted as IP datagrams � Gateways to handle communication between networks � Q: What’s the advantage of connectionless � Gateways, routers, nodes, links, delivery? networks Regional Network 3 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming Advantages of Connectionless IP Routing � Host software is much simpler at the network layer. � Q: How do you get a packet from one network to another? � Transport layer already provides connection-oriented, should not repeat the work � Many applications do not require sequential delivery of ? packets (example: packet voice). � It is better to provide degraded service to everyone than A B C D W X Y Z to limit network access. � Server (or router) could become overloaded managing too many connections. CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming
IP Routing IP Routing � A: with a router (or a series of routers) Case 1: R Single hop A B C D W X Y Z Network R R Case 2: cloud Multi-hop Actual routing able contains IP addresses, Flags A B C D W X Y Z indicating type of entries, net mask etc. CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming IP Routing Routing Table � Each entry contains following information � Forwarding: � Destination IP address � When each packet arrives, looking up the outgoing � IP address of next-hop router line to use for it in the routing table � Specification of network interface � Done on a hop-by-hop basis � Flag � U: the route is up and operational. � If destination is directly connected or on a shared � H :this is a route to a specific host (most routes are to networks). network, send IP datagram directly to destination � G : the route uses an external gateway . � Otherwise send datagram to a router Destination Gateway Flags Ref Use Interface -------------------- -------------------- ----- ----- ------ ---------------- ------------ � Routing updates 192.168.0.0 129.252.130.203 UG 1 0 129.252.130.0 129.252.130.106 U 1 68 eri0 � filling in and updating the routing tables 224.0.0.0 129.252.130.106 U 1 0 eri0 default 129.252.130.1 UG 1 135 127.0.0.1 127.0.0.1 UH 1 0 lo0 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming Host route determination IP Routing � Longest prefix match with destination address and entry � Forward datagrams generated either on local in the routing table host or on some other hosts toward their ultimate destination � First, search for a matching host address � Flag H is set � Static routing: when network is small, single � Second, search for a matching network address connection point to other networks, no � Need to know the number of bits to use for network ID redundant route existent � Third, search for a default entry � Execute netstat –rn on your machine and find the contents � Dynamic routing: use routing daemon to run of the routing table routing protocol in order to communicate with � Default entry allows for a single entry for a list of entries that have the same next-hop value other routers CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming
ifconfig Command netstat Command � Available at /usr/bin � Available at /usr/sbin � Display network status � Configure or query a network interface � -a option to display state of all sockets, all used by TCP/IP routing table entries, or all interfaces � Support address families other than IP � -i option to display interface information address � -n option to print IP addresses instead of host names � -a option to display report of all interfaces � -r option to display routing table � -M option to display multicast routing table CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming IP Addresses The four for mats of IP Addresses � 32 bits long: 129.252.138.8 � Subnet Addressing Class Class � To make better use of class A and class B addresses, divide host ID into subnet ID and A A 0 NetID HostID host ID B B 10 NetID HostID 14 16 10 NetID HostID C C 110 NetID HostID Class B Class B 14 8 8 D D 1110 Multicast Address 10 NetID SubnetID HostID 8 bits 8 bits 8 bits 8 bits CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming Subnet Mask Subnet Masks � 32-bit value containing “1” bits for network ID � Assume UP addresses A and B share subnet mask M. and subnet ID, and “0” bits for host ID � Are IP addresses A and B on the same subnet? � 1. Compute (A and M) � 2. Compute (B and M) 14 8 8 � 3. if (A and M) == (B and M) then A and B are one the same subnet. B B 10 NetID SubnetID HostID � Example: A and B are class B addresses 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 � A = 165.230.82.52 255.255 .255 .0 � B = 165.230.24.93 Same network? 0xFFFF FF 00 � M = 255.255.255.0 Same subnet? CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming
Variable length subnetting Routing Table � Subnet masks allow power of 2 subnets Address Mask Interface � Use a hierarchy of routers to allow subnets to be 221.2.3.0 255.255.255.128 L1 divided with different subnet masks 255.255.255.192 � Another approach: � Variable length subnet masks 221.2.3.128 255.255.255.128 L2 � Allow a subnet to be defined by more than two masks 255.255.255.192 � The router applies the masks one after another mask: 255.255.255.128 221.2.3.129 255.255.255.128 L3 subnet: 221.2.3.0 mask: 255.255.255.128 subnet 1 255.255.255.192 255.255.255.192 subnet: 221.2.3.128 subnet 2,3 subnet: 221.2.3.192 mask: 255.255.255.192 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming Question CIDR � CIDR (classless Inter domain routing) � If an ISP has a 203.6.8.0 Network, he � Too many small networks requiring multiple wants to give assign to 5 customers who class C addresses need 60, 60, 60, 30, 30 hosts. � Running out of class B addresses, not enough � What should the subnet mask be? nets in class A � What is the address range in each subnet? � Assign contiguous block of class C addresses � What should the routing table entries be? � Use CIDR address mask to aggregate � Ex 192.17.0.0, 255.255.248.0, Send it to R3 CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming CIDR Supernetting � Example: an organization needs 500 addresses. � Original addressing schemes (class-based): � A single class C address not enough (256 hosts). � 32 bits divided into 2 parts: � Instead a class B address is allocated. (~64K hosts). a huge waste. � Class A 0 NetID HostID � Class B � CIDR allows multiple Class C addresses to be assigned to an 10 NetID HostID � Class C organization but still occupy one entry in the routing table 110 NetID HostID � <192.5.48.0,2> this is used to specify that 2 network addresses 192.5.48.0 and 192.5.49.0 is allocated to an organization � Class C address has max of 254 hosts � Not enough for many organizations � Typically the starting address with a CIDR mask that indicates the � Too many class C addresses � huge routing tables common most significant bits for the ranges is used to specify the block of addresses � Classless Inter domain routing (CIDR) � /notation � CIDR introduced to solve 2 problems: � 192.5.48.0/23 � 192.5.48.0 and 192.5.49.0 are assigned � exhaustion of IP address space � size and growth rate of routing table CSCE515 – Computer Network Programming CSCE515 – Computer Network Programming
Recommend
More recommend