COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016.

Slides:



Advertisements
Similar presentations
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Advertisements

Network Services Networking for Home & Small Business.
(4.4) Internet Protocols Layered approach to Internet Software 1.
COEN 445 Communication Networks and Protocols Lab 4
ECE 4450:427/527 - Computer Networks Spring 2015 Dr. Nghi Tran Department of Electrical & Computer Engineering Lecture 8: Application Layer Dr. Nghi Tran.
HTTP: the hypertext transfer protocol
Hypertext Transfer Protocol Kyle Roth Mark Hoover.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
TCP/IP summary Skills: none IT concepts: review This work is licensed under a Creative Commons Attribution-Noncommercial- Share Alike 3.0 License.
1 Java Networking – Part I CS , Spring 2008/9.
Layer 7- Application Layer
Introduction to Management Information Systems Chapter 5 Data Communications and Internet Technology HTM 304 Fall 07.
McGraw-Hill©The McGraw-Hill Companies, Inc., 2004 Application Layer PART VI.
TCP/IP Protocol Suite 1 Chapter 11 Upon completion you will be able to: User Datagram Protocol Be able to explain process-to-process communication Know.
How Clients and Servers Work Together. Objectives Learn about the interaction of clients and servers Explore the features and functions of Web servers.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
Process-to-Process Delivery:
INTRODUCTION TO WEB DATABASE PROGRAMMING
Lightning Talk Fred Rodriguez Aakash Juneja CPSC 473 March 16, 2012.
TCP/IP protocols Communication over Internet is mostly TCP/IP (Transmission Control Protocol over Internet Protocol) TCP/IP "stack" is software which allows.
CHAPTER 2 PCs on the Internet Suraya Alias. The TCP/IP Suite of Protocols Internet applications – client/server applications The client requested data.
 TCP/IP is the communication protocol for the Internet  TCP/IP defines how electronic devices should be connected to the Internet, and how data should.
Socket Lab Info. Computer Network. Requirement Use TCP socket to implement a pair of programs, containing a server and a client. The server program shall.
Web application architecture
1 Computer Communication & Networks Lecture 28 Application Layer: HTTP & WWW p Waleed Ejaz
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 Network Services Networking for Home and Small Businesses – Chapter.
HTTP HTTP stands for Hypertext Transfer Protocol. It is an TCP/IP based communication protocol which is used to deliver virtually all files and other.
Network Services Networking for Home & Small Business.
CSCI 6962: Server-side Design and Programming Web Services.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Chapter 1: The Internet and the WWW CIS 275—Web Application Development for Business I.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail  SMTP,
Operating Systems Recitation 9, May 19-20, Iterative server Handle one connection request at a time. Connection requests stored in queue associated.
Data Streams David Meredith Source Chapter 19 of – Shiffman, D. (2008). Learning Processing. Morgan Kaufmann, Burlington, MA. ISBN:
Sockets process sends/receives messages to/from its socket
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
CS 241 Section (04/19/12). MP8  Web Server  Due: Tuesday, May 1 st, 11:59pm  What will you be doing?  Creating a web-server in C that serves HTML.
Dr. John P. Abraham Professor University of Texas Pan American Internet Applications and Network Programming.
Internet Protocol B Bhupendra Ratha, Lecturer School of Library and Information Science Devi Ahilya University, Indore
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
ECEN “Internet Protocols and Modeling”, Spring 2012 Course Materials: Papers, Reference Texts: Bertsekas/Gallager, Stuber, Stallings, etc Class.
Socket Programming Introduction. Socket Definition A network socket is one endpoint in a two-way communication flow between two programs running over.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
INTRO TO NETWORKING. OVERVIEW Transmitting data Across a physical media Ethernet Wi-fi Bluetooth Etc. Cross-platform (usually) Challenges Varying network.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 K. Salah Application Layer Module K. Salah Network layer duties.
Process-to-Process Delivery:
Network Programming. These days almost all devices.
IST 201 Chapter 11 Lecture 2. Ports Used by TCP & UDP Keep track of different types of transmissions crossing the network simultaneously. Combination.
COMP2322 Lab 4 Socket Programming
CISC103 Web Development Basics: Web site:
Networking COMP
Working at a Small-to-Medium Business or ISP – Chapter 7
HTTP: the hypertext transfer protocol
Web Development & Design Chapter 1, Sections 4, 5 & 6
Working at a Small-to-Medium Business or ISP – Chapter 7
CISC103 Web Development Basics: Web site:
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
The Internet and HTTP and DNS Examples
Working at a Small-to-Medium Business or ISP – Chapter 7
Starting TCP Connection – A High Level View
Web Server Technology Unit 10 Website Design and Development.
ECE 4450:427/527 - Computer Networks Spring 2017
Internet Applications & Programming
Computer Networks Protocols
Transport Protocols Relates to Lab 5. An overview of the transport protocols of the TCP/IP protocol suite. Also, a short discussion of UDP.
Presentation transcript:

COMP2322 Lab 4 Socket Programming Toby Lam March 2, 2016

2 Requirement Experience in Python Programming Python for Programmers  ogrammers ogrammers  Learn Python Online  

3 Simple Example Suppose I am interested in knowing the latitude and longitude of The Hong Kong Polytechnic University I can enter the following URL in the browser to obtain the information (in JSON format)  ress=The Hong Kong Polytechnic University&sensor=false&region=Hong Kong

4

5 Client/Server Model

6 Examples of Client  Google Chrome, Firefox Examples of Server  Apache, IIS

7 Make a Raw HTTP Connection

8 socket in Python Instead of making an HTTP request through httplib package  We can make the request by using socket socket – support basic network communications on an IP network  Low-level approach Raw network communication  A matter of sending and receiving strings

9 Make a Request By Socket

10 Network Sockets Used to identify particular processes (programs) on particular machines Network Socket is composed of 2 numbers:  IP address – machine identifier  Port number – process identifier Well-known ports:  25 – SMTP ( ), 80 - HTTP (web), 110 – POP3 ( ), 443 – HTTPS (secure web)

11 Network Sockets Socket() used in previous example is NOT the lowest protocol level  The layers below the socket() are: Transmission Control Protocol (TCP)  One alternative to TCP is UDP (we focus on TCP in this lab) Internet Protocol (IP) Link layer

12 “Passive” Listening Socket VS Active “Connected” Socket Server  The server is a machine that is ready to receive connections  It holds the address and the port number Passive Listening Socket  It DOES NOT represent any actual network conversation <= no data can be received / sent by this kind of port! (Q: HOW it works then ???)

13 “Passive” Listening Socket VS Active “Connected” Socket When the server get the request from the passive listening socket  Server checks with the OS willingness to receive incoming connections  If NO, drop the request  If YES, an active connected socket is then created This socket is bounded to one remote conversation partner Example: A busy web server, there is a thousand active sockets all bound to its public IP address at port 80

14 A Simple TCP Client and Server

15 A Simple TCP Client and Server

16

17 Limitation At the moment, the message must be fixed in 16 characters (octets)! Solution:  Client side, before sending the message 1)Determine the length of the message L [Assume max. number of length is 255] – Add L at the beginning of the message 2) Send the new message to server  Server side, after received the message 1)Extract the length of the message (first 3 characters) 2)Read the rest of the message with the proper length

18 Modified TCP Client and Server

19 Modified TCP Client and Server

20

21 Lab Exercise (Total mark: 50) [1 / 2] 1. Create 2 python files (10 marks) – Client file - client_studentID.py – Server file - server_studentID.py – E.g. if my student ID is d, name the client file as client_ d.py 2. Provide your full name and student ID (10 marks) – At the beginning of each python program, by using program comment, provide the following information Your full name Your student ID

Lab Exercise (Total mark: 50) [2 / 2] 3. Create a simple instant messaging system (25 marks) – The messaging system should let the client and server send the message in one by one approach (20 marks) (more detail description is shown in next page) – Coding - easy to read (5 marks) – if there is any syntax error in your programs (i.e. cannot run), ZERO mark will be given in this section 4. Submission (5 marks) – Submit two python programs to before the submission deadline (Monday, 14 March 2016, at noon) It is not required to zip the files! 22

23 Message in one by one approach Message in one by one approach IS NOT the same as common messaging platform!! It works like this: 1. Server is waiting for connection 2. Client is connected to Server 3. Client sends message 4. Server receives message 5. Server sends message 6. Client receives message 7. Go back to (3) until Client/Server sends message “BYEBYE”

24

25

26 Reference J. Goerzen and B. Rhodes, Foundations of Python Network Programming: The comprehensive guide to building network applications with Python, Second Edition, Apress, 2010