490 likes | 502 Views
Learn about network basics, protocols, and the TCP/IP protocol suite in client-server programming. Understand connection-oriented and connectionless communication.
E N D
Welcome to UFCEKP-20-2Client Server Programming Jin Sa http://www.cems.uwe.ac.uk/~jsa/ClientServer07/ Julia Dawson http://squanderette.co.uk/ufcekp/ Client-Server Programming
Books • “Java Network Programming”, 3rd edition, by Elliotte Rusty Harold, published by O‘Reilly • "Distributed Computing" M L Liu • “Distributed Systems Concepts and Design”, 4th edition, by Coulouris, Dollimore and Kindberg, published by Addison Wesley. Client-Server Programming
Delivery and Assessment • One lecture and one practical per week • Assessment consists of one exam and one assignment. Assignment hand-in date is in the second semester. Client-Server Programming
Contents – semester 1 plan Client-Server Programming
Contents – semester 2 plan Client-Server Programming
General idea of the module Client server concepts Java knowledge required to do client server programming Protocol Basic network concepts Some basic client server programming mechanisms, e.g. socket, datagram, RMI Basic java, thread/ concurrency, gui Smtp,http, user defined Some client server applications, e.g. day time, echo, “knock-knock”, Email Client-Server Programming
Block 1: Basic Network Concepts Client-Server Programming
Outline of block 1 • Network basics • Types of networks • Protocols • Network architecture • TCP/IP protocols suite • Connection-oriented and connectionless communications • Network resources • Identification of network resources • Addressing an Internet host • Addressing a process running on a host • Addressing a Wed document Client-Server Programming
Distributed system • In Coulouris et al “We define a distributed system as one in which hardware or software components located at networked computers communicate and coordinate their actions only by passing messages.” • Examples are internet, intranet, technology based on mobile devices Client-Server Programming
Network Basics Client-Server Programming
A typical intranet Client-Server Programming
Portable and handheld devices in a distributed system Client-Server Programming
Some types of network • Local area networks (LAN), e.g. Ethernet • Wide area network (WAN) • Internetwork, e.g. Internet • Wireless local area network (WLAN), e.g. WiFi Client-Server Programming
Network standards and protocols • On public networks such as the Internet, it is necessary for a common set of rules to be specified for the exchange of data. • Such rules, called protocols, specify such matters as the formatting and semantics of data, flow control, error correction. Client-Server Programming
Protocols • In the context of communications, a protocol is a set of rules that must be observed by the participants. • In communications involving computers, protocols must be formally defined and precisely implemented. For each protocol, there must be rules that specify the followings: • How is the data exchanged encoded? • How are events (sending , receiving) synchronized so that the participants can send and receive in a coordinated order? Client-Server Programming
Network architecture • Network hardware transfers electronic signals,which represent a bit stream, between two devices. • Modern day network applications require an application programming interface (API) which masks the underlying complexities of data transmission. • A layered network architecture allows the functionalities needed to mask the complexities to be provided incrementally, layer by layer. • Actual implementation of the functionalities may not be clearly divided by layer. Client-Server Programming
Network architecture The division of the layers is conceptual: the implementation of the functionalities need not be clearly divided. The conceptual division serves at least two useful purposes : • it allows protocols to be specified systematically 2. it allows programs to be written in terms of logical data flow Client-Server Programming
Protocol layers in the ISO model Client-Server Programming
The TCP/IP protocol suite • The Transmission Control Protocol/Internet Protocol suite is a set of network protocols which supports the following network architecture. • It is currently the protocol suite employed on the Internet. • Java’s network classes are based on the TCP/IP protocol Client-Server Programming
The TCP/IP protocol suite • The Internet layer implements the Internet Protocol, which provides the functionalities for allowing data to be transmitted between any two hosts on the Internet, e.g. Internet protocol • The Transport layer delivers the transmitted data to a specific process running on an Internet host, e.g. TCP, UDP • The Application layer supports the programming interface used for building a program, e.g. FTP, HTTP Client-Server Programming
Connection-oriented and connectionless communication Client-Server Programming
In class example Using connection-oriented communication, it takes 50 seconds to establish a connection, after which a packet of up to 10 characters can be sent in 1.0 seconds over the connection, in either direction. Using connectionless communication, a packet of up to 10 characters can be sent in 1.2 seconds. Suppose A and B exchange messages on this network. A initiates the communication by sending B a message of 200 characters, which are partitioned into 20 packets. In reply, B sends a message of 50 characters, which are partitioned into 5 packets. Client-Server Programming
Example -- cont Work out how long the session between A and B last using connection-oriented communication. Work out how long the session between A and B last using connectionless communication. Client-Server Programming
Example -- cont Time for connection-oriented: ConnectionTime + time for A to send + time for B to send = 50 + 1.0 * 20 + 1.0 * 5 = 75 seconds Time for connectionless: Time for A to send + time for B to send = 1.2 * 20 + 1.2 * 5 =30 seconds Client-Server Programming
Example -- cont Now suppose A sends B a message of 3000 characters, which are partitioned into 300 packets. In reply, B sends a message of 50 characters, which are partitioned into 5 packets. Work out which form of communication takes less time. Client-Server Programming
Example -- cont Time for connection-oriented: ConnectionTime + time for A to send + time for B to send = 50 + 1.0 * 300 + 1.0 * 5 = 355 seconds Time for connectionless: Time for A to send + time for B to send = 1.2 * 300 + 1.2 * 5 =366 seconds Client-Server Programming
Network resources • Network resources are resources available to the participants of a distributed computing community. • Network resources include hardware such as computers and equipment, and software such as processes, email mailboxes, files, web documents. • An important class of network resources is network services such as the World Wide Web and file transfer (FTP), which are provided by specific processes running on computers. Client-Server Programming
Identification of network resources One of the key challenges in distributed computing is the unique identification of resources available on the network, such as hosts and web documents. • Addressing an Internet Host • Addressing a process running on a host • Addressing web contents: URL Client-Server Programming
Addressing an Internet Host Client-Server Programming
The Internet topology • The internet consists of an hierarchy of networks, interconnected via a network backbone. • Each network has a unique network address. • Computers, or hosts, are connected to a network. Each host has a unique ID within its network. • Each process running on a host is associated with zero or more ports. A port isa logical entity for data transmission. Client-Server Programming
The Internet topology Client-Server Programming
The Internet addressing scheme • In IP version 4, each address is 32 bit long. • The address space accommodates 232 (4.3 billion)addresses in total. • Addresses are divided into 5 classes (A through E) Client-Server Programming
The Internet address scheme • For human readability, Internet addresses are written in a dotted decimal notation: nnn.nnn.nnn.nnn, where each nnn group is a decimal value in the range of 0 through 255 Client-Server Programming
Example 1: Suppose the dotted-decimal notation for a particular Internet address is129.65.24.50. The 32-bit binary expansion of the notation is as follows: Client-Server Programming
Example 1 - continued Since the leading bit sequence is 10, the address is a Class B address. Within the class, the network portion is identified by the remaining bits in the first two bytes, that is, 00000101000001, and the host portion is the values in the last two bytes, or 0001100000110010. For convenience, the binary prefix for class identification is often included as part of the network portion of the address, so that we would say that this particular address is at network 129.65 and then at host address 24.50 on that network. Client-Server Programming
Example 2 (skip) Given the address 224.0.0.1, one can expand it as follows: The binary prefix of 1110 signifies that this is class D, or multicast, address. Data packets sent to this address should therefore be delivered to the multicast group 0000000000000000000000000001. Client-Server Programming
IP version 6 addressing scheme • Each address is 128-bit long. Client-Server Programming
The Domain Name System (DNS) For user friendliness, each Internet address is mapped to a symbolic name, using the DNS, e.g., www.cems.uwe.ac.uk www.cs.bris.ac.uk Client-Server Programming
The Domain Name System . For network applications, a domain name must be mapped to its corresponding Internet address. . Processes known as domain name system servers provide the mapping service, based on a distributed database of the mapping scheme. Client-Server Programming
Name lookup and resolution • If a domain name is used to address a host, its corresponding IP address must be obtained for the lower-layer network software. • The mapping, or name resolution, must be maintained in some registry. • For runtime name resolution, a network service is needed. Client-Server Programming
Addressing a process running on a host Client-Server Programming
Logical ports Client-Server Programming
Identifying processes with ports • Domain names (or its corresponding IP addresses) locate computers (hosts) • The logical entity port is used to identify a process running on a host • In the transport layer, both TCP and UDP use ports on each host for dispatching data to processes • A process that wishes to exchange data with another process must be assigned a port • To send data to a process associated with port p on host H, an applicatin programm must address the data to (H,p) in the code. Client-Server Programming
Well-known ports Client-Server Programming
Addressing a Web Document Client-Server Programming
The Uniform Resource Identifier (URI) • Resources to be shared on a network need to be uniquely identifiable. • On the Internet, a URI is a character string which allows a resource to be located. • There are two types of URIs: • URL (Uniform Resource Locator) points to a specific resource at a specific location • URN (Uniform Resource Name) points to a specific resource at a nonspecific location. Client-Server Programming
URL A URL has the format of: protocol://host address[:port]/ directory path/file name#section Client-Server Programming
A sample URL: • http://www.cems.uwe.ac.uk/~jsa/Internetics/overall.html#intro • Some conventions: • Port 80 is the default port for http • ~fred by convetion is in a subdirectory of public_html of user fred’s home directory • Path name ends with a directory refers to the file index.html in that directory section name protocol host name directory name file name Client-Server Programming
Review questions • Explain the concept of connection-oriented communication and connectionless communication • Understand the concept of network resources • Explain Internet addressing scheme • Understand the concept of domain names • Understand URL • Understand how to address Internet host; how to address a running process; how to address a web document Client-Server Programming