1 TCP/IP Networking. 2 TCP/IP TCP/IP is the networking protocol suite most commonly used with UNIX,...

35
1 TCP/IP Networking

Transcript of 1 TCP/IP Networking. 2 TCP/IP TCP/IP is the networking protocol suite most commonly used with UNIX,...

1

TCP/IP Networking

2

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.

3

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.

4

TCP/IP Family

5

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• ….

6

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

7

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.

8

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.

9

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.

10

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.

11

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.

12

IP Addresses

13

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.

14

Private IP Address

15

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

Subnet mask (255.255.255.0)

Subnetted address

11111111111111111111111100000000

Network number Host IDSubnet ID

16

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.

17

CIDR

• Classless Inter-Domain Routing

Border gateway(advertises path to11000000000001)

Regional network

Corporation X(11000000000001000001)

Corporation Y(11000000000001000000)

18

CIRD Examples

19

CIDR Host Address Example

20

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.

21

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.

22

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.

23

Data Forwarding Example

Forwarding table at router R1Subnet Number Subnet Mask Next Hop

128.96.34.0 255.255.255.128 interface 0

128.96.34.128 255.255.255.128 interface 1

128.96.33.0 255.255.255.0 R2

Subnet mask: 255.255.255.128Subnet number: 128.96.34.0

128.96.34.15128.96.34.1

H1 R1

128.96.34.130 Subnet mask: 255.255.255.128Subnet number: 128.96.34.128

128.96.34.129128.96.34.139

R2H2

128.96.33.1128.96.33.14

Subnet mask: 255.255.255.0Subnet number: 128.96.33.0

H3

24

Forwarding AlgorithmD = destination IP addressfor 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

25

NAT – Network Address Translation

Placement and operation of a NAT box.

26

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.

27

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.

28

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

29

Dynamic Host Configuration Protocol

Operation of DHCP.

30

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

31

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.

32

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.

33

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.

34

Domain Naming System

• Hierarchy

• Namechinstrap.cs.princeton.edu

edu com

princeton■ ■ ■ mit

cs ee

ux01ux04

physics

cisco ■ ■ ■ yahoonasa ■ ■ ■ nsf arpa ■ ■ ■ navyacm ■ ■ ■ ieee

gov mil org net uk fr

35

One Example Name Resolution

Rootnameserver

Princetonnameserver

CSnameserver

Localnameserver

1cicada.cs.princeton.edu

192.12.69.608

cicada.cs

.princeton.edu

princeton.edu, 1

28.196.128.233

cicada.cs.princeton.edu

cicada.cs.princeton.edu,

192.12.69.60

cicada.cs.princeton.edu

cs.princeton.edu, 192.12.69.5

2

3

4

5

6

7

Client

Princetonname server

Cisconame server

CSname server

EEname server

■ ■ ■

Rootname server

■ ■ ■