Title: CSE 4213: Computer Networks II
1CSE 4213 Computer Networks II
- Suprakash Datta
- datta_at_cs.yorku.ca
- Office CSEB 3043
- Phone 416-736-2100 ext 77875
- Course page http//www.cs.yorku.ca/course/4213
- Some slides are adapted from Jim Kuroses slides.
2Administrivia
- Course webpage http//www.cs.yorku.ca/course/4213
- Lectures Tue-Thu 230-400 pm (VH 3005)
- Exams midterm (25), final (40)
- Homework (35) divided between lab assignments
(20) and project (15). - Slides should be available the morning of the
class - Office hours Tuesday 4-6 pm, Th 12 noon -2 pm or
by appointment at CSB3043
Textbook
Computer Networking A Top Down Approach
Featuring the Internet, 4th edition. Jim Kurose,
Keith Ross Addison-Wesley, 2008. ISBN
0-321-49770-8
3Administrivia contd.
- Cheating will not be tolerated. Visit the webpage
for more details on policies etc. - Be careful not to misuse packet sniffing
software. - I would like to have a 2-hour midterm. Your
cooperation is greatly appreciated. - TA none.
- There will be some non-credit homework to help
you study. - I may have an extra-credit assignment. This will
be announced beforehand.
4Course objectives
- Understand the full TCP/IP architecture.
- Become familiar with advanced topics
- - P2P systems, multimedia communication
(including VoIP), network security, wireless
sensor networks. - Learn about active research areas.
5Major differences with 3213
- More algorithmic (less math!)
- More hands-on TCP/IP programming.
6Internet structure network of networks
- roughly hierarchical
- at center tier-1 ISPs (e.g., UUNet,
BBN/Genuity, Sprint, ATT), national/international
coverage - treat each other as equals
Tier 1 ISP
Tier 1 ISP
Tier 1 ISP
7Tier-1 ISP e.g., Sprint
Sprint US backbone network
8Internet structure network of networks
- Tier-2 ISPs smaller (often regional) ISPs
- Connect to one or more tier-1 ISPs, possibly
other tier-2 ISPs
Tier 1 ISP
Tier 1 ISP
Tier 1 ISP
9Internet structure network of networks
- Tier-3 ISPs and local ISPs
- last hop (access) network (closest to end
systems)
Tier 1 ISP
Tier 1 ISP
Tier 1 ISP
10Internet structure network of networks
- a packet passes through many networks!
Tier 1 ISP
Tier 1 ISP
Tier 1 ISP
11A closer look at network structure
- network edge applications and hosts
- access networks, physical media wired, wireless
communication links
- network core
- interconnected routers
- network of networks
12The network edge
- end systems (hosts)
- run application programs
- e.g. Web, email
- at edge of network
- client/server model
- client host requests, receives service from
always-on server - e.g. Web browser/server email client/server
- peer-peer model
- minimal (or no) use of dedicated servers
- e.g. Skype, BitTorrent
13Network edge reliable data transfer service
- Goal data transfer between end systems
- handshaking setup (prepare for) data transfer
ahead of time - Hello, hello back human protocol
- set up state in two communicating hosts
- TCP - Transmission Control Protocol
- Internets reliable data transfer service
- TCP service RFC 793
- reliable, in-order byte-stream data transfer
- loss acknowledgements and retransmissions
- flow control
- sender wont overwhelm receiver
- congestion control
- senders slow down sending rate when network
congested
14Network edge best effort (unreliable) data
transfer service
- Apps using TCP
- HTTP (Web), FTP (file transfer), Telnet (remote
login), SMTP (email) - Apps using UDP
- streaming media, teleconferencing, DNS, Internet
telephony
- Goal data transfer between end systems
- same as before!
- UDP - User Datagram Protocol RFC 768
- connectionless
- unreliable data transfer
- no flow control
- no congestion control
15Internet Design Philosophy
- Simple core, complex edge
- Best effort service
- Great support for heterogeneity
- Dynamic by design
- One network for many, many purposes
- Designed primarily for non-real-time text traffic
- with no QoS requirements other than reliable
delivery. - Q Does this explain why the internet does not
work well for many applications?
16Protocol Layers
- Networks are complex!
- many pieces
- hosts
- routers
- links of various media
- applications
- protocols
- hardware, software
- Pros and cons of layering
- explicit structure allows identification,
relationship of complex systems pieces - modularization eases maintenance, updating of
system - change of implementation of layers service
transparent to rest of system - Inefficient?
17Internet protocol stack
- application supporting network applications
- FTP, SMTP, STTP
- transport host-host data transfer
- TCP, UDP
- network routing of datagrams from source to
destination - IP, routing protocols
- link data transfer between neighboring network
elements - PPP, Ethernet
- physical bits on the wire
18Encapsulation
source
message
application transport network link physical
segment
datagram
frame
switch
destination
application transport network link physical
router
19Internet History
1961-1972 Early packet-switching principles
- 1972
- ARPAnet demonstrated publicly
- NCP (Network Control Protocol) first host-host
protocol - first e-mail program
- ARPAnet has 15 nodes
- 1961 Kleinrock - queueing theory shows
effectiveness of packet-switching - 1964 Baran - packet-switching in military nets
- 1967 ARPAnet conceived by Advanced Research
Projects Agency - 1969 first ARPAnet node operational
20Internet History
1972-1980 Internetworking, new and proprietary
nets
- 1970 ALOHAnet satellite network in Hawaii
- 1973 Metcalfes PhD thesis proposes Ethernet
- 1974 Cerf and Kahn - architecture for
interconnecting networks - late70s proprietary architectures DECnet, SNA,
XNA - late 70s switching fixed length packets (ATM
precursor) - 1979 ARPAnet has 200 nodes
- Cerf and Kahns internetworking principles
- minimalism, autonomy - no internal changes
required to interconnect networks - best effort service model
- stateless routers
- decentralized control
- define todays Internet architecture
21Internet History
1990, 2000s commercialization, the Web, new apps
- Late 1990s 2000s
- more killer apps instant messaging, P2P file
sharing - network security to forefront
- est. 50 million host, 100 million users
- backbone links running at Gbps
- Early 1990s ARPAnet decommissioned
- 1991 NSF lifts restrictions on commercial use of
NSFnet (decommissioned, 1995) - early 1990s Web
- hypertext Bush 1945, Nelson 1960s
- HTML, HTTP Berners-Lee
- 1994 Mosaic, later Netscape
- late 1990s commercialization of the Web
22Next the programming API
- Reading Ch 2.7-2.8.
- TCP vs UDP
23Socket programming
Goal learn how to build client/server
application that communicate using sockets
- 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
24Socket-programming using TCP
- Socket a door between application process and
end-end-transport protocol (UCP or TCP) - TCP service reliable transfer of bytes from one
process to another
controlled by application developer
controlled by application developer
controlled by operating system
controlled by operating system
internet
host or server
host or server
25Socket programming with TCP
- Client must contact server
- server process must first be running
- server must have created socket (door) that
welcomes clients 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)
26Client/server socket interaction TCP
Server (running on hostid)
Client
27Stream jargon
- A stream is a sequence of characters that flow
into or out of a process. - An input stream is attached to some input source
for the process, e.g., keyboard or socket. - An output stream is attached to an output source,
e.g., monitor or socket.
Client process
client TCP socket
28Socket programming with TCP
- Example client-server app
- 1) client reads line from standard input
(inFromUser stream) , sends to server via socket
(outToServer stream) - 2) server reads line from socket
- 3) server converts line to uppercase, sends back
to client - 4) client reads, prints modified line from
socket (inFromServer stream)
29Example Java client (TCP)
import java.io. import java.net. class
TCPClient public static void main(String
argv) throws Exception String
sentence String modifiedSentence
BufferedReader inFromUser new
BufferedReader(new InputStreamReader(System.in))
Socket clientSocket new
Socket("hostname", 6789)
DataOutputStream outToServer new
DataOutputStream(clientSocket.getOutputStream())
Create input stream
Create client socket, connect to server
Create output stream attached to socket
30Example Java client (TCP), cont.
Create input stream attached to socket
BufferedReader inFromServer
new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()))
sentence inFromUser.readLine()
outToServer.writeBytes(sentence '\n')
modifiedSentence inFromServer.readLine()
System.out.println("FROM SERVER "
modifiedSentence) clientSocket.close()
Send line to server
Read line from server
31Example Java server (TCP)
import java.io. import java.net. class
TCPServer public static void main(String
argv) throws Exception String
clientSentence String capitalizedSentence
ServerSocket welcomeSocket new
ServerSocket(6789) while(true)
Socket connectionSocket
welcomeSocket.accept()
BufferedReader inFromClient new
BufferedReader(new
InputStreamReader(connectionSocket.getInputStream(
)))
Create welcoming socket at port 6789
Wait, on welcoming socket for contact by client
Create input stream, attached to socket
32Example Java server (TCP), cont
DataOutputStream outToClient
new DataOutputStream(connectionSocket.get
OutputStream()) clientSentence
inFromClient.readLine()
capitalizedSentence clientSentence.toUpperCase()
'\n' outToClient.writeBytes(capit
alizedSentence)
Create output stream, attached to socket
Read in line from socket
Write out line to socket
End of while loop, loop back and wait for another
client connection
33Socket programming with UDP
- UDP no connection between client and server
- no handshaking
- sender explicitly attaches IP address and port of
destination to each packet - server must extract IP address, port of sender
from received packet - UDP transmitted data may be received out of
order, or lost
34Client/server socket interaction UDP
Server (running on hostid)
35Example Java client (UDP)
Client process
Input receives packet (recall thatTCP received
byte stream)
Output sends packet (recall that TCP sent byte
stream)
client UDP socket
36Example Java client (UDP)
import java.io. import java.net. class
UDPClient public static void main(String
args) throws Exception
BufferedReader inFromUser new
BufferedReader(new InputStreamReader(System.in))
DatagramSocket clientSocket new
DatagramSocket() InetAddress IPAddress
InetAddress.getByName("hostname")
byte sendData new byte1024 byte
receiveData new byte1024 String
sentence inFromUser.readLine() sendData
sentence.getBytes()
Create input stream
Create client socket
Translate hostname to IP address using DNS
37Example Java client (UDP), cont.
Create datagram with data-to-send, length, IP
addr, port
DatagramPacket sendPacket new
DatagramPacket(sendData, sendData.length,
IPAddress, 9876) clientSocket.send(send
Packet) DatagramPacket receivePacket
new DatagramPacket(receiveData,
receiveData.length) clientSocket.receiv
e(receivePacket) String
modifiedSentence new
String(receivePacket.getData())
System.out.println("FROM SERVER"
modifiedSentence) clientSocket.close()
Send datagram to server
Read datagram from server
38Example Java server (UDP)
import java.io. import java.net. class
UDPServer public static void main(String
args) throws Exception
DatagramSocket serverSocket new
DatagramSocket(9876) byte
receiveData new byte1024 byte
sendData new byte1024 while(true)
DatagramPacket
receivePacket new
DatagramPacket(receiveData, receiveData.length)
serverSocket.receive(receivePacket)
Create datagram socket at port 9876
Create space for received datagram
Receive datagram
39Example Java server (UDP), cont
String sentence new
String(receivePacket.getData())
InetAddress IPAddress receivePacket.getAddress()
int port receivePacket.getPort()
String
capitalizedSentence sentence.toUpperCase()
sendData capitalizedSentence.getBytes()
DatagramPacket sendPacket
new DatagramPacket(sendData,
sendData.length, IPAddress,
port) serverSocket.send(s
endPacket)
Get IP addr port , of sender
Create datagram to send to client
Write out datagram to socket
End of while loop, loop back and wait for another
datagram