Socket Programming Project Intro to transport layer - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Socket Programming Project Intro to transport layer

Description:

DatagramSocket clientSocket = new DatagramSocket ... after creating server, you can request file using a browser (e.g. IE explorer) ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 19
Provided by: JimKurosea175
Category:

less

Transcript and Presenter's Notes

Title: Socket Programming Project Intro to transport layer


1
Socket Programming ProjectIntro to transport
layer
EECS 325/425, Fall 2005 September 21
2
Chapter 2 Application layer
  • 2.1 Principles of network applications
  • 2.2 Web and HTTP
  • 2.3 FTP
  • 2.4 Electronic Mail
  • SMTP, POP3, IMAP
  • 2.5 DNS
  • 2.6 P2P file sharing
  • 2.7 Socket programming with TCP
  • 2.8 Socket programming with UDP
  • 2.9 Building a Web server

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

4
Client/server interaction UDP (Java)
Server (running on hostid)
5
Example Java client (UDP)
Client process
Input receives packet (TCP received byte
stream)
Output sends packet (TCP sent byte stream)
client UDP socket
6
Example Javaserver (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)
  • String sentence new
    String(receivePacket.getData())

Create datagram socket at port 9876
Create space for received datagram
Receive datagram
Get IP addr and 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
7
Example Javaclient (UDP)
  • import java.io.
  • import java.net.
  • class UDPClient
  • public static void main(String args) throws
    Exception
  • BufferedReader inFromUser
  • new BufferedReader(new InputStreamReader(S
    ystem.in))
  • DatagramSocket clientSocket new
    DatagramSocket()
  • InetAddress IPAddress InetAddress.getByNam
    e(servername")
  • 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
Create datagram with data-to-send, length, IP
addr, port
Send datagram to server
Read datagram from server
8
Chapter 2 Summary
  • Application architectures
  • client-server
  • P2P
  • application service requirements
  • reliability, bandwidth, delay
  • Internet transport service model
  • connection-oriented, reliable TCP
  • unreliable, datagrams UDP
  • specific protocols
  • HTTP
  • FTP
  • SMTP, POP, IMAP
  • DNS
  • socket programming
  • Protocols
  • typical request/reply message exchange
  • client requests info or service
  • server responds with data, status code
  • message formats
  • headers fields giving info about data
  • data info being communicated
  • control vs. data msgs
  • in-band, out-of-band
  • stateless vs. stateful
  • reliable vs. unreliable msg transfer
  • complexity at network edge

9
Project 1
  • EECS 325 building a Web server, or design a Web
    crawler
  • EECS 425 design a Web crawler, or if you have
    other ideas
  • Due 10/21, Friday

10
Project 1
  • EECS 325 building a Web server, or design a Web
    crawler
  • EECS 425 design a Web crawler, or if you have
    other ideas
  • Due 10/21, Friday

11
Building a simple Web server (1A)
  • creates HTTP response message
  • header lines file
  • sends response to client
  • after creating server, you can request file using
    a browser (e.g. IE explorer)
  • Give the host name (IP)
  • Port number
  • E.g. http//vorlon.case.edu80/
  • handles multiple HTTP requests
  • multi-process or multi-threaded
  • accepts HTTP 1.0 request
  • parses header
  • obtains requested file from servers file system

12
Building a simple Web crawler (1B)
  • Important
  • Make sure your crawler eventually stops
  • Try to limit the request rate (to fairly low)
  • Introduce some delay between requests
  • The crawler may run for a long time
  • Sends HTTP requests to many Web servers
  • Starts with a few servers (a few pages)
  • Recursively discovers more links, and more
    servers
  • Versions of servers
  • Response time of servers
  • Report statistics of the servers

13
Example
  • sxj63_at_easy telnet www.cs.ucla.edu 80
  • Trying 131.179.128.22...
  • Connected to Pike.cs.ucla.edu.
  • Escape character is ''.
  • GET /index.html HTTP/1.0
  • HTTP/1.1 200 OK
  • Date Wed, 21 Sep 2005 164851 GMT
  • Server Apache/1.3.33 (Unix)
  • Last-Modified Tue, 20 Sep 2005 225557 GMT
  • ETag "64341-754e-4330937d"
  • Accept-Ranges bytes
  • Content-Length 30030
  • Connection close
  • Content-Type text/html

14
Chapter 3 Transport Layer
  • learn about transport layer protocols in the
    Internet
  • UDP connectionless transport
  • TCP connection-oriented transport
  • TCP congestion control
  • Our goals
  • understand principles behind transport layer
    services
  • multiplexing/demultiplexing
  • reliable data transfer
  • flow control
  • congestion control

15
Chapter 3 outline
  • 3.1 Transport-layer services
  • 3.2 Multiplexing and demultiplexing
  • 3.3 Connectionless transport UDP
  • 3.4 Principles of reliable data transfer
  • 3.5 Connection-oriented transport TCP
  • segment structure
  • reliable data transfer
  • flow control
  • connection management
  • 3.6 Principles of congestion control
  • 3.7 TCP congestion control
  • A few relevant topics

16
Transport services and protocols
  • provide logical communication between app
    processes running on different hosts
  • transport protocols run in end systems
  • send side breaks app messages into segments,
    passes to network layer
  • rcv side reassembles segments into messages,
    passes to app layer
  • does not control resources in the network (links
    and routers) does not control application
    behavior either
  • more than one transport protocol available to
    apps
  • Internet TCP and UDP

17
Transport vs. network layer
  • network layer logical communication between
    hosts
  • transport layer logical communication between
    processes
  • relies on, enhances, network layer services

Processes
Processes
transport layer
OS kernel
OS kernel
network layer
Host A
Host B
18
Internet transport-layer protocols
  • reliable, in-order delivery (TCP)
  • congestion control
  • flow control
  • connection setup
  • unreliable, unordered delivery UDP
  • no-frills extension of best-effort IP
  • services not available
  • delay guarantees
  • bandwidth guarantees
  • how to provide them?
Write a Comment
User Comments (0)
About PowerShow.com