480 likes | 671 Views
Communication Protocols. Outline. Basics IP UDP TCP. Communication. Circuits vs. Packets. Circuit switching reserve a circuit between communicating entities Packet switching break data into packets transmit each packet separately—each packet could travel a different route.
E N D
Outline • Basics • IP • UDP • TCP
Circuits vs. Packets • Circuit switching • reserve a circuit between communicating entities • Packet switching • break data into packets • transmit each packet separately—each packet could travel a different route
ISO OSI Reference Model application application 7 6 presentation presentation session session 5 4 transport transport network link network link network link network link 3 data link data link data link data link 2 physical physical physical physical 1
Application Application End-to-End End-to-End Internet Internet Internet Internet Net Interface Net Interface Net Interface Net Interface Internet Architecture OSI Layer 5-7 OSI Layer 4 OSI Layer 3 OSI Layers 1-2
IP i/f i/f i/f i/f IP IP i/f i/f Internetworking with TCP/IP user user TCP TCP IP LAN LAN WAN
LAN LAN LAN LAN LAN WAN WAN WAN WAN Navigating the Internet
Internet Addresses 0 network host Class A 7 bits 24 bits 10 network host Class B 14 bits 16 bits 110 network host Class C 21 bits 8 bits 1110 multicast group ID Class D 28 bits
Internet Addresses Written as sequence of octets Example: 144.16.11.1 Different from the name: linux-2.ece.iastate.edu
Subnetting 10 network host subnet mask & 10 institution network host
Example A machine has IP address 16.15.15.1 and subnet mask 255.0.0.0 16.15.15.1 = 00010000.00001111.00001111.00000001 255.0.0.0 = 11111111.00000000.00000000.00000000 net id | host id Net id = 00010000 = 16 Host id = 00001111.00001111.00000001 = 15.15.1 http://www.cisco.com/warp/public/701/3.html
IP Routing • How to get the packet from source to destination? • (Loose) Analogy with USPS routing • Network address = zip code • Host address = street + house # • Major conceptual difference between postal and internet routing • Role of a central organization (such as USPS) is limited
Network vs Subnetwork • Network • A logical grouping of computers • Share a common address prefix • Physically “quite close” to each other • Subnetwork • A single physical network • All computers are very close to each other • A single network might consist of many subnetworks
IP Routing • Two options: • sender supplies entire route • “source routing” • sender supplies the first hop • each intermediate host determines the next host
Types of Routes • Direct vs. Indirect Routes • Host-Specific vs. Network-Specific vs. Default Routes • Generate Strategy: • Find a host-specific route • Find a network-specific route • Try the default route
Direct Route Example spenser 128.148.128.2 128.148.32.1 holmes 128.148.32.33
Host-Specific Route Example spenser 128.148.128.2 128.148.32.1 holmes 128.148.32.33 128.148.128.3:128.148.32.1 routing table archy 128.148.128.3
Network-Specific Route Example spenser 128.148.128.2 128.148.32.1 holmes 128.148.32.33 16.0.0.0: 128.148.128.3 128.148.128.3:128.148.32.1 routing table routing table archy 128.148.128.3 16.0.0.111 sloth 16.0.0.234
Default Route Example spenser 128.148.128.2 128.148.32.1 holmes 128.148.32.33 16.0.0.0: 128.148.128.3 128.148.128.3:128.148.32.1 routing table routing table archy 128.148.128.3 16.0.0.111 sloth 16.0.0.234 0.0.0.0: 16.0.0.111 routing table
vers hlen type of serv total length identification flags fragment offset time-to-live protocol header checksum source address destination address options padding data IP Header
Broadcasting • Broadcast: no filtering done at net interface • limited: to local net • address: 255.255.255.255 • net: to all on specified net • address: netid.x, where x is the all ones host portion of the address • subnet: to all on specified subnet • address: netid.subnetid.x • all subnets: to all on subnets of one net • address: the host portion of the address is all ones
Multicasting (1) • Like broadcasting, but: • multicast messages are sent to multicast group addresses • individual interfaces can select group addresses of interest • Distribution handled by collection of multicast routers • IGMP (internet group management protocol) used to manage group membership
Multicasting (2) Routers Source Potential Receivers
User Datagram Protocol (UDP) • A multiplexing service built on top of IP • Extends IP packet-level communication to individual user processes • No guarantees about reliability • Checksumming is (optionally) performed on • the UDP header and data, and • portion of the IP header
Source Port Destination Port Length UDP Checksum UDP Header
Transmission Control Protocol (TCP) • Another multiplexing service built on top of IP • A full-duplex reliable stream protocol • Provides reliable data transfer • Packet boundaries are not seen by the application • it sees a sequence of bytes, not a sequence of packets • A connection must be established for communication to take place • connections are flow-controlled • connections are congestion-controlled
TCP Header Components source port destination port sequence number acknowledgment sequence number offset reserved flags window size checksum urgent pointer options padding data
Sliding-Window Protocol • Used for: • reliable delivery • flow control • Windows • send • receive
Send and Receive Windows send sequence space ack’d data unack’d data ok to xmit not ok to xmit send_una send_next send_una + send_window size receive sequence space already rcv’d and ack’d ok to receive throw away recv_next + recv_window size recv_next
1024 1024 0-511 512 512 511-767 0-511 768 256 1024 768-1023 Ack 512 1024 512 512 Ack 512 768-1023 512 512 512 512 Sending Data via TCP (1)
512 512 512 512 511-767 1024 Ack 1024 Win 512 Ack 1024 Win 512 1024 512 1024 512 1024-1279 1280 256 Sending Data via TCP (2)
active open: init state send SYN passive open: init state closed closed recv SYN: send ACK recv SYN: send SYN,ACK syn sent closed syn rcvd closed closed listen recv ACK of SYN recv SYN, ACK: send ACK closed estab CLOSE: send FIN recv FIN: send ACK fin wait 1 close wait recv FIN: send ACK CLOSE: send FIN recv ACK recv FIN, ACK: send ACK fin wait 2 closing last ack recv ACK recv ACK of FIN timeout recv FIN: send ACK time wait closed TCP State Diagram
closed listen seq=100 ctl=syn syn-sent listen seq=100 ctl=syn syn-rcvd seq=300 ack=101 ctl=syn,ack syn-sent seq=300 ack=101 ctl=syn,ack estab seq=101 ack=301 ctl=ack seq=101 ack=301 ctl=ack syn-rcvd estab Connection Initiation
closed seq=100 ctl=syn syn-sent listen seq=90 ctl=syn old transmission syn-rcvd seq=300 ack=91 ctl=syn,ack syn-sent seq=300 ack=91 ctl=syn,ack syn-sent seq=91 ctl=rst syn-rcvd seq=100 ctl=syn syn-rcvd seq=300 ack=91 ctl=ack syn-rcvd seq=91 ctl=rst listen syn-sent seq=300 ack=91 ctl=ack syn-sent . seq=100 ctl=syn . . (retransmission) Coping with Problems
estab seq=100 ack=300 ctl=fin,ack close fin-wait -1 estab seq=100 ack=300 ctl=fin,ack close-wait seq=300 ack=101 ctl=ack fin-wait-1 seq=300 ack=101 ctl=ack fin-wait-2 close-wait seq=300 ack=101 ctl=fin,ack close last-ack fin-wait-2 seq=300 ack=101 ctl=fin,ack time-wait seq=101 ack=301 ctl=ack last-ack 2MSL seq=101 ack=301 ctl=ack delay closed time-wait closed Shutdown
When to Retransmit? • After waiting significantly longer than the average (“smoothed”) roundtrip time • How much longer? • significantly longer than the average deviation • What if one retransmission doesn’t do it? • transmit again … • When? • use exponential backoff • When does one give up? • after 12 retries in some systems
Computing SRTT, Etc.A Little (Sketchy) Math ... • srtt = (1g)srtt + grtt • = srtt + g(rtt srtt) • = srtt + gEr + gEe • 0.1 g 0.2 • Err = rtt srtt • srtt = srtt + g1Err • g1 = .125 • dev = dev + g2(|Err| dev) • g2 = .25 • rto = srtt + 4dev
Measuring RTT • Consider a case in which the average roundtrip time is too small • a timeout occurs on a segment, so the segment is retransmitted • immediately thereafter, the acknowledgment for the original transmission comes in • the sender “thinks” that the ack is for the retransmission, so it concludes that the first segment was lost, but the second segment was acknowledged very quickly, so it should further reduce the average roundtrip time! • Solution: measure the roundtrip time for a packet only if it is not retransmitted
1) 2) 3) Congestion Control (1)
4) 5) Congestion Control (2)
Fast Retransmit and Recovery • Waiting an entire RTO before retransmitting causes the “pipeline” to become empty • must slow-start to get going again • If one receives three acks that all repeat the same sequence number: • some data is getting through • one segment is lost • immediately retransmit the lost segment • halve the congestion window (i.e., perform congestion control) • don’t slow-start (there is still data in the pipeline)