Sie sind auf Seite 1von 52

TCP/IP Basics

Objectives

Upon completion of this course, you will be able to:


Know about TCP/IP protocol suite Be familiar with commonly used IP network devices

Contents

OSI Model and Layer Function TCP/IP Protocol Suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

Post System

Jim

N.Y.

Pekin

Tom

Post network

To Jim

Post code

stamp

Destination address

TCP/IP
Host A Host B

Internet
TCP/IP

First used protocol suite Universal De-facto standard

Internet standard communication

OSI Model
Application Upper layer Presentation session

Layer7 Layer6 Layer5

Layer4 Layer3 Layer2 Layer1

Transport Network Data layer Data link Physical

Upper Layer Function


Example

Application

Network User Interface

Telnet FTP ASCII EBCDIC JPEG Authentication

Presentation

Present data Encryption, decryption Keep different applications independent

Session

Data Layer Function


Example
Transport
Reliable and Unreliable transfer Use retransmission to ensure reliability Provide logical address and path-finding method for the working of routers Combine bit to byte and byte to frame Access media by MAC address Error detection without error correction Transfer bit between devices Define voltage, bit rate, physical connection

TCP UDP SPX IP IPX 802.3 / 802.2 HDLC EIA/TIA-232 V.35

Network

Data Link

Physical

Data Encapsulation
Application Presentation Upper Layer Data TCP Header Upper Layer Data Session

PDU
Segment

Transport

IP Header

Upper Layer Data

Network

Packet

MAC+LLC Header

Upper Layer Data FCS

Data Link

Frame

0101110101001000010

Physical

Bits

Data Decapsulation
Application Presentation Session

Upper Layer Data

Transport

Upper Layer Data

Network

TCP+ Upper Layer Data

Data Link

IP + TCP + Upper Layer Data

Physical

0101110101001000010

Contents

OSI model and layer function TCP/IP protocol suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

TCP/IP Model vs OSI Model

Application Presentation Session Transport Network Application Transport Internet

Data Link
Data Link Physical

TCP/IP Protocol Suite


F T T E P L N E T
Application
Transport Internet Data Link

S M T P

D N S

T F T P

S N M P

21

23 TCP 6

25 53 69 Application
UDP

161

17

ARP
0806 0800

IP

Data Link

ICMP

Ethernet II (RFC 894 )

Contents

OSI model and layer function TCP/IP protocol suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

Transport Layer

Segment upper layer data Establish end to end connection Ensure the reliability of data transfer

Logical connection

TCP Protocol
Bit 0 Bit 15 Bit 16 Bit 31

Source port (16)

Destination port (16)

Sequence number (32)

Acknowledgement number (32)


Header length (4)

20 Bytes

Reserved (6) Code bits (6) Checksum (16)

Window (16) Urgent (16)

Options (0 or 32 if any) Data (varies)

Port Number Range


F T T E P L N E T
21 23 TCP

S M T P

D N S

T F T P

S N M P

Application Application Transport Transport Internet Data Link

25 53 69 Application
UDP

161

well-known port number :1-1023 common port number: 1024-65535

Port Number Function

Source Port Number

Destination Port Number Destination port = 23 Send packet to my Telnet application

Telnet Z Process #1 client Telnet Z Process #2

server

Port multiplexing
SP 1028 1029 23 DP 23

Sequence and Ack Number

Sender

Receiver

Send 1 Send 2 Send 3 Ack 4

Send 4 Send 5 Send 6


Retransfer 5 Send 5 Ack 7

Code Bits
U R G

A C K

P
S H

R
S T

S
Y N

F
I N

URG: Urgent Pointer field significant ACK: Acknowledgment field significant PSH: Push function RST: Reset the connection SYN: Synchronize sequence numbers FIN: No more data from sender

Window Control
Window size = 1 Send 1

Receive 1 Ack 2 Receive 2 Ack 3

Send 2
Sender

Receiver

Window size = 3 Send 1 Send 2 Send 3


Sender

Receive 1 Receive 2
Receive 3 Ack 4
Receiver

Send 4

Connection-oriented Session

TCP connection
Sender Receiver

Establish connection (synchronize)

1
Data transfer (Send Segments)

Tear down connection


3

Establish Connection

TCP Three Way Handshake/Open Connection


Host A Host B

Send SYN (seq=100 ctl=SYN) SYN received Established (seq=101 ack=301 ctl=ACK)

1 2 3

SYN received Send SYN, ACK (seq=300 ack=101 ctl=SYN,ACK)

Established

Data Transfer

SP

DP

Seq. #

Ack. #

Upper layer data

Host A

Host B

Source Dest. Seq. Ack. 1028 23 102 301 Source Dest. Seq. Ack. 23 1028 301 103 Source Dest. Seq. Ack. 1028 23 103 302 Source Dest. Seq. Ack. 23 1028 302 104

Tear Down Connection

TCP four way handshakes/connection terminating


Host A Close application Host B

FIN

ACK to FIN
FIN ACK to FIN

2 3 Close application

UDP Protocol
Bit 0 Source port (16) Length (16) Data (if any) Bit 15 Bit 16 Destination port (16) Checksum (16) Bit 31 8 Bytes

No sequence and acknowledgement Unreliable and connectionless Efficient and fast

TCP/UDP Comparison

TCP
Connection oriented Or connectionless Reliable or not With traffic Control Or not Transfer speed

UDP connectionless unreliable

Connection oriented Reliable

Traffic control
Slow

No traffic control
Fast

overhead of protocol

Big

Small

Contents

OSI model and layer function TCP/IP protocol suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

Internet/Network Layer

Define logical address Provide path-finding method routers


Application Transport Internet Data Link

TCP 6 ARP IP

UDP

17
Data Link

ICMP

IP Packet Format
Bit 1 0
Version (4) Header Length (4)

Bit 15 Bit 16 Type of Service (8) Flags (3) Total Length (16)

Bit 31

Identification (16)
Time to live (8) Protocol (8)

Fragment offset (13)


Header checksum (16)

20 Bytes

Source IP Address (32) Destination IP Address (32) Options (0 or 32 if any) Upper layer data (varies if any)

Type of Service Field

precedence

Bits 0-2: Precedence Bit 3: Delay Bit 4: Throughput Bit 5: Reliability Bits 6-7: Reserved for future use

MTU and Fragmentation


0
Identification (16)

15 16 17 18
D M 0 F F

Fragment offset (13)

Flags(3)
Bit 16: Reserved, must be zero Bit 17: (DF)0=May fragment, 1=Dont fragment

Bit 18: (MF)0=Last fragment, 1=More fragment


Host A

Host B

RA MTU 1000

RB

Ethernet

IP(1500)

HDLC HDLC

IP(750) IP(750)

Ethernet Ethernet

IP(750) IP(750)

IP Address
Host A Fei_1/1 Fei_1/2 Host B

172.16.2.1

172.16.2.1

10.6.24.2

10.250.8.11

0
Dotted Decimal Maximum

7 8

15 16

23 24

31

Network

Host

255

255

255

255

Binary

11111111 11111111
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1

11111111 11111111
128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1

Internet Control Message Protocol

Application Transport Internet Data Link

IP

Data Link

ICMP

PING and Reachability

Hi B, Host A are you there?


ICMP echo reply

Host B

I am here.

ICMP echo request no

Is B reachable?

yes

Destination Unreachable

ICMP echo request

Host or port unreachable Network unreachable

Time Exceeded and TTL


A: Tracert 10.1.1.2

1: 172.16.1.1
2: 200.1.1.2
Host A

3: 10.1.1.2
172.16.1.1 200.1.1.1 200.1.1.2 10.1.1.1

Host B

172.16.1.2
RA RB

10.1.1.2

TTL=1 TTL=2 TTL=3

Contents

OSI model and layer function TCP/IP protocol suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

Data Link Layer



Application
Transport Internet Data Link

Combine bit to byte and byte to frame Access media by physical address (MAC address) SAP associated with upper layer protocols type Error detection without error correction

ARP
0806 0800

IP

Data Link

ICMP

Ethernet II (RFC 894 )

48-bits MAC Address


Ethernet II frame (RFC 894)
# Bytes 8
Preamble

6 Dest. Addr

6 Src. Addr

2 Type

Variable Length 46-1500 Data

4 FCS

00.d0.d0
IEEE assign to Manufacturers

xx.xx.xx
Sequence ID for NIC

Address Resolution Protocol

I need the MAC address of IP 172.16.3.2

Host A

Host B

I got the packet, I will reply with my MAC address.

172.16.3.1

172.16.3.2

Other hosts

IP: 172.16.3.2 = ??? IP: 172.16.3.2 Ethernet: 0800.0020.1111

Map IP to MAC Local broadcast

Packet Process Procedure


FTP client FTP server

ftp://10.66.1.100:21 I wanna download a file SP:1024 DP:21 Seq.100 Ack.200 SIP:10.66.1.1 DIP:10.66.1.100,TTL=100, DF, Protocol=7 SA:01-00-39 DA:01-00-4A type=0800 01010010100010101010101010100010110111000101001

Contents

OSI model and layer function TCP/IP protocol suite Transfer Control Protocol Internet Protocol Address Resolution Protocol IP Network Equipment

Hub Work in Physical Layer


Signal !!

- Forward signal to all ports except receive port - Interconnect hosts in same network
0101101 0101101 0101101

PC1

PC2

PC3

Switch Work in Data Link Layer


MAC
MAC1 MAC2

Out 1 2

MAC2 IP DATA

MAC2 IP DATA

- Forward data according to MAC address - Interconnect hosts in same network

1.1.1.1 MAC1

1.1.1.2
MAC2

1.1.1.3
MAC3

Difference between Hub and Switch


100M 10 ports hub
bandwidth 100M

100M 10 ports switch


bandwidth>100M*10*2

More people more slowly

So many people! But it does not matter

Router Work in Network Layer


NET
1.0.0.0 2.0.0.0

OUT
fei_1/1 fei_1/2
fei_1/2 :2.2.2.254 MAC3

- forward according to
destination IP address - interconnect hosts in different network - collect routing informationOSPF BGP

fei_1/1 :1.1.1.254 MAC3

MAC3 2.2.2.2 data

MAC2 2.2.2.2 data

1.1.1.1 G: 1.1.1.254 MAC1

2.2.2.2 G:2.2.2.254 MAC2

Routing Switch
Router
Im a switch? Im a router? Interface fei_1/1 ip add 1.1.1.254 255.255.255.0

RS

Interface vlan10 ip add 1.1.1.254 255.255.255.0

switch

1.1.1.1/24 G:1.1.1.254

1.1.1.2/24 G:1.1.1.254

1.1.1.1/24 G:1.1.1.254

1.1.1.2/24 G:1.1.1.254

Routing Switch Working Mode Switching


vlan10:1.1.1.254 MAC4 vlan20:2.2.2.254

MAC4

MAC OUT MAC4 vlan10 MAC4 vlan20 MAC1 P1

MAC2 1.1.1.2 data MAC2 1.1.1.2 data

1.1.1.1 G: 1.1.1.254 MAC1

1.1.1.2 G: 1.1.1.254 MAC2

2.2.2.2 G:2.2.2.254 MAC3

The received frames destination MAC address is different from RSs MAC address , switching

Routing Switch Working Mode Routing


vlan10:1.1.1.254 MAC4 vlan20:2.2.2.254 MAC4 MAC table
MAC INT MAC4 vlan10 MAC4 vlan20

Hardware forwarding table


MAC4 2.2.2.2 data
MAC3 2.2.2.2 data DIP OUT 2.2.2.2 P3

Route table
NET
2.0.0.0

1.1.1.1 G: 1.1.1.254 MAC1

1.1.1.2 G: 1.1.1.254 MAC2

2.2.2.2 G:2.2.2.254 MAC3

1.0.0.0

Out vlan20 vlan10

routing once, switching for several times

Comparison: Router and Routing Switch

Router
CPU + NP Less ports, costly Applicable to network export

Routing Switch
CPU + ASIC (Application Specific Integrated Circuit) More ports, high cost performance Applicable to exchange data in large LAN, routing capability is not as good as the same level router

Summarization

OSI reference model TCP protocol suite Transport layer Network layer Data link layer IP network equipment

Das könnte Ihnen auch gefallen