Chap. 5) Communication Protocols

IP Network (the Internet)

▪IP network 연결 방법: LAN, modem/PSTN, ISDN, ADSL, cable 망, satellite 등.

Introduction to Network Layer

▪Layering architecture of network S/W

- System S/W의 구조: 상위 layer는 하위 layer의 service를 사용함.

ex)

사용자

OS		DBMS		N/W S/W
command		query processor		application
system call		file manager		transport
process & file control		disk manager		network
H/W control (driver routine)		disk controller		data link

H/W

- Why?

․Abstraction: independent from underlying architecture. (가상통신 제공)

중역 A

비서 A

FAX A

중역 B

비서 B

FAX B

PSTN

계약서

가상통신

실제경로

계층 3

계층 2

계층 1

․보안성: 사용자로부터 system을 보호

․확장성: 새로운 기술을 도입시 해당 layer만 교체.

▪TCP/IP protocol suite (or just TCP/IP)

- A "family" of protocols was specified as the standard for the ARPANet and associated DoD network in the early 1980s.

- Characteristics.

․It is NOT vendor-specific.

․It has been implemented on everything from PC to the supercomputers.

․It is used for both LANs and WANs.

․It is used by many different government agencies and commercial sites, NOT just DARPA-funded networks.

- TCP/IP protocol suite: p.199 fig.5-1 참조

① TCP: a connection-oriented protocol

② UDP: a connectionless protocol

③ ICMP(Internet Control Msg. Protocol): handles error and control info. bet. gateways and host & generated by the "TCP/IP networking" S/W, NOT user processes.

④ IP(Internet Protocol): provides the packet delivery service for TCP, UDP and ICMP & user processes normally do NOT need to be involved with the IP layer.

⑤ ARP(Addr. Resolution Protocol): the protocol that maps an IP addr. into a H/W addr. (such as "Ethernet addr.")

⑥ RARP("Reverse" ARP): the protocol that maps a H/W addr. into an IP addr.

▪IP

- IP is the protocol that provides the packet delivery service for TCP and UDP.

⇒ "routing"

TCP

UDP

H/W

interface

IP

process

host

H/W

interface

H/W

interface

IP

gateway/router

H/W

interface

H/W

interface

IP

gateway/router

TCP

UDP

H/W

interface

IP

process

host

PSDN

Ethernet

Ethernet

∙각 layer의 기능

① Process layer: Services to the users.

② Transport layer: "Process-to-process" comm.

③ Network layer: Routing, congestion control, internetworking.

⇒ "Host-to-host" comm.

④ Data link layer: Error detection & correction, delivery of physical signal.

⇒ "Node-to-node" comm.	(host-to-gateway, gateway-to-gateway)

<KNUE 광케이블 구성도>

∙Network Devices

- Physical media

․wired: twisted pair, coaxial cable(baseband/broadband), optical fiber 등.

․wireless: radio, infrared, microwave(terrestrial/satellite) 등.

- L1 Device: Repeater

⇒ Amplify or regenerate "weak" signals.

⇒ Copy individual bits bet. cable segments inside a LAN. (NO "storage")

⇒ 하나의 LAN을 단순히 연장시킴.

⇒ Physical layer device

R

R

⇒ The transceiver chips can

only provide enough power     to drive 500m.

500m

1500m

- L2 Device: Bridge

⇒ Store-and-forward frames bet. same LANs.

⇒ 같은 종류의 LAN과 LAN을 연결

Bridge

Ethernet

Ethernet

Network

Data Link Physical

Physical

Physical

Network

Data Link Physical

Data Link

① A bridge "accepts" an entire frame and passes it up to the data link layer where the checksum is verified.

② Then, the frame is sent "down" to the physical layer for forwarding on a different network.

⇒ Data link layer device

- L3 Device: Router

⇒ Store-and-forward packets bet. different "networks".

⇒ 다른 종류의 network과 network을 연결

Router

Token Ring

Physical

Physical

Network

Data Link Physical

Data Link

Data Link

Network

Ethernet

Network

Data Link Physical

Router

Physical

Physical

Data Link

Data Link

Network

X.25 PSDN

① A router take incoming packets from one line and forward them on another.

② The lines may belong to different networks and use different "protocols".

⇒ Network layer device

Data Link Layer (Network Access Layer in TCP/IP)

▪The protocol in this layer provide the means to deliver frames to the other devices on a "directly attached" network.

▪다양한 physical connections

- LAN: Ethernet(CSMA/CD), FDDI(token ring), ATM 등.

- WAN: PSTN(circuit switching), PSDN(packet switching - X.25), ATM 등.

▪There are "many" network access protocols - one for each physical network standard.

⇒ As new H/W technology appear, "new" network access protocols must be developed so that TCP/IP networks can use the new H/W.

ex) ATM on optical fiber network.

▪As implemented in Unix, protocols in this layer often appear as a combination of "device drivers" and "related programs".

Network Layer (Internet Layer in TCP/IP)

▪Every IP packet contains the "source" addr. and the "dest." addr. so that each packet can be routed and delivered "independently."

⇒ Reassembling packets must be provided by the upper layer. (TCP & UDP)

ex) p.208 fig5-6, fig.5-7

- IP header format

	0		8	16		24 31
	version	head. len.	type of service	total length
	identification			flags	fragmentation offset
	time to live		protocol	header checksum
	"source addr."
	"destination addr."
	options					padding

▪A 32-bit Internet addr. encodes both a "network" ID and a "host" ID.

ex) telephone no.:	국가식별번호 - 지역번호 - 지역전화국 - 가입자번호

82 - 431 - 230 - 3786

IP addr.:	network addr. - (subnet addr.) - host addr.

▪An IP addr. on the Internet are assigned by the NIC (Network Information Center) located at SRI (Stanford Research Institute) International.

▪Four formats

ex) p. 202 fig.5-2

① Class A: 00000000. ～ 01111111. (0. ～ 127.)

for networks that have a lot of hosts on a single network.

② Class B: 10000000. ～ 10111111. (128. ～ 191.)

③ Class C: 11000000. ～ 11011111. (192. ～ 223.)

for more networks but fewer hosts per network.

④ Class D: for multicast

- a msg. is sent to a specified "group" of hosts on the network.

(broadcast - a msg. is sent to "all" hosts on the network.

unicast - a msg. is sent to "one" specific host on the network.)

▪The NIC assigns the "type" of addr. and the "network" ID to the requesting organization.

⇒ Then, the req. org. assigns individual host addr.s on that network.

ex)	공공망	KREONet (연구전산망)	- 134.75.0.0

KREN (교육망)	- 147.47.0.0

상용망	KORNet (한국통신)	- 147.6.0.0

ex)	1.2.255.4	→ 01.02.FF.04

→ 00000001 00000010 ～

class A, net. ID=1 (1.0.0.0)

128.3.0.5	→ 80.03.00.05

→ 10000000 00000011 ～

class B,  net. ID=3 (128.3.0.0)

134.75.204.2	→ 86.4B.CC.02

→ 10000110 01001011 ～

class B,  net. ID=1611 (134.75.0.0)

▪Subnet addr.

- Subnetwork: Any organization can "subdivide" the available host addr. space in anyway it desires.

ex) An org. has a class B addr. and 150 hosts.

Case 1: Allocate host IDs of 1 through 150 using all 16-bits.

⇒ All the gateway in the org. must know where each "individual" host is located for routing.

⇒ Adding a "new" host requires that each gateway's routing table be "updated".

10       net ID             host ID

Case 2: Allocate "some" of the high-order bits, say 8 bits, for the subnetwork and the remaining 8 bits for the individual hosts on each subnetwork.

⇒ Gateways in the org. only need to know the subnetwork ID.

(network/subnetwork ID를 사용하여 routing함)

⇒ Adding a new “host” on an existing subnetwork does NOT require any changes. (Adding a new “subnetwork” requires the change of routing tables)

10       net ID       subnet ID   host ID

- A subnet is defined by applying the "subnet mask" to the IP addr.

⇒	If a bit is on, that bit is interpreted as a "network" bit.

If a bit is off, that bit belongs to the "host" part of the addr.

0		15	16 31
1	0	network ID	host ID

ex) class B addr.

255.     255.        255.        0.       ; subnet mask

network ID    subnet ID    host ID

ex)

① IP addr.  (class B)	128. 66. 12.  1

subnet mask	255.255.255.  0

⇒ host 1 on the subnet 128.66.12.0

② IP addr.  (class B)	130. 97. 16.132

10000100

subnet mask	255.255.255.192

11000000

⇒ host 4 on the subnet 130.97.16.128

③ IP addr.  (class C)	192.178. 16. 66

01000010

subnet mask	255.255.255.192

11000000

⇒ host 2 on the subnet 192.178. 16. 64

⇒ max. subnet 개수 = 4 (00, 01, 10, 11)

▪관련 system file들

- /etc/networks: network들과 subnetwork들이 define되어 있음.

ex)	134.75.91.0 ～ 134.75.109.0	; for SERI subnet in KREONet

134.75.110.0 ～ 134.75.119.0	; for KIST subnet in KREONet

134.75.204.0	; for KNUE subnet in KREONet

147.47.0.0	; KREN

- /etc/netmasks: subnet mask가 define되어 있음.

ex)	134.75	255.255.255.0

- /etc/hosts: Domain name들이 저장되어 있음.

ex)	127.0.0.1	localhost

134.75.204.1	router.knue.ac.kr	router

134.75.204.2	cc.knue.ac.kr	cc

203.247.208.60	comedu.knue.ac.kr	comedu

▪Routing in the IP network

Ex) Mail System: 각 우체국에서 목적지 주소를 보고 “다음 해당” 우체국으로 넘김. (host-subnet-network-…-network-subnet-host)

대전 중앙

청주 중앙

교원대

가경동

건물

우체통

우체통

To: 서울시 서대문구

신촌 33-5

서울 중앙

신사동

신촌

압구정

건물

우체통

서울시 서대문구

신촌 33-5

- Total network consists of "co-equal" collections of routing domains.

⇒ (sub)networks

Network Gateway

Subnet.

Gateway

H1

H2

Hn

…

Subnet.

Gateway

H1

H2

Hn

…

……

Network Gateway

Subnet.

Gateway

H1

H2

Hn

…

Subnet.

Gateway

H1

H2

Hn

…

……

Network Gateway

Subnet.

Gateway

H1

H2

Hn

…

Subnet.

Gateway

H1

H2

Hn

…

……

Case 1: To the host on the same subnetwork

Case 2: To the host on the same nework

Case 3: To the host on the other network

⇒ No central controller.

- IP Network: Gateway/Router에 있는 "routing table"을 참조.

⇒ 각 Gateway/Router에서 dest. addr.를 보고 “다음 해당” Gateway/Router로 넘김.

R

R

G

G

G

G

G

G

R

R

R

R

KNUE

충북대

KREN

(KORNet)

NSFNet

U. C. at

Berkeley

U. C. at

L. A.

210.93.99.64

211.34.193.6

KREONet

G

BITNet

G

- Gateways extract the network ID field

⇒ Route packets based solely on the "network" ID.

⇒ Gateways need only to know the location of other "networks" NOT individual hosts.

subnet 1 (subnet ID=128.66.12.0)

subnet 2

(subnet ID=

128.66.1.0)

G1-1

G1-2

128.66.12.3

128.66.1.5

H3

128.66.1.2

H1

128.66.12.2

H2

128.66.12.4

G1

128.66.12.1

G2

26.104.0.19

network ID = 128.66.0.0 (subnet mask=255.255.255.0)

network ID = 26.0.0.0

ex)

H1's routing table

"인접한 routing domain들만 specify"

* display the routing table in Unix

# netstat -nr

* localhost

/usr/include/netinet/in.h에 다음과 같이 define되어 있음.

# define INADDR_LOOPBACK (u_long) 0x7F000001

Destination	Gateway
127.0.0.1 128.66.1.0 128.66.12.0 default	127.0.0.1 128.66.12.3 128.66.12.2 128.66.12.1	localhost로 (자기 자신) subnet 2로 subnet 1로 (자신의 subnet⇒자신이 deliver) other network으로

- Routing decision for a host

① If the dest. host is on the "local" network, the packet is delivered to the "dest. host" directly.

② If the dest. host is on the "remote" network, the packet is forwarded to a "local gateway".

⇒ Because routing is network-oriented, IP makes routing decisions based on the "network portion" of the IP addr.

⇒ Subnet Mask

ex) packet delivery: H1 → H3 (128. 66.  1.  2),

s.m.=255.255.255.  0

H3 (128.66.1.2)			G1-2 (128.66.1.5)
Destination	Gateway		Destination	Gateway
128.66.1.0 default	128.66.1.2 128.66.1.5		128.66.1.0 default	128.66.1.5 128.66.12.3

H1 (128.66.12.2)			G1-1 (128.66.12.3)
Destination	Gateway		Destination	Gateway
128.66.1.0 128.66.12.0 default	128.66.12.3 128.66.12.2 128.66.12.1		128.66.1.0 128.66.12.0 default	128.66.1.5 128.66.12.3 128.66.12.1

If H1 sends packets to H3 (128.66.1.2)

① H1 determines 128.66.1.2 is the local network's class B addr. and applies a subnet mask (255.255.255.0).

⇒ IP knows that the dest. network addr. is 128.66.1.0

⇒ The routing table shows that data bound for 128.66.1.0 should be sent to gateway 128.66.12.3

② Gateway 128.66.12.3 deliver data to gateway 128.66.1.5

③ Gateway 128.66.1.5 makes direct delivery to H3.

⇒ The routing tables in all systems list only gateways they are "directly connected" to.

⇒ A route only points to the "next" gateway, called the next hop.

▪Routing table

ex)	comedu# netstat -nr

Routing Table:

Destination           Gateway      Flags  Ref   Use   Interface

------------ -------------- ----- ---- ----- ---------

127.0.0.1	127.0.0.1             UH	0   25246	lo0

203.247.208.0	203.247.208.60        U	1   17329	le0

224.0.0.0	203.247.208.60        U	1       0	le0

default	203.247.208.2         UG   1  177829

Flags:	U - The route is Up and operational.

H - This is a route to a specific "host". (NOT "networks")

G - The route uses a "gateway".

Refcnt:	The current number  of  routes  that “share” the same data link layer addr. (현재, "같은" data link layer addr. - 예: Ethernet addr. - 를 공유하고 있는 route 개수)

Use:	No. of "packets" transmitted via this route.

Interface:	The name of the "network interface" used by this route.

⇒ the network access H/W and S/W that IP uses to communicate with the physical network.

⇒ lo0  : loopback route for local host

le0  : 10BaseT

hme0: 10/100Mbps Fast Ethernet

lane0: ATM

- Data link layer addr.

․Physical networks have their "own" addressing schems.

⇒ One task of data link layer (network access layer in TCP/IP) is to map IP addr.'s to physical network addr.'s

IP addr.

D.L. addr.

TCP

UDP

H/W

interface

IP

process

host

H/W

interface

H/W

interface

IP

gateway/router

PSDN

Ethernet

ARP

RARP

․ARP: The translation of IP addr.s to Ethernet addr.s

․The ARP S/W maintains a table of translations bet. IP addr.s and Ethernet addr.s

ex) Displaying the contents of the ARP table

comedu# /usr/sbin/arp -a

Net to Media Table

Device   IP Address               Mask	Flags   Phys Addr

------ --------------- --------------- ----- --------------

le0    203.247.208.153	255.255.255.255	00:00:e8:d3:8d:37

le0    203.247.208.155	255.255.255.255	00:00:e8:d2:38:d6

le0    203.247.208.156	255.255.255.255	00:00:e8:d3:7e:40

le0    comedudb.knue.ac.kr	255.255.255.255	08:00:20:8c:a8:97

…	…	…	…

le0    203.247.208.45	255.255.255.255	00:50:4d:00:a6:73

le0    comedu.knue.ac.kr	255.255.255.255	SP	08:00:20:74:e6:c5

le0    mathoff.knue.ac.kr	255.255.255.255	00:e0:1a:00:03:a6

le0    BASE-ADDRESS.MCAST.NET 240.0.0.0     SM	01:00:5e:00:00:00

▪How to build a routing table?

- 세가지 routing 구성 방법

① Minimal routing

․A network completely "isolated" from all other TCP/IP networks.

ex) A TCP/IP LAN NOT to have access to the outside world.

⇒ Built by the "ifconfig" command.

② Static routing

․A network with a "limited" no. of gateways to other TCP/IP networks.

⇒ Constructed "manually" by the "route" command.

․"Static" routing tables do NOT "adjust" to network changes.

⇒ They should be used only where routes do NOT change.

․When remote dest.s can only be reached through "one" route, a static route is the "best" choice. (한가지 길 밖에 없을 경우)

③ Dynamic routing

․A network with "more than one" possible route to the "same" dest.

․A dynamic routing table is built from the info. exchanged by routing protocols.

⇒ "methods" + "programs" that exchange the info. on the network.

⇒ dynamically adjusts routes to "reflect" changing network conditions.

․Routing protocols are designed,

- To switch to a "backup route" when the primary	route becomes "inoperable"

- To decide which is the "best" route to a dest.

G

G

G

G

G

G

IGP

EGP

IGP

(Sub)Network 1

(Sub)Network 2

G

․Two types

- Interior Gateway Protocol (IGP): Internal Routing Protocol in 'ONE' autonomous system, i.e., Local Network.

⇒ Network 내부의 Dynamic routing

Ex) RIP, IGRP, EIGP, OSPF

- Exterior Gateway Protocol (EGP): Routing Protocol between autonomous systems

⇒ Network간의 Dynamic routing

⇒ Many ISPs(Internet Service Providers) use it.

Ex) BGP

- Building a static routing table

① minimal routing 작성

ex) H1's routing table

H1# netstat -nr

Routing Table:

Destination           Gateway      Flags  Ref   Use   Interface

------------ -------------- ----- ---- ----- ---------

127.0.0.1	127.0.0.1             UH	0   25246	lo0

128.66.12.0	128.66.12.2	U	3   17329	le0

② "Manually" add or delete entries in the routing table.

⇒ use the "route" command

ex)	H1# route -n add  26.0.0.0  128.66.12.1  1

Display numeric addr.s

in its info. msgs.

(or delete) (directly  (gateway) (metric

connected	0: 자기자신을 gateway로 설정.

network)	⇒ G flag is NOT set.

add net 26.0.0.0 128.66.12.1	1: 다른 host를 gateway로 설정.

⇒ G flag is set.)

ex) Configuring static routing for "H1" on the subnet 128.66.12.0

subnet

128.66.12.0

H1

128.66.12.2

G1-1

128.66.12.3

Other local subnets

128.66.1.0

128.66.3.0

128.66.6.0

128.66.9.0

G1-2

128.66.12.1

Other network

26.0.0.0

H1#	route  -n  add  default  128.66.12.1  1

add net default: gateway 128.66.12.1	; output msg.

H1# netstat -nr

Routing Table:

Destination           Gateway      Flags  Ref   Use   Interface

------------ -------------- ----- ---- ----- ---------

127.0.0.1	127.0.0.1             UH	0   25246	lo0

128.66.12.0	128.66.12.2	U	3   17329	le0

default	128.66.12.1	UG	0	0	le0

H1# ping 26.40.0.17

～ successful comm. with the remote host ～

H1# ping 128.66.1.2

～ ping failed (the ICMP redirect msg.) ～

H1#	route  -n  add  128.66.1.0  128.66.12.3  1

H1#	route  -n  add  128.66.3.0  128.66.12.3  1

H1#	route  -n  add  128.66.6.0  128.66.12.3  1

H1#	route  -n  add  128.66.9.0  128.66.12.3  1

⇒ Finishing the routing table.

③ If any subnets are added to the network, the routes to these new subnets must be "manually added" to the routing table.

⇒ If the system is "rebooted", all static routing table entries are "lost".

Thus, the routes are "re-installed" each time your system boots.

④ Installing static routes at "start-up".

․2 modifications to start-up files

⇒ Add the desired "route" commands to a start-up file.

Remove any commands from the start-up file that run a "dynamic"     routing protocol.

ex) In BSD Unix,

․Edit the "rc.local" file

route -n	add	default	128.66.12.1 1 > /dev/console

route -n	add	128.66.1.0	128.66.12.3 1 > /dev/console

route -n	add  128.66.3.0 128.66.12.3 1 > /dev/console

route -n	add  128.66.6.0 128.66.12.3 1 > /dev/console

route -n	add  128.66.9.0 128.66.12.3 1 > /dev/console

․Comment out the lines that start the "dynamic" routing protocol.

⇒ Often, start-up procedures run routing protocols by "default".

⇒	Routing protocols are "flexible" enough to handle simple and complex routing environments.

ex)	find	sometimes routed instead of in.routed

# if [-f /usr/etc/in.routed ]; then

#   in.routed;

#   echo -n 'routed' > /dev/console

# fi

⇒ The routing daemon (routed) dynamically builds the routing table based on network info.