TCP/IP Networking - Lamar University

Download Report

Transcript TCP/IP Networking - Lamar University

TCP/IP Networking
1
TCP/IP
• TCP/IP is the networking protocol suite most
commonly used with UNIX, Windows, NT and most
other OS’s. TCP/IP defines a uniform programming
interface to different types of networking hardware,
guaranteeing that systems can exchange data despite
their differences
• The technical success of the internet is due largely to
the elegant and flexible design of TCP/IP.
2
TCP/IP Protocol Suite
• TCP/IP is a protocol suite consisting of several
components:
– IP - Internet protocol that routes data packets from one
machine to another
– ICMP - Internet Control Message Protocol, which provides
low level support for IP, such as error messages, routing
assistance and debugging help.
– ARP - Address Resolution Protocol, which translates IP
addresses to hardware addresses
– TCP and UDP - Transmission Control Protocol and User
Datagram Protocol, which deliver data to specific
applications on the destination machine.
3
TCP/IP Family
4
Request for Comment (RFC)
•
•
•
•
•
•
•
•
IP : RFC 791
ICMP: RFC 792
ARP: RFC 832
UDP: RFC 768
TCP: RFC 793
CIDR: RFC 1519
DHCP: RFC 2131
….
5
Packet Addressing
• Network packets must be properly addressed
to reach their destination. Several addressing
schemes are used:
– MAC addresses for hardware: MAC addresses
distinguishes it from other machines on the
physical network
– IP addresses for software: IP address identifies it
on the global network
– Hostnames for people: this is for the benefit of
humans
6
MAC Addresses
• Every Ethernet card has built into it a 48 bit address
(Ethernet address or Media Access Control (MAC)
address). The high 24 bits of the address are used to
assign a unique number to manufactures of Ethernet
addresses and the low 24 bits are assigned to the
individual Ethernet cards made by the manufacturer.
• Every packet of information sent on the Ethernet
contains a source and destination MAC address.
7
Hostnames
• Most computers on a TCP/IP network are
given a name. A fully qualified name, (fully
qualified domain name) uses the format:
– hostname.site.domain.country
• Qualified hostnames give the full path and is
unique to the entire Internet.
8
IP Addresses
• Computers and other equipment involved in TCP/IP
networks use numbers to identify hosts on the
Internet. These are called IP (Internet Protocol)
addresses. IP addresses are currently 32 bit numbers
(4 bytes long).
• An IP address consists of two parts, a network portion
and a host portion. The network portion identifies the
network the machine belongs to and the host portion
uniquely identifies the host on that particular
network.
9
Network Classes
• There are several classes of IP addresses, in
that they differ in the way that bytes are
allocated between the host and network part.
10
IP Addresses
• The size of the network and host portions of an IP
address is specified by another 32 bit number called
the netmask (also known as the subnet mask).
• To calculate which part of an IP address is the
network and which the host the IP address and the
subnet mask are treated as binary numbers. Each bit
of the subnet mask and the IP address are compared
and
– if the bit is set in both the IP address and the subnet mask
then the bit is set in the network address,
– if the bit is set in the IP address but not set in the subnet
mask then the bit is set in the host address.
11
IP Addresses
12
IP Addresses
• Assigning IP Addresses:
– Some IP addresses are reserved for specific purposes and
these should not be assigned to machines.
• Network addresses : By convention, the network address is the IP
address with the host address that is all 0’s. The network address is
used to identify a network.
• Broadcast address: This is the network address with the host
address set to all 1’s, and is used to send information to all the
computers on a network, typically for routing.
• Loopback address: 127.0.0.1 is a special address that refers to the
local host. This allows software to address the local machine
exactly the same way it would a remote machine.
13
Private IP Address
14
Subnetting
• Add another level to address/routing hierarchy:
subnet
• Subnet masks define variable partition of host part
• Subnets visible only within site
Network number
Host number
Class B address
111111111111111111111111
00000000
Subnet mask (255.255.255.0)
Network number
Subnet ID
Subnetted address
Host ID
15
Subsets
• The division between network part and host
part does not necessarily have to fall on a byte
boundary. However, the network part must be
contiguous and appear at the high order end of
the address.
16
CIDR
• Classless Inter-Domain Routing
Corporation X
(11000000000001000001)
Border gateway
(advertises path to
11000000000001)
Regional network
Corporation Y
(11000000000001000000)
17
CIRD Examples
18
CIDR Host Address Example
19
Routing
• Routing is the act of deciding how each individual
datagram finds its way through the multiple different
paths to its destination.
• Routing is concerned with finding the right network
for a datagram. Once the right network has been
found the datagram can be delivered to the host.
• Most hosts (and gateways) on the Internet maintain a
routing table. The entries in the routing table contain
the information describing where to send datagrams
for a particular network.
20
Routing Table
• The routing table can be constructed in one of two
ways:
– constructed by the Systems Administrator, sometimes
referred to as static routes
– dynamically created by a number of different available
routing protocols
• A static route is entered using the route command.
– route add -net 132.236.220.64 -netmask 255.255.255.192
gw 132.236.212.6 eth1
– route add default gw 132.236.227.1 eth0
• Dynamic routing is performed by a daemon process
that maintains and modifies the routing table.
21
Routing Tables
• You can check your routing table with the
netstat -r –n command.
• The destination field is usually a network
address, the gateway must be a host address. A
default route is used for packets not explicitly
addressed to any of the three networks listed or
to the machine itself.
22
Data Forwarding Example
Subnet mask: 255.255.255.128
Subnet number: 128.96.34.0
128.96.34.15
128.96.34.1
R1
H1
Subnet mask: 255.255.255.128
Subnet number: 128.96.34.128
128.96.34.130
128.96.34.139
128.96.34.129
H3
R2
H2
128.96.33.1
128.96.33.14
Subnet mask: 255.255.255.0
Subnet number: 128.96.33.0
Forwarding table at router R1
Subnet Number
128.96.34.0
128.96.34.128
128.96.33.0
Subnet Mask
255.255.255.128
255.255.255.128
255.255.255.0
Next Hop
interface 0
interface 1
R2
23
Forwarding Algorithm
D = destination IP address
for each entry (SubnetNum, SubnetMask, NextHop)
D1 = SubnetMask & D
if D1 = SubnetNum
if NextHop is an interface
deliver datagram directly to D
else
deliver datagram to NextHop
• Use a default router if nothing matches
• Not necessary for all 1s in subnet mask to be
contiguous
• Can put multiple subnets on one physical network
• Subnets not visible from the rest of the Internet
24
NAT – Network Address Translation
Placement and operation of a NAT box.
25
Address Resolution Protocol
• The mapping of Ethernet addresses into Internet
addresses is performed by the Address Resolution
Protocol (ARP). This is done with the help of a table
of MAC addresses against the IP addresses.
• The ARP only contains Ethernet addresses of
machines on the local network. Delivery of
information to machines not on the local network
requires the intervention of routing software.
26
Address Resolution Protocol
• If host A wants to send a packet to host B on the
same network, it uses ARP to discover B’s hardware
address. If B is not on the same network, host A uses
ARP to find the hardware address of the next-hop
router to which a packet destined for B should be
sent.
• Every machine maintains a table in memory called
the ARP cache, which contains the result of recent
ARP queries.
• arp -a displays the contents of the arp cache.
27
Dynamic Host Configuration Protocol
• This protocol enables a DHCP client to ‘lease’
a variety of network and administrative
parameters from a central server that is
authorized to distribute them.
– IP addresses and netmasks
– Gateways (default routes)
– DNS name servers
28
Dynamic Host Configuration Protocol
Operation of DHCP.
29
Adding a Machine to a Network
• In order to add a machine to a network, you
would have to:
– assign an IP address and a hostname
– Set up the new host to configure its network
interfaces at boot time
– Set up a default route
– Point to a DNS server, to allow access to the rest
of the Internet
30
Assigning Host Names and Addresses
• This can be done in various ways. The /etc/hosts file
is the oldest and simplest way to map names to IP
addresses. /etc/hosts is important during the boot
process because DNS is not available yet. It must
contain at least the the mapping for the host and the
loopback address.
• The hostname command assigns a hostname to a
machine.
• You could also have DNS and NIS and NIS+ or even
a combination of all these to assign host names and IP
addresses.
31
Configuring Network Interfaces
• The ifconfig command enables or disables a network
interface, sets its IP address and subnet mask, and sets
various other options and parameters. It is usually run
at boot time, but it can make changes on the fly too.
– ifconfig interface address options….. up
– ifconfig eth0 129.7.160.152 netmask 255.255.240.0 up
• Then the default route should be set with the route
command.
32
DNS
• The process of taking a hostname and finding the IP
address is called name resolution. This can be done in
two ways:
– /etc/host file
– Domain Name Service
• The Domain Name database coordinates a look up of
a computer name and finds the corresponding Internet
number. This is done by a set of name servers that
keep track of computer names and the corresponding
Internet addresses. These servers have the ability to
store and report more than just the computer name.
33
Domain Naming System
• Hierarchy
edu
princeton
cs
■■■
com
mit
cisco
■■■
gov
yahoonasa
■■■
mil
nsf arpa
■■■
org
navy acm
■■■
net
uk
fr
ieee
ee physics
ux01 ux04
• Name
chinstrap.cs.princeton.edu
34
One Example Name Resolution
Root
name server
2
n
e to
ad
cic
Princeton
name server
■■■
Cisco
name server
1
cicada.cs.princeton.edu
Client
192.12.69.60
8
CS
name server
■■■
EE
name server
Local
name
server
a.
nc
pri
cs.
1
u,
.e d
.ed
.1 9
28
u
Root
name
server
33
8 .2
2
1
3
6.
n
e to
4
nc
i
r
p
cicada.cs.princeton.edu
Princeton
name
cs.princeton.edu, 192.12.69.5 server
5
cic
ad
a.c
cic
s. p
19 ada
rin
2.1 .cs
ce
2 .6 .p r
to n
9.6 inc
.ed 6
0 e to
u
n .e
du
,
CS
name
7
server
35