Verteilte Systeme 2. Transport Layer (Wdh) ISO- Referenzmodell OSI- Modell = Open Systems Interconnection Referenzmodell! Protokollfamilien Realisierung Ebene 1-3: Hardware (Firmware) Netzwerk- Controller Ebene 4-7: Software (Verteilte) Anwendungen 7. Application Layer 6. Presentation Layer 5. Session Layer 4. Transport Layer 3. Network Layer 2. Link Layer 1. Physical Layer Kommunikationsnetzwerk Anwendungsorientierung Netzwerkorientierung 1
Ebene 4: Transport Layer Ende- zu- Ende- Protokoll Angabe der empfangenden Anwendung Meist zwei Protokolle: Verbindungslos (Datagramm) Verbindung (Reliable Stream) Aufgaben Quittungsbetrieb Sequenznummern Eliminierung von Duplikaten Flußkontrolle Ausnutzung der Speicher- kapazität des Mediums... Speicherfähigkeit des Mediums Abstand zur Erde (April 2013): 18481 Millionen Kilometer Roundtrip- Zeit: 34h, 13min, 48s Raumsonde Voyager 2 Annahme 100 Mbit pro Sekunde: 1.4 Tbyte Speicherkapazität 2
Ebene 5: Session Layer Kommunikationssitzungen Sicherungspunkte Recovery Wachsende Bedeutung Ebene 6: Presentation Layer Umwandlung von Datenformaten Offene Systeme Heterogenität Beispiele XDR (SUN- RPC), ASN.1, SOAP Verschlüsselung 3
Ebene 7: Application Layer Spezifische Anwendungsprotokolle Beispiele FTP - File Transfer Protocol rlogin - Remote Login NFS - Network File System NIS - Network Information System SMTP - Simple Mail Transfer Protocol X.400, POP.3,... - Ebenfalls Mail- Protokolle HTTP - Hypertext Transfer Protocol... Transport Layer 4
Motivation UDP and TCP are the transport layer protocols UDP is connection- less, notification TCP is connection- oriented, reliable stream IP is network- layer protocol Host to host protocol Addressing, routing, and other network- centric functionality Well suited to form networks of networks Overview in Relation to OSI Model Application-Layer Protocols FTP, TELNET, SMTP, DNS, NSP, NTP, HTTP,... Layer 4-7 RPC Protocols PVM, MPI, Corba, DCE,... UDP TCP Layer 3 IP / ICMP / ARP / RARP / Routing Layer 1-2 IEEE 802.X X.25 5
IP Address (IPv4) Class A: 2 7-2 networks with at most 2 24-2 computers 0 netid(7) hostid(24) Class B: 2 14-2 networks with at most 2 16-2 computers 1 0 netid(14) hostid(16) Class C: 2 21-2 networks with at most 2 8-2 computers 1 1 0 netid(21) hostid(8) Bit 32 24 16 8 Bit 1 IPv6 128 Bit addresses Unicast and Multicast Anycast Any member of a given group receives message Usually the closest one Accelerators (Akamai), Proxies, DNS,... 6
UDP UDP = User Datagram Protocol End to End version of IP Introduces port number to identify sending and receiving process Best effort Loss of messages possible Message may be received out of order No flow control 8 byte header Maximum size of UDP packet = 64 kbyte including header UDP supports multicast Ping Pong Using UDP and TCP in applications Runtime libraries for all common languages available Java and.net provide easy to use abstractions Lots of details needed in case of C/C++ 7
Details Two C# program are sending a virtual ball back and forth using UdpClient First player creates an UdpClient and lets the operating system decide on the port number Then it prints hostname and port number to allow the second to connect Second connects and sends a ball Both player send ball back and forth for a given number of turns Solution UdpClient covers most functionality Must derive from UdpClient to access protected Client property required to derive port number First Player: p = new UdpClient(0); Print p.hostname and p.portnumber while (turns-- > 0) { ball = p.receive(ref peer); Sleep for some time; p.send(ball,peer); } Second Player: p = new UdpClient(hostname,port); p.send(ball,player1); while (turns-- > 0) { ball = p.receive(ref peer); Sleep for some time; p.send(ball,peer); } 8
Playing Ping Pong TCP TCP = Transmission Control Protocol Reliable Stream Connection- oriented Establish a connection before being able to send Full- Duplex Both communication partners can send and receive Send and receive granularity may differ TCP endpoint looks like a handle to read from and write to file 9
Connection Establishment Asymmetric solution One partner is awaiting connection requests (passive) This is called the server The other partner is initiating the connection (active) This one is typically called client Client Client Server Server Server has a dedicated end point just to receive connect requests Client 2 Each time a connection is accepted, a new end point just for communication with this one client is created Client Server Connection to Client Compute A Sum Remotely 4, 3, 22, 13 Client Server 42.NET based solution in C# 10
Server Client 11
Example in plain C Example from http://cs.baylor.edu/~donahoo/practical/csockets/code/tcpechoserver.c D.E. Comer, D.L. Stevens Internetworking with TCP/IP, Volume I- III Prentice- Hall, 1993 W. Stevens TCP/IP Illustrated, Volume 1: The Protocols (1994) TCP/IP Illustrated, Volume 3: T/TCP, HTTP,... (1996) Addison- Wesley G. Wright, W. Stevens TCP/IP Illustrated, Volume 2: The Implementation Addison- Wesley, 1995 A. Jones, J. Ohlund, L. Olson Network Programming for the Microsoft.NET Framework Microsoft Press, 2003 Charles M. Kozierok The TCP/IP Guide No Starch Press, 2005 References 12