TCP/IP networking

advertisement
TCP/IP networking
 TCP/IP
 A networking protocol suite
• Use several protocols, main ones are tcp and ip.
• IP stands for Internet Protocol
• TCP stands for Transmission Control Protocol.
 The
native language of the Internet
 Supported by most OSs (Unix, MacOS,
Windows, Netware, etc)
 Defines a uniform programming interface
to different types of network hardware
TCP/IP networking
1-1
TCP/IP and Internet
 1969 ARPAnet
 Experimental packet-switching network
 Study robust, reliable, vendor-independent data
communication
 Very successful
 1975 ARPAnet became operation network
 Development continuing
 TCP/IP was developed
 1983 TCP/IP protocols were adopted as Military
Standards


TCP/IP was implemented in Berkeley Unix.
ARPAnet was divided into MILNET and ARPAnet
TCP/IP networking
1-2
TCP/IP and Internet
 1985 NSFNet
 Connected to the then existing Internet (
MILNET plus ARPAnet)
 Linked together the five NSF super computer
centers
 Wanted to extend the network to every
scientist
 1987 new NSFNet backbone
 Faster
 Three-tiered topology: backbone, regional
networks, and local networks.
TCP/IP networking
1-3
TCP/IP and Internet
 1990 ARPAnet passed out of existence
 1995 NSFnet ceased its role as a primary Internet
backbone network
 Today Internet is build by commercial providers.

Infrastructure is being created by
• National network provider, caller tier-one providers
• Regional network provider


Local access and user services is provided by Internet
Service Providers (ISPs)
Network Access Points (NAPS): major interconnection
points
TCP/IP networking
1-4
TCP/IP and Internet
 How the internet is managed today
Commercial force
 Several organization

• Internet Corporation for Assigned Names and
Numbers (ICANN)
– www.icann.org
• Internet Engineering Task Force (IETE)
– www.ietf.org
• Internet Society (ISOC)
– www.isoc.org
TCP/IP networking
1-5
TCP/IP and Internet
 Network standards and documentation

Request for Comments (RFC)
•
•
•
•

Over 4000 has been created
FY
STD
BCP
Dispatch central for RFC-related matters
• www.rfc-editor.org
TCP/IP networking
1-6
Networking Road Map
 TCP/IP components

IP, the Internet Protocol
• routes data packets from one machine to another

ICMP, the Internet Control Message Protocol
• Provides several kinds of low-level support for IP
– Error message
– Routing assistance
– Debugging help

ARP, the Address Resolution Protocol
• Translates IP addresses to hardware addresses
TCP/IP networking
1-7
Networking Road Map

UDP, the User Datagram Protocol
• Delivers data to specific applications on the
destination machine
• Provides “unverified”, “best effort” transport for
individual messages
 TCP,
the Transmission Control Protocol
• Delivers data to specific applications on the
destination machine
• Provides reliable, flow controlled, error corrected
conversation between processes on two hosts.
TCP/IP networking
1-8
TCP/IP network model
Application
Layer
Transport Layer
Network Layer
Link Layer
Physical layer
ARP
SSH, FTP, WEB
TCP
DNS, Quake
Traeroute
UDP
IP
ICMP
ARP, Device Drivers
UTP copper, fiber, radia waves
TCP/IP networking
1-9
Packets and encapsulation
 Data travels on a network in the form of packets
 Each packet consists of
 A header – where it came from and where it’s going,
protocol info, checksum, etc.
 A payload - data
 As a packet travels down the protocol stack
 encapsulation
• Each protocol adds its own header information
• Each protocol’s finished packet becomes the payload part of
the packet generated by the next protocol.
 On a receiving machine, the encapsulation is
reversed as the packet travels back up the
protocol stack.
TCP/IP networking
1-10
Packets and Encapsulation
 Example: A typical network packet
Ethernet
header
IP
header
UDP
header
Application data
Ethernet
CRC
UDP packet(108 bytes)
IP packet(128bytes)
Ethernet frame(146 bytes)
TCP/IP networking
1-11
Addressing
 Packets addressing
 Packets must be properly addressed in order to reach
their destination
 Addressing schemes
• MAC (media access control) addresses for hardware
• IP addresses for software
• Hostnames for people
 Ports
 16 bit number
 Address particular processes or services
 Well-known ports are defined in /etc/services
 Unix systems restrict access port under 1024 to root.
TCP/IP networking
1-12
Addressing
 Address types
 Unicast – addresses that refer to a single host
(interface)
 Multicat – addresses that identify a group of hosts
 Broadcast – addresses that include all hosts on the local
network
 IP addresses
 Four bytes long
 Network part and host part
 Written as decimal numbers, one for each byte
separated by periods
 When 127 is the first byte of an address, it denotes the
“loopback network”
• Lookback address 127.0.0.1 - localhost
TCP/IP networking
1-13
Addressing
 IP address classes

The traditional class determine which bytes of
the address were in the network portion and
which were in the host portion
•
•
•
•
•
A 1-126
N.H.H.H
B 128-191
N.N.H.H
C 192-223 N.N.N.H
D 224-239
E 240- 254
Very early network
large sites (65536)
(256)
Multiple addresses
Experimental addresses
TCP/IP networking
1-14
Addressing
 Subnetting and netmasks
 Host portion of an address is “borrowed” to
extend the network portion
 This reassignment is done by using ifconfig
command to associate an explicit “subnet mask”
with a network interface.
 Each bit of the netmask that corresponds to
the network portion of an IP address is set to
1, host bits are set to 0
• The division of network part and host part need not
fall on a byte boundary
• Network bits must be contiguous and must appear at
the high order end of the addresses
TCP/IP networking
1-15
Addressing

Notation
• Ipaddress netmask
• Ipaddress/length of the network part
– 128.138.243.0/26

Example
• 128.138.243.100/24
– Netmask?
– Network?
– Broadcast?
• 128.138.243.100/26 100=01100100
– Netmask?
– Network?
– Broadcast?

Use ipcalc to get the values.
TCP/IP networking
1-16
Addressing
 The IP address crisis

Fundamental problems with the original class
allocating scheme
• Run out of B classes
• Routing table were growing so large
• IP address were allocated on a first-com, firstserved basis with no locality of reference

solutions
• Short term: Classless Inter-Domain Routing (CIDR)
• IPV6: extend the address to 16 bytes
– 665,570,793,348,866,943,898,599 addresses
TCP/IP networking
1-17
Addressing
 Address allocation
 Regional IP address registries
• ARIN
• APNIC
• RIPE
North and South America
Asia/Pacific region
Europe and surrounding areas
 Private addresses
 Packets bearing private addresses can not get
into internet
 IP address reserved for private use
• 10.0.0.0/8
• 172.16.0.0/12
• 192.168.0.0/16
TCP/IP networking
1-18
Routing
 Routing is the process of directing a
packet through the maze of networks that
stand between its source and its
destination.
 Routing info is stored in a table in the
kernel.
Examine it use “netstat –r”
 Configure dynamically
 Configure statically

#route add –net 132.236.220.64 netmask 255.255.255.192 132.236.212.6
#route add default 132.236.227.1
TCP/IP networking
1-19
ARP
 The address Resolution Protocol discovers the
hardware address associated with a particular IP
address.
 APR uses broadcast packets, cannot cross
networks

“Does anyone know the hardware address for
128.138.116.4”?
 Check the arp cache table with arp command
#/usr/sbin/arp –a
 RARP
 Reverse translation
 Query a central server to discover its own address
 Need configuration
TCP/IP networking
1-20
Additions of machines to a
network
 Basic steps are
Assign a IP address and hostname
 Set up the new host to configure its network
interfaces at boot time
 Set up a default route and perhaps fancier
routing
 Point to a DNS name server, to allow access to
the rest of the Internet.
 Debugging

• Always to reboot if changes affect booting
TCP/IP networking
1-21
Assigning hostnames and IP
addresses
 Mapping hostnames to IP
 Hosts file
 NIS or NIS+
 DNS
 Or Combination above
 Hosts file
 /etc/hosts
• Each line start with IP, continues with various symbolic
names by which that address is known.
• Entries
– Localhost, gateway, special hosts, …
• Replicate same hosts file on machines
 Configure hostname
 Command hostname run at the boot time
 Configuration file
TCP/IP networking
1-22
Assigning hostnames and IP
addresses
 Configure network interfaces: ifconfig
Enable or disable network interface
 Set IP address
 Set subnet mask
 Set other options
 Run at the boot time (use command with the
value from configure files )
 Format

• $ifconfig interface address options … up|down
• Ex:
#ifconfig eth0 128.138.240.7 network 255.255.255.0 up
TCP/IP networking
1-23
Assigning hostnames and IP
addresses
 Interface name:
 Identifies the hardware to which the command applies
 Two or three character device name followed by a
number.
 The loopback interface is named lo0
 The common interface names are
• Ie0, le0, ln0, we0, hme0, eri0, lan0, …
 Display the interfaces
 $netstat –i
 Display the setting of interfaces
 $ifconfig –a
TCP/IP networking
1-24
Assigning hostnames and IP
addresses
 Configure the network interface
 The ifconfig commands support many options
• Specify address
• Specify netmask, otherwise it uses address class (A,B,C)
• Specify broadcast
– Default can be calculated from IP + netmask
– Some sites set it to avoid certain types of denial of service
attacks. Not good.
• Activate or deactivate the device driver
– Use keywork up, down.

Ifconfig allows you to configure a interface card by
hand, but the value is only in kernel.
• To make it survive the reboot, change the right
configuration file
TCP/IP networking
1-25
Configure static routes
 Command route defines static routes
 Static route will stay in the routing table in
most case
 configure the default routing when adding a
host to local network
 Routing is performed at what layer?
• The packets’ destination IP is compared with the
route , if it matches, the packet is forwarded to the
“next gateway” IP address associated with that route
• Routing added when configure the interface - Packets
destined for host on a directory connected network
• Default route is invoked when there is no route that
matches the destination address.
TCP/IP networking
1-26
Configure static routes

The format:
• #route op [type] destination gateway [hop-count]
• Where
– Op: add, delete, get, change, flush, monitor
– Destination: host address, network address, or the
keyword “default” ( 0.0.0.0)
– Gateway: a machine to which packets should be
forwarded
» Must be on a directly connected network
» Forwarding can only be performed one hop at a time
– Type: -net, -host

Check the routing table:
• #netstat -nr
TCP/IP networking
1-27
Configure static routes

default route
• #route add default gateway_ip_address
• Change the configure file
– Solaris: /etc/defaultrouter
– Hp-UX: /net/rc.config.d/netconf
– Redhat: /etc/sysconfig/network
TCP/IP networking
1-28
Configuring DNS
 To configure a machine as a DNS client

Configure /etc/resolv.conf
• List DBS domains that should be searched to resolve
name that are incomplete
• Line the IP addresses of the name servers to contact
for name lookups
• Example:
[ruihong@dafinn ~]$ more /etc/resolv.conf
search cs.mtu.edu csl.mtu.edu mtu.edu
nameserver 141.219.152.253
nameserver 141.219.152.254
TCP/IP networking
1-29
Configuring DNS

Configure the service switch file
• Which one take effect? /etc/hosts, NIS, DNS?
• Solaris, Hp-UX, Redhat: /etc/nsswitch.conf
• Example:
hosts: files nis dns
• Clause: [NOTFOUND=return]
TCP/IP networking
1-30
Network configuration files by
system
 All


/etc/hosts
/etc/recolv.conf
 Solaris
 /etc/hostname.ifname
 /etc/nodename
 /etc/defaultrouter
 /etc/inet/netmasks
 /etc/inet/hosts
 HP-UX
 /etc/rc.config.d/netconf
 Red Hat
 /etc/sysconfig/network
 Network-scripts/ifcfg-ifname
TCP/IP networking
1-31
Practice
 Check
 IP address/netmask/broadcast
 route
 Arp table
 Hostname
 DNS
 Modify
 Hostname
 Dns research list
• Ping wopr


Dns servers
Remote default route
• Ping wopr

Add the default route back again
 Reboot
TCP/IP networking
1-32
DHCP
 Dynamic Host Configuration Protocol

Distribute network and administrative
parameters to DHCP client, include
•
•
•
•
•
IP address and netmasks
Gateways
DNS name servers
Syslog hosts
WINs Servers, X font servers, proxy servers, NTP
servers
• TFTP servers ( for loading a boot image)
• And more…
TCP/IP networking
1-33
DHCP
 How DHCP works

Client sends “Who am I” DHCPDISCOVER
message
• To broadcast 255.255.255.255
• With 0.0.0.0 as its own address
Server responds with OFFER messages
 Client sends back a REQUEST messages
 Server responds with ACK or NAK


Client renew the lease by sending another
REQUEST message
TCP/IP networking
1-34
Download