Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review of TCP/IP.

Similar presentations


Presentation on theme: "Review of TCP/IP."— Presentation transcript:

1 Review of TCP/IP

2 TCP/IP Four layer Architecture Developed in 1960’s Open System
Not just one protocol, whole family. Many programming interfaces available. Standardised protocol set.

3 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.

4 IP Address Format 24 bits 7 bits netid hostid Class A 16 bits 14 bits
netid hostid Class A 16 bits 14 bits Class B 10 netid hostid 21 bits 8 bits Class C 110 netid hostid 28 bits Class D 1110 Multicast group ID

5 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.

6 IP Address Notation A decimal dot notation is used to break down the IP address. Example gives the address 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.

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

8 Specail IP Addresses Class D addresses are for multicasting.
Class E are experimental Private blocks include – ( /8) – ( /12) – ( /16) Loopback address

9 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 = Class B = Class C =

10 Subnetting a Class B network
512 networks, 126 hosts /25 10 Network Subnet Network Host 254 networks, 254 hosts /24 10 Network Subnet Network Subnet Host 128 networks, 510 hosts /23 10 Network Subnet Network Subnet Host 64 networks, 1,022 hosts /22 10 Network Subnet Network Subnet Host 10 Network Subnet Network Subnet Host 32 networks, 2,046 hosts /21

11 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

12 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

13 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

14 TCP/IP Encapsulation Application TCP IP 802.3 user Data Appl Hdr user
header Application Data TCP IP header TCP header Application Data IP Ethernet header IP header TCP header Application Data Ethernet trailer 802.3

15 TCP Segment Header 16-bit source port number
16-bit destination port number 32-bit sequence number 32-bit acknowledgement number 4bit hdr length reserved u r g A C K P S H R S T S Y N F I N 16-bit window size 16-bit TCP checksum 16-bit urgent pointer Options (if any) Data (if any)

16 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 !

17 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

18 Window size used for variable-sized sliding window
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.

19 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.

20 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.

21 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, , WWW Browsers.

22 What programmers need to know
TCP – The Guts What programmers need to know

23 Three Way Handshake Socket, Bind, Listen Socket Accept(blocks)
Connect(blocks) (active open) SYN J SYN K, ack J+1 Connect returns Ack K+1 Accept returns Read(blocks

24 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.

25 Common TCP Options in SYN
MSS: maximum segment size (Stevens Ch 7.9) Window Scale Option: max window (16 bit size). Window may be scaled (left shifted) by 0-14 bits giving amx window size of 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”

26 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.

27 FIN M ack M+! FIN N ack N+1 Close (active close) (passive close)
read returns 0 close ack M+! FIN N ack N+1

28 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.

29 starting point closed listen active open SYN_RCVD SYN_SENT ESTABLISHED
appl:passive open send<nothing> Appl: active open Send SYN listen recv: SYN; send: SYN, ACK active open recv: RST recv: SYN send: SYN, ACK simultaneous open SYN_RCVD SYN_SENT recv:ACK send<nothing> recv:SYN, ACK send: ACK ESTABLISHED data Transfer state CLOSE_WAIT recv: FIN send: ACK appl: close send: FIN appl: close send: FIN recv: ACK send: <nothing> LAST_ACK

30 CLOSING FIN_WAIT_1 TIME_WAIT FIN_WAIT_2 appl: close send: FIN
simultaneous close recv:FIN send: ACK FIN_WAIT_1 CLOSING recv: FIN, ACK send: ACK recv: ACK send: <nothing> recv: ACK send: <nothing> recv: FIN send: ACK TIME_WAIT FIN_WAIT_2 2MSL timeout

31 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

32 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.

33 Client Server socket, bind, listen LISTEN(passive open) accept(blocks)
SYN_RCVD ESTABLISHED accept returns read(blocks) read returns <server process request> write CLOSE_WAIT(passive close) read returns 0 close LAST_ACK CLOSED SYN J, mss=1460 Socket Connect(blocks) (active open) SYN_SENT ESTABLISHED Connection returns <client forms request> Write Read(blocks) Read returns Close (active close) FIN_WAIT_1 FIN_WAIT_2 TIME_WAIT SYN K, ack J+1, mss=1024 ack K+1 Data (request) Data reply Ack of request ack of reply FIN M ack M+! FIN N ack N+1

34 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.


Download ppt "Review of TCP/IP."

Similar presentations


Ads by Google