Protocols

advertisement
Protocols
• A protocol is a set of rules and formats that
govern the communication between
communicating peers
– set of valid messages
– meaning of each message
• A protocol is necessary for any function that
requires cooperation between peers
1
What does a protocol tell us?
• Syntax of a message
– what fields does it contain?
– in what format?
• Semantics of a message
– what does a message mean?
– for example, not-OK message means receiver got a corrupted file
• Actions to take on receipt of a message
– for example, on receiving not-OK message, retransmit the entire
file
2
Routing
• How does a device know where to send
a packet?
– All devices need to know what IP
addresses are on directly attached
networks
– If the destination is on a local network,
send it directly there
Routing (cont)
• If the destination address isn’t local
– Most non-router devices just send
everything to a single local router
– Routers need to know which network
corresponds to each possible IP address
Orientation
• IP (Internet Protocol) is a Network Layer
Protocol.
TCP
UDP
ICMP
IP
ARP
Network
Access
Media
5
IGMP
Transport
Layer
Network
Layer
Link Layer
IP: The waist of the hourglass
• IP is the waist of the
hourglass of the Internet
protocol architecture
Applications
HTTP FTP SMTP
TCP UDP
• Multiple higher-layer
protocols
• Multiple lower-layer
protocols
IP
Data link layer
protocols
Physical layer
protocols
• Only one protocol at the
network layer.
6
IP Service
• IP supports the following services:
• one-to-one
• one-to-all
• one-to-several
unicast
broadcast
(unicast)
(broadcast)
(multicast)
multicast
• IP multicast also supports a many-to-many service.
• IP multicast requires support of other protocols (IGMP, multicast
7
routing)
IP packets
• Source and destination addresses
• Protocol number
– 1 = ICMP, 6 = TCP, 17 = UDP
• Various options
– e.g. to control fragmentation
• Time to live (TTL)
– Prevent routing loops
IP Datagram
0
4
8
Vers
16
Len
TOS
24
31
Total Length
Identification
TTL
19
Flags
Protocol
Fragment Offset
Header Checksum
Source Internet Address
Destination Internet Address
Options...
Padding
Data...
Field
Vers
Len
TOS
T. Length
Ident.
Flags
Frag Off
Purpose
IP version number
Length of IP header (4 octet units)
Type of Service
Length of entire datagram (octets)
IP datagram ID (for frag/reassembly)
Don’t/More fragments
Fragment Offset
Field
TTL
Protocol
Purpose
Time To Live - Max # of hops
Higher level protocol (1=ICMP,
6=TCP, 17=UDP)
Checksum Checksum for the IP header
Source IA Originator’s Internet Address
Dest. IA
Final Destination Internet Address
Options
Source route, time stamp, etc.
Data...
Higher level protocol data
We only looked at the IP addresses, TTL and protocol #
Source
IP Routing
Application
Destination
Application
Transport
Router
Transport
Network
Network
Network
Link
Link
Link
• Routing Table
Destination IP address
IP address of a next-hop router
Flags
Network interface specification
ARP
When IP packets are sent on shared access,
broadcast-based networking technologies such
as Ethernet or Token Ring, the media access
control (MAC) address corresponding to a
forwarding IP address must be resolved. ARP
uses MAC-level broadcasts to resolve a known
forwarding IP address to its MAC address.
ICMP
Internet Control Message Protocol (ICMP)
provides troubleshooting facilities and error
reporting for packets that are undeliverable. For
example, if IP is unable to deliver a packet to the
destination host, ICMP sends a Destination
Unreachable message to the source host.
UDP
• Thin layer on top of IP
• Adds packet length + checksum
– Guard against corrupted packets
• Also source and destination ports
– Ports are used to associate a packet with a
specific application at each end
• Still unreliable:
– Duplication, loss, out-of-orderness possible
UDP datagram
0
16
31
Source Port
Destination Port
Length
Checksum
Application data
Field
Source Port
Destination Port
Length
Checksum
Purpose
16-bit port number identifying originating application
16-bit port number identifying destination application
Length of UDP datagram (UDP header + data)
Checksum of IP pseudo header, UDP header, and data
Typical applications of UDP
– Where packet loss etc is better handled by
the application than the network stack
– Where the overhead of setting up a
connection isn’t wanted
• VOIP
• NFS – Network File System
• Most games
TCP
• Reliable, full-duplex, connectionoriented, stream delivery
– Interface presented to the application
doesn’t require data in individual packets
– Data is guaranteed to arrive, and in the
correct order without duplications
• Or the connection will be dropped
– Imposes significant overheads
Applications of TCP
• Most things!
– HTTP, FTP, …
• Saves the application a lot of work, so
used unless there’s a good reason not
to
TCP implementation
• Connections are established using a
three-way handshake
• Data is divided up into packets by the
operating system
• Packets are numbered, and received
packets are acknowledged
• Connections are explicitly closed
– (or may abnormally terminate)
TCP Packets
• Source + destination ports
• Sequence number (used to order packets)
• Acknowledgement number (used to verify
packets are received)
0
4
TCP Segment
10
16
Source Port
19
24
31
Destination Port
Sequence Number
Acknowledgment Number
Len
Reserved
Flags
Window
Checksum
Urgent Pointer
Options...
Padding
Data...
Field
Source Port
Destination Port
Sequence Number
Acknowledgment #
Len
Flags
Window
Checksum
Urgent Pointer
Options
Purpose
Identifies originating application
Identifies destination application
Sequence number of first octet in the segment
Sequence number of the next expected octet (if ACK flag set)
Length of TCP header in 4 octet units
TCP flags: SYN, FIN, RST, PSH, ACK, URG
Number of octets from ACK that sender will accept
Checksum of IP pseudo-header + TCP header + data
Pointer to end of “urgent data”
Special TCP options such as MSS and Window Scale
You just need to know port numbers, seq and ack are added
TCP Ports
A TCP port provides a specific location for
delivery of TCP segments. Port numbers
below 1024 are well-known ports and are
assigned by the Internet Assigned Numbers
Authority (IANA).
Well-Known TCP Ports
TCP Port Number
Description
20
FTP (Data Channel)
21
FTP (Control Channel)
23
Telnet
80
HTTP used for the World Wide Web
139
NetBIOS session service
TCP : Data transfer
Client
Timer
Send Packet 1
Start Timer
ACK would normally
Arrive at this time
Host
Packet Lost
Packet should arrive
ACK should be sent
Time Expires
Timer
Retransmit Packet1
Start Timer
Receive ACK 1
Cancel Timer
Receive Packet 1
Send AXK 1
IPv6
• 128 bit addresses
– Make it feasible to be very wasteful with
address allocations
• Lots of other new features
– Built-in autoconfiguration, security options,
…
• Not really in production use yet
IP Address Classes
25
IP Address Class Ranges
26
Address Class Characteristics
27
Class
Network Bits
Host Bits
Total Networks
Total Addresses
A
8
24
127
16,777,216
B
16
16
16,384
65,536
C
24
8
2,097,152 256
IP addressing: the last word...
Q: How does an ISP get block of addresses?
A: ICANN: Internet Corporation for Assigned
Names and Numbers (guidelines in RFC 2050)
– allocates addresses
– manages DNS
– assigns domain names, resolves disputes
28
World Wide Web
• the Web is the world’s largest client/server system
communication occurs via message passing
• within browser, select URL of desired page
• browser requests page from server
• server responds with message containing
– type of page (HTML, gif, pdf, zip, …)
– page contents
• browser uses type info to correctly display page
• if page contains other items (images, applets, …), browser must
request each separately
Hyper Text Transfer Protocol
(HTTP)
• Protocol relating to web applications
• Current version of HTTP 1.1 has additional
features
– Upload information to the server
– Etc.
• Default port number is 80
File Transfer Protocol (FTP)
• File Transfer Protocol
– Used for downloading from most MP3 sites, for
example
• Designed for faster file transfer over the Internet
compared to using the HTTP protocol
• FTP sites can be configured alongside a web site
to support FTP file transfer
• FTP default ports are 20 and 21
HTTP and FTP
• File transfer under FTP is faster than file
transfer under HTTP
• Choose an FTP site if there is one for
downloading files etc.
Simple Mail Transfer Protocol
(SMTP)
• Governs the transmission of mail messages
and attachments
• SMTP is used in the case of outgoing
messages
• More powerful protocols such as POP3 and
IMAP4 are needed and available to manage
incoming messages
POP3/IMAP4
• Used for incoming mail
• POP3 is the older protocol
• IMAP4 is the more advanced protocol
Telnet
• Supports terminal emulation or host
sessions
• For example, Telnet can be used for
accessing a Unix machine and emulating a
terminal attached to the Unix computer
Domain Name System (DNS)
Resolves domain names to IP addresses
and vice versa
www.refer.com
DNS Server
130.182.125.66
Routing Information Protocol
(RIP)
Network 1 Router
Network 2
Network 1
Used by Routers to route
data packets on an IP Internet.
Simple Network Management
Protocol (SNMP)
Facilitates the management of SNMP compliant
routers, bridges, switches etc. by enabling
the collection and exchange of
network management information.
Router
Router
Switch
Bridge
Remote
Management
Console
SNMP
• Used by network management utilities to
manage network devices
• For example, a manageable hub that support
SNMP can be managed from a remote
location using a SNMP based LAN
management software
Download