67
TCP/IP for Linux
郭大維教授
ktw@csie.ntu.edu.tw
國立台灣大學 資訊工程系
68
Internet
?Origin:
?ARPANET (1970’s - 1988)
?NSF NET (no longer exist?) and Internet.
?World Wide Web (WWW)
?Utilize TCP/IP over ARPANET/Internet.
?Linux adopts Unix 4.3BSD sockets and supports TCP/IP.
•Definition of “Intranet”: roughly speaking for any network under one authorization, e.g., a company or a school.
•Often in a Local Area Network (LAN), or connected LAN’s.
• Having one (or several) gateway with the outside world.
• In general, it has a higher bandwidth because of a LAN.
69
* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.
TCP/IP
? IP Address:
?140.123.101.1
?256*256*256*256 combinations
?140.123 -> Network Address
?101.1 -> Host Address
?Subnet:
?140.123.101 and 140.123.102
?Mapping of IP addresses and host names
?Static assignments: /etc/hosts
?Dynamic acquisition: DNS (Domain Name Server)
?/etc/resolv.confg
?If /etc/hosts is out-of-date, re-check it up with DNS!
?Domain name: cs.ccu.edu.tw as a domain name for 140.123.100, 140.123. 101, and 140.123.103
Name Resolution in TCP/IP Network
?Name Resolution
?A hierarchical host name
?bob.csie.ntu.edu.tw
?A 32-bit Internet Number (host id)
?140.112.101.32
?How it works?
?The sending system checks its routing table to locate a router. The routers use the network part of the host-id to transfer the packet to the destination network.
71
* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.
Name Resolution in TCP/IP Network
? Mapping of Ethernet (IEEE 802.3) physical addresses and IP addresses
?Each Ethernet card has a built-in Ethernet physical address, e.g., 08-01-2b-00-50-A6.
?Ethernet cards only recognize frames with their physical addresses.
?Linux uses ARP (Address Resolution Protocol) to know and maintain the mapping.
?Periodically broadcast requests over Ethernet for IP address resolution over ARP.
?A UDP packet with the host-id and Ethernet address
?Machines with the indicated IP addresses reply with their Ethernet physical addresses.
72
Name Resolution in TCP/IP Network
?Within a network,
?Each host caches the info in its ARP cache with aging.
?When a process specifies a host to communicate.
?The kernel determine the host’s in using domain name server (DNS) lookup.
?Pass all layers with Ethernet address in the packet.
?The Host receives the packets and pass all layers.
73
* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.
TCP/IP
TCP header + Data
IP header Data
Ethernet header Data
An Ethernet frame
An IP packet
A TCP packet
• Each IP packet has an indicator of which protocol used, e.g., TCP or UDP
Routing
?Def:
?How are msgs sent through network?
?Common routing scheme
?Fixed routing
?A path is specified in advance & does not change!
?Virtual routing
?A path is fixed for a session, e.g., a file transfer or remote login!
?Dynamic routing
?A path is chosen only when a msg is sent.
?Wrong sequence order!
75
* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.
TCP/IP
?Router
?With a Routing table
?Use some routing protocol, e.g., to maintain network topology by broadcasting.
?Connecting several subnets (of the same IP- or-higher-layer protocols) for forwarding packets to proper subnets.
?Gateway
?Functionality containing that of routers.
?Connecting several subnets (of different or the same networks, e.g., Bitnet and Internet)for forwarding packets to proper subnets.
76
TCP/IP
gateway
gateway TARNET
HINET
Intranet AIntranet
AIntranet
Intranet
router Intranet
77
* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2001.
Network Layers in Linux
PPP SLIP Ethernet
Internet Protocol (IP)
Transport Layer ARP
TCP UDP
INET sockets
BSD sockets Kernel
Applications applications
TCP/IP
?Transmission Control Protocol (TCP)
?Reliable point-to-point packet transmissions.
?Applications which communicate over TCP/IP with each another must provide IP addresses and port numbers.
?/etc/services
?Port# 80 for a web server.
?User Datagram Protocol (UDP)
?Unreliable point-to-point services.