+ All Categories
Home > Documents > Review of TCP/IP

Review of TCP/IP

Date post: 06-Jan-2016
Category:
Upload: halen
View: 50 times
Download: 1 times
Share this document with a friend
Description:
Review of TCP/IP. TCP/IP. Four layer Architecture Developed in 1960’s Open System Not just one protocol, whole family. Many programming interfaces available. Standardised protocol set. IP Addressing Scheme. Need capability of mapping addresses of one type onto another. - PowerPoint PPT Presentation
Popular Tags:
34
Review of TCP/IP Review of TCP/IP
Transcript
Page 1: Review of TCP/IP

Review of TCP/IPReview of TCP/IP

Page 2: Review of TCP/IP

TCP/IPTCP/IP• Four layer Architecture

• Developed in 1960’s

• Open System

• Not just one protocol, whole family.

• Many programming interfaces available.

• Standardised protocol set.

Page 3: Review of TCP/IP

IP Addressing Scheme

• Need capability of mapping addresses of one type onto another.

• LAN address, Network Point of Attachment NPA, must be mapped onto an IP address.

• NPA formats differ from one LAN standard to another.

• IP addresses are homogenous within single IP version.

Page 4: Review of TCP/IP

IP Address Format

netid hostid0

netid hostid10

netid hostid110

Multicast group ID1110

Class A

Class B

Class C

Class D

7 bits 24 bits

14 bits 16 bits

21 bits 8 bits

28 bits

Page 5: Review of TCP/IP

IP Address Format (cont.)

• Different size networks may use different address classes, defined by the first few bits in the address. 0 for Class A, 10 for Class B, 110 for Class C, etc. etc.

• Networks with large numbers of hosts may use Class A, while Class C may have many subnets with a small number of attached hosts.

Page 6: Review of TCP/IP

IP Address Notation

• A decimal dot notation is used to break down the IP address.

• Example– 10001000 11001110 00001011 00000110 – gives the address 136.206.11.6 aka boole !– Note that this is a Class B address (first zero in

second position) and the subnet is defined with 14 bits, the host address with 16 bits.

Page 7: Review of TCP/IP

IP Allocations

• A central authority has responsibility for allocation of IP addresses. They are the network Information center, or NIC.

Page 8: Review of TCP/IP

Specail IP Addresses

• Class D addresses are for multicasting.

• Class E are experimental

• Private blocks include– 10.0.0.0 – 10.255.255.255 (10.0.0.0/8)– 172.16.0.0 – 172.31.255.255 (172.16.0.0/12)– 192.168.0.0 – 192.168.255.255 (192.168.0.0/16)– 127.0.0.1 Loopback address

Page 9: Review of TCP/IP

Subnetting• Subnetting allows for the creation of multiple

logical networks within a single Class A, B or C network

• Instead of using 16 bits for the hosts, divide the host space up into 2, a subnet and a host

• If you have a Class B network, you can connect up to 64 thousand hosts. Think of DCU. Need to break up network into EE, CA, Communications, etc., so we subnet the network

• Subnet masks– Class A = 255.0.0.0– Class B = 255.255.0.0– Class C = 255.255.255.0

Page 10: Review of TCP/IP

Subnetting a Class B network

Subnet

Network

Subnet

Host10 Network

Subnet

Network

Subnet

Host10 Network

Subnet

Network

Subnet

Host10 Network

Subnet

Network

Subnet

Host10 Network

Subnet

Network

Subnet

Host10 Network

512 networks, 126 hosts /25

254 networks, 254 hosts /24

128 networks, 510 hosts /23

64 networks, 1,022 hosts /22

32 networks, 2,046 hosts /21

Page 11: Review of TCP/IP

Subnetting

• Normally when a router receives a packet it looks at the IP address and decides if it is local or has to sent elsewhere. Entries look like (network, 0) and (this-network, host). The routing table has entries for local packets as well as distant packets. A router only needs to know about its local hosts, some other networks and where to send all other packets

• With subnetting an extra entry is added to the routing table stating (this-network, subnet, 0) and (this-network, this-subnet, host)

• This way a router knows about all of its own hosts and how to get to the other subnets

Page 12: Review of TCP/IP

Subnet Mask

• Router has a subnet mask telling it the split between (subnet) networks and hosts

• Subnetting is not visible outside the network

• Boolean AND to remove host part– 136.206.19.34– 255.255.255.0– 136.206.19.0

Page 13: Review of TCP/IP

Subnetting• To recap, subnetting divides an

organisations single class A, B or C network into multiple logical networks by dividing the original host identifier string into two, with the first string representing the subnet and the second representing the hosts

• Routers use a subnet mask to determine if a packet is to be routed to the current network, another network in the subnet or a distant network

Page 14: Review of TCP/IP

TCP/IP TCP/IP EncapsulationEncapsulation

Ethernetheader

IPheader

TCPheader

Application DataEthernettrailer

IPheader

TCPheader

Application Data

TCPheader

Application Data

userData

ApplHdr

userData

Page 15: Review of TCP/IP

TCP Segment Header

32-bit sequence number

32-bit acknowledgement number

16-bit source port number 16-bit destination port number

4bit hdrlength

reservedurg

ACK

PSH

RST

SYN

FIN

16-bit window size

16-bit TCP checksum 16-bit urgent pointer

Options (if any)

Data (if any)

Page 16: Review of TCP/IP

TCP Header Description• Source Port and Destination Port identify

transport end-points of connection.• Sequence Number and Acknowledgement Number

perform usual functions, Ack numbers next byte expected.

• TCP Header Length indicates number of 32 bit words in header. Length varies because of options.

• Not used. No bug fixes required !

Page 17: Review of TCP/IP

• Six one bit flags…– URGent pointer in use, used for indicating

interrupts and offset from seq no. to urgent data.

– ACK bit used to indicate piggybacked acknowledgement.

– PSH requests that receiver does not buffer but to deliver.

– RST is reset connection, means problems !– SYN used in conjunction with ACK to request

connection.– FIN release connection

Page 18: Review of TCP/IP

• Window size used for variable-sized sliding window. Size of zero indicates a choke packet.

• Checksum checks header.

• Options field for things like specification of maximum TCP payload. Negotiated at startup lowest bid wins.

• A selective repeat instead of go-back-n sliding window protocol may be specified as an option.

Page 19: Review of TCP/IP

TCP Addressing

• TCP uses notion of Port Number to access transport endpoint on a single host. Many Ports may be in use simultaneously.

• Combination of IP address and port number uniquely identifies a port for process running on a particular machine.

• Process may even have several ports open.

Page 20: Review of TCP/IP

TCP Services

• Provides connection-oriented, reliable, byte stream service.

• Segments passed to IP for routing, timer attached for each segment.

• Sliding window protocol utilised with go-back-n or selective-repeat for retransmission.

• All TCP segments acknowledged.

Page 21: Review of TCP/IP

• TCP segments may arrive out of order, sliding window will sort order.

• TCP segments may be duplicated, duplicated are discarded.

• TCP provides flow control, no process\host will be swamped, helps avoid congestion.

• TCP utilised by many internet applications such as Telnet, Rlogin, FTP, E-mail, WWW Browsers.

Page 22: Review of TCP/IP

TCP – The GutsWhat programmers need to know

Page 23: Review of TCP/IP

Three Way Handshake

SocketConnect(blocks)(active open)

Connect returns

Socket,Bind,ListenAccept(blocks)

Accept returnsRead(blocks

SYN J

SYN K, ack J+1

Ack K+1

Page 24: Review of TCP/IP

• Server prepares connection– socket, bind, listen. This is a passive open.

• Client issues active open by calling connect.– Issues a SYN segment with sequence no.– Contains IP header, TCP header and possible TCP

options (next slide)

• Server acks clients SYN with its own SYN with initial sequence no that server will send. The SYN and ACK are sent is the same segment.

• Client acknowledges the servers SYN• 3 packets are sent (minimum) so called 3-way-

handshake.

Page 25: Review of TCP/IP

Common TCP Options in SYN

• MSS: maximum segment size (Stevens Ch 7.9)• Window Scale Option: max window 65535 (16 bit

size). Window may be scaled (left shifted) by 0-14 bits giving amx window size of 65535 x 214. Only used if both sender and receiver agree.

• Timestamp option: used on hi-speed connections to prevent corruption due to reappearing packets, negociated similarely to above.

• Latter two called RFC 1332 options, or “long fat pipe options”

Page 26: Review of TCP/IP

TCP Connection Termination

• If application calls close forst, this is an active close.

• Sends FIN segment, meaning finished sending data.• Server performs passive close. • Clients FIN is ack’ed and sent to application as

EOF, after any queued data to receive.• When application receives its EOF, it will close its

socket. TCP sends FIN.• The server on receiving final FIN acks that FIN.

Page 27: Review of TCP/IP

ack N+1

FIN N

ack M+!

FIN MClose

(active close)(passive close)

read returns 0

close

Page 28: Review of TCP/IP

TCP SDT

• Normal client transitions• Normal Server transitions• appl: Application issues

operation• recv: segment received• send: what is sent for this

transition• The netstat application uses the

state names from this diagram, try it out.

Page 29: Review of TCP/IP

closed

listen

SYN_RCVD SYN_SENT

ESTABLISHED

Appl: active open

Send SYN

active open

starting point

recv: SYNsend: SYN, ACKsimultaneous open

recv: SYN; send: SYN, ACK

recv: RST

appl:passive opensend<nothing>

recv:SYN, ACK

send: ACK

data Transferstate

recv:ACKsend<nothing>

appl: c

lose

send: F

IN

CLOSE_WAIT

LAST_ACK

appl: closesend: FIN

recv: ACKsend: <nothing>

recv: FINsend: ACK

Page 30: Review of TCP/IP

appl: c

lose

send: F

IN

FIN_WAIT_1 CLOSING

TIME_WAITFIN_WAIT_2

recv:FINsend: ACK

simultaneous close

2MSL timeout

recv: ACKsend: <nothing>

recv: FIN, ACK

send: ACK

recv: FINsend: ACK

recv: ACKsend: <nothing>

Page 31: Review of TCP/IP

• 11 states defined. Rules of TCP apply…– If application performs active open in CLOSED state,

TCP sends SYN and new state is SYN_SENT.

– If TCP next receives a SYN with an ACK, it sends an ACK and the new stste is ESTABLISHED

• Two arrows leading from ESTABLISHED deal with termination.– If application calls close before receiving eof (active

close), transits to FIN_WAIT_1

– If application receives FIN while ESTABLISHED (passive close), transits to CLOSE_WAIT

Page 32: Review of TCP/IP

TCP Connection & The Packets

• A complele TCP connection involves many packet exchanges.– Connection establishment– Data transfer– Connection termination– TCP states are also shown as client and server

enter them.

Page 33: Review of TCP/IP

SocketConnect(blocks)

(active open) SYN_SENT

ESTABLISHEDConnection returns

<client forms request>

WriteRead(blocks)

Read returns

Close(active close) FIN_WAIT_1

FIN_WAIT_2

TIME_WAIT

socket, bind, listenLISTEN(passive open)accept(blocks)

SYN_RCVD

ESTABLISHEDaccept returnsread(blocks)

read returns<server process request>

writeread(blocks)

CLOSE_WAIT(passive close)read returns 0

closeLAST_ACK

CLOSED

Client Server

ack N+1

FIN N

ack M+!

Data reply

Ack of request

SYN K, ack J+1, mss=1024

SYN J, mss=1460

ack K+1

Data (request)

ack of replyFIN M

Page 34: Review of TCP/IP

• Client announces MSS 1460, typical for Ethernet, Ok if different in each direction.

• Once connection established, clients forms request for server.

• Server processes request and replies with piggybacked ack.

• Termination by client (active close) enters TIME_WAIT state, 2MSL (Maximum Segment Lifetime) to deal with lost or wandering IP packets.


Recommended