Computer Networks and Socket Programming

Download Report

Transcript Computer Networks and Socket Programming

CS 381
Introduction to computer
networks
Lecture 2
1/29/2015
Chapter 1: roadmap
1.1 What is the Internet?
1.2 Network edge
 end systems, access networks, links
1.3 Network core
 circuit switching, packet switching, network structure
1.4 Delay, loss and throughput in packet-switched networks
1.5 Protocol layers, service models
1.6 Networks under attack: security
1.7 History
Introduction
1-3
A closer look at network structure:
• network edge:
• applications and hosts
• access networks
•
Connects end system to
1st router
physical media: wired,
wireless communication
links
•
• network core:
•
•
interconnected routers
network of networks
Introduction
1-4
The network edge:
• End systems (hosts):
• All Internet applications are implemented at the end systems.
• HTTP, FTP, SSH, SCP, DNS, SMTP
• Reasons for this?
Introduction
1-5
Access networks and physical media
• Question:
• How to connect end systems to edge router?
• Most common ways:
• residential access networks
• Cable modems, DSL, Dial-Up modem
• NAT router with Wi-Fi, Ethernet
• institutional access networks (school, company)
• mobile access networks
Introduction
1-6
Access networks and physical media
• Two important characteristics of access networks
• bandwidth (bits per second) of access network
•
•
•
•
•
Residential (Outgoing): 2Mbps – 50Mbps (and higher)
Residential (Local): 11Mbps – 1.2Gpbs
Institutional (Outgoing): 100s Mbps – multiple Gbps
Institutional (Local): 54Mbps – 10Gpbs
Mobile: Kbps - ~40Mbps
• shared or dedicated
Introduction
1-7
Dial-up Modem
central
office
home
PC
•
home
dial-up
modem
telephone
network
Internet
ISP
modem
(e.g., AOL)
Problems:
• Extremely slow with max speed of 56 kbps
• ~42.5 hours to download 1GB worth of data
• ~4KHz bandwidth compared to 500MHz using CAT6a cable
• Have to choose: Computer or telephone.
• Circuit switched, non-shared access to ISP
Digital Subscriber Line (DSL)
Existing phone line:
0-4KHz phone; 4-50KHz upstream data;
50KHz-1MHz downstream data
Internet
home
phone
DSLAM
telephone
network
splitter
DSL
modem
home
PC
central
office
• Telephone line carries both digital and telephone signals
• Encoded at different frequencies.
• Phone line at 0 - 4KHz
• Upstream data at 4 - 50KHz
(128 kbps - 1 mbps)
• Downstream data at 50KHz - 1MHz (1 - 2 megabits per second)
 New technologies emerging for DSL: up to 1Gbps (~2016)
Ethernet Internet access
100 Mbps
Institutional
router
Ethernet
switch
To Institution’s
ISP
100 Mbps
1 Gbps
100 Mbps
server
• Typically used in companies, universities, etc
• 10 Mbps, 100Mbps, 1Gbps, 10Gbps Ethernet
• Multiple switches per building
• Serves rooms with Ethernet ports and Wi-Fi access points
• Fiber connection between switches
Ethernet Internet access
100 Mbps
Institutional
router
Ethernet
switch
To Institution’s
ISP
100 Mbps
1 Gbps
100 Mbps
server
• Few routers on campus
•
Why?
• Campus network can be thought of as a large LAN (Local Area Network)
•
•
•
•
Similar to your network at home, but with thousands of end systems
Greater complexity, but basic topology is exactly the same
Large number of switches allow local communication (layer 2 routing)
Only communication off campus requires the use of routers (layer 3 routing)
The Network Core
• Mesh of interconnected routers
• The fundamental question:
• how is data transferred through net?
• Compare telephone network and Internet
• Telephone network employs “circuit switching”
• resources necessary to make call are reserved for duration of
communication
Introduction
1-12
Network Core: Packet Switching
• Internet is a packet switching network.
• Reservations not accepted
• No reserving of communication links,
• no guarantee of given bandwidth
• In fact, No guarantees at all!
• How can we demonstrate this?
•
Ping command
Introduction
1-13
“Real” Internet delays and routes
• What do “real” Internet delay & loss look like?
• Traceroute program:
• Sends UDP packet to each router on the path from source to
destination.
• Each router on the path sends back a “special” message to source
• Source tracks the time from when it sent the UDP packet and when
it receives the message from the router.
• Actually sends three UDP packets to each router to provide three
different timings.
Introduction
1-14
Protocol “layers”
Networks are complex, with many “pieces”:
• Hosts
• Clients/Servers
• Switches
• Layer 2 routing: MAC
• Routers
• Layer 3 routing: IP
• Links
• Copper, fiber, air
• Applications
• HTTP, FTP, SCP
• Protocols
• IP, TCP, UDP
• Hardware
• Software
Introduction
1-15
Internet protocol stack
•
application: supporting network
applications
• FTP, SMTP, HTTP
•
application
transport: process-process data
transfer
• TCP, UDP
•
network: routing of datagrams
from source to destination
• IP, routing protocols
•
link: data transfer between
neighboring network elements
• Ethernet, 802.11 (WiFi), PPP
•
transport
network
link
physical
physical: bits “on the wire”
Introduction
1-16
Encapsulation
source
message
segment
M
Ht
M
datagram Hn Ht
M
frame
M
Hl Hn Ht
application
transport
network
link
physical
link
physical
switch
M
Ht
M
Hn Ht
M
Hl Hn Ht
M
destination
Hn Ht
M
application
transport
network
link
physical
Hl Hn Ht
M
network
link
physical
Hn Ht
M
router
Introduction
1-17
Internet history
1961-1972: Early packet-switching principles
•
1961: Kleinrock queueing theory shows
effectiveness of packetswitching
•
1964: Baran - packetswitching in military nets
1967: ARPAnet conceived
by Advanced Research
Projects Agency
1969: first ARPAnet node
operational
•
•
•
1972:
• ARPAnet public demo
• NCP (Network Control
Protocol) first host-host
protocol
• first e-mail program
• ARPAnet has 15 nodes
Introduction
1-18
Internet history
1972-1980: Internetworking, new and proprietary nets
•
•
•
1970: ALOHAnet radio network
in Hawaii
1974: Cerf and Kahn architecture for interconnecting
networks
1976: Ethernet at Xerox
•
late70’s: proprietary
architectures: DECnet, SNA, XNA
•
late 70’s: switching fixed length
packets (ATM precursor)
1979: ARPAnet has 200 nodes
•
Introduction
Cerf and Kahn’s
internetworking principles:
• minimalism, autonomy - no
internal changes required to
interconnect networks
• best effort service model
• stateless routers
• decentralized control
define today’s Internet
architecture
1-19
Internet history
1980-1990: new protocols, a proliferation of networks
•
•
•
•
•
1982: SMTP e-mail
protocol defined
1983: deployment of
TCP/IP
1983: DNS defined for
name-to-IP-address
translation
1985: ftp protocol defined
1988: TCP congestion
control
•
100,000 hosts connected
to confederation of
networks
Introduction
1-20
Internet history
1990, 2000’s: commercialization, the Web, new apps
•
•
early 1990’s: ARPAnet
late 1990’s – 2000’s:
decommissioned
• more killer apps: instant
early 1990s: Web
messaging, P2P file sharing
• hypertext [Bush 1945, Nelson • network security to
1960’s]
forefront
• HTML, HTTP: Berners-Lee
• est. 50 million host, 100
• 1994: Mosaic, later Netscape
million+ users
• late 1990’s:
• backbone links running at
commercialization of the Web
Gbps
Introduction
1-21
Internet history
2005-present
•
~950 million hosts
•
Smartphones and tablets
• Aggressive deployment of broadband access
• Increasing ubiquity of high-speed wireless access
• Emergence of online social networks:
• Facebook: ~1.2 billion users
• Service providers (Google, Microsoft) create their own networks
• Bypass Internet, providing “instantaneous” access to search, emai, etc.
• E-commerce, universities, enterprises running their services in “cloud” (eg, Amazon
EC2)
Introduction
1-22
Application layer
Goals:
• conceptual, implementation aspects of network application
protocols
• transport-layer service models
• client-server paradigm
• peer-to-peer paradigm
Application Layer
2-23
Application layer
• learn about protocols by examining popular applicationlevel protocols
• HTTP
• Request/response protocol for exchanging information
• FTP
• Transfer files
• SMTP / POP3 / IMAP
• Email
• DNS
• Domain name to IP conversions
• creating network applications
• socket API
Application Layer
2-24
Some network apps
•
•
•
•
e-mail
web
text messaging
remote login
• P2P file sharing
• multi-user network games
• streaming stored video
(YouTube, Hulu, Netflix)
• voice over IP (e.g., Skype)
• real-time video
conferencing
• social networking
• search
• …
•…
Application Layer
2-25
Creating a network app
write programs that:
• run on (different) end systems
• communicate over network
• e.g., web server software
communicates with browser
software
no need to write software for
network-core devices
• network-core devices do not
run user applications
• applications on end systems
allows for rapid app
development, propagation
Application Layer
application
transport
network
data link
physical
application
transport
network
data link
physical
application
transport
network
data link
physical
2-26
Sockets
• process sends/receives messages to/from its socket
• socket analogous to door
• sending process shoves message out door
• sending process relies on transport infrastructure on other
side of door to deliver message to socket at receiving
process
application
process
socket
application
process
transport
transport
network
network
link
Internet
link
controlled by
app developer
controlled
by OS
physical
physical
Application Layer
2-27
DNS: services, structure
DNS services
why not centralize DNS?
• hostname to IP address translation
• host aliasing
•
•
•
•
• canonical, alias names
• mail server aliasing
• load distribution
• replicated Web servers: many IP addresses
correspond to one name
Application Layer
single point of failure
traffic volume
distant centralized database
maintenance
A: doesn’t scale!
2-28
Socket programming
Goal: learn how to build client/server application that
communicate using sockets
socket
Socket API
• introduced in BSD4.1 UNIX, 1981
• explicitly created, used, released
by apps
• client/server paradigm
• two types of transport service via
socket API:
• unreliable datagram
• reliable, byte stream-oriented
a host-local,
application-created,
OS-controlled interface
(a “door”) into which
application process can
both send and
receive messages to/from
another application
process
2: Application Layer
29
Socket-programming using TCP
Socket: a door between application process and end-endtransport protocol (UCP or TCP)
TCP service: reliable transfer of bytes from one process to
another
controlled by
application
developer
controlled by
operating
system
process
process
socket
TCP with
buffers,
variables
internet
socket
TCP with
buffers,
variables
controlled by
application
developer
controlled by
operating
system
host or
server
host or
server
2: Application Layer
30
Internet transport-layer protocols
• TCP: reliable, in-order delivery
• congestion control
• flow control
• connection setup
application
transport
network
data link
physical
network
data link
physical
• UDP: unreliable, unordered
delivery
• no-frills extension of “best-effort” IP
• Connectionless, unreliable
• UDP only offers process-to-process
communication and error checking
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
network
data link
physical
application
transport
network
data link
physical
• Services not available:
• delay guarantees
• bandwidth guarantees
Transport Layer
3-31
Socket programming with TCP
Client must contact server
• server process must first be
running
• server must have created socket
(door) that welcomes client’s
contact
Client contacts server by:
• creating client-local TCP socket
• specifying IP address, port
number of server process
• When client creates socket:
client TCP establishes
connection to server TCP
• When contacted by client, server
TCP creates new socket for server
process to communicate with
client
• allows server to talk with
multiple clients
• source port numbers used to
distinguish clients (more in
Chap 3)
application viewpoint
TCP provides reliable, in-order
transfer of bytes (“pipe”)
between client and server
2: Application Layer
32