Computer Networks with (Network Programming)
|
|
- Junior Shepherd
- 6 years ago
- Views:
Transcription
1 Computer Networks with (Network Programming) Introduction to Programming with UDP Lecture #8 Department of Electrical and Electronics Engineering Çukurova University TCP vs UDP Both use port numbers Application-specific construct serving as a communication endpoint 16-bit unsigned integer, thus ranging from 0 to ) To provide end-to-end transport UDP: User Datagram Protocol No acknowledgements No retransmissions Out of order, duplicates possible connectionless, i.e., app indicates destination for each packet TCP: Transmission Control Protocol Reliable byte-stream channel (in order, all arrive, no duplicates) similar to file I/O flow control, connection-oriented, bidirectional Connectionless In network, connectionless describes communication between two network end points in which a message can be sent from one end point to another without prior arrangement. Connectionless sockets allow the sending of messages in self-contained packets. A single read method reads the entire message sent by a single sent method. The User Datagram Protocol (UDP) is one of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. Connectionless-II A connectionless network provides minimal services. Connection-oriented methods may be implemented in the data link layers of the protocol stack and/or in the transport layers of the protocol stack, and the services required by the systems. UDP UDP uses a simple transmission model without implicit hand-shaking dialogues for guaranteeing reliability, ordering, or data integrity. Thus, UDP provides an unreliable service and datagrams may arrive out of order, appear duplicated, or go missing without notice. UDP assumes that error checking and correction is either not necessary or performed in the application, avoiding the overhead of such processing at the network interface level. 1
2 Why is there an UDP? Time-sensitive applications often use UDP because dropping packets is preferable to using delayed packets. Unfortunately, UDP packets are not guaranteed to arrive at their destination. Many factors, such as busy networks, can prevent the packet from making it to its destination. No connection establishment (which can add delay) Socket Overview Uniquely identified by an internet address, an end-to-end protocol (e.g. TCP or UDP) a port number Two types of (TCP/IP) sockets Stream sockets (e.g. uses TCP) provide reliable byte-stream service Datagram sockets (e.g. uses UDP) provide best-effort datagram service messages up to bytes Socket extend the convectional UNIX I/O facilities file descriptors for network communication extended the read and write system calls Sockets 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 application viewpoint UDP provides unreliable transfer of groups of bytes ( datagrams ) between client and server UDP Ports 16-bit unsigned integers associated with UDP connection Used to distinguish different processes running on the same host Ports Proc1 Proc2 Proc3 Proc4 Proc5 A Internet B IP Address 1 IP Address 2 2
3 Four-step process for UDP sending data Send data to the remote device. Start a timer, set for a predetermined period of time. Wait for a response from the remote device. When it arrives, stop the timer and go on with your program. If the timer expires before you receive a response, go back and repeat step 1. After you have repeated step 1 a set number of times (the retry count) without an answer, assume that you cannot communicate with the remote host. To receive data Using UDP Sockets Create a UDP socket Create a local endpoint (Local IP + Local Port) Bind socket to the endpoint Receive data Close socket To send data Create a UDP socket Send data Close socket Connections between methods UdpClient For applications that require a connectionless socket, the UdpClient class provides a simple interface to UDP sockets. UDP is a connectionless protocol, so there is no such thing as a client or server; There are only UDP sockets either waiting for or sending data. You do not need to bind the UDP socket to a specific address and wait for incoming data. The C# API provides UDP streams by the following classes: Methods UdpClient - This class Provides User Datagram Protocol (UDP) network services. UdpClient Constructor: public UdpClient( AddressFamily family ); public UdpClient( int port ); public UdpClient( IPEndPoint localep ); public UdpClient( int port, AddressFamily family ); public UdpClient( string hostname, int port ); IPEndPoint: Initializes a new instance of the IPEndPoint class. public IPEndPoint( long address, int port ) public IPEndPoint( IPAddress address, int port ); void Connect(IPEndPoint remoteep) void Connect(IPAddress ip, int port) void Connect(String host, int port) public byte[] Receive(ref IPEndPoint remoteep) int Send(byte[] data, int size) int Send(byte[] data, int size, IPEndPoint remoteep) int Send(byte[] data, int size, string host, int port) void Close() Establishes a default remote host and default remote port. Returns a UDP datagram sent by a remote host. Sends a datagram to the client. The first version assumes a default remote end-point has been established. Closes the UDP connection. 3
4 Creating UDP Socket The following namespaces should be used Use new keyword to create an object of class Socket Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Socket parameters The AddressFamily member specifies the addressing scheme that a socket instance must use to resolve an address. AddressFamily.InterNetwork indicates that an IP version 4 addresses is expected when a socket connects to an end point. The SocketType parameter specifies the socket type of the current instance. SocketType.Stream indicates a connection-oriented stream and SocketType.Dgram indicates a connectionless stream. The ProtocolType parameter specifies the protocol to be used for the communication. ProtocolType.Udp indicates that the protocol using is UDP. Creating Local Endpoint Resolve local IP addresses using functions Dns.Resolve() and Dns.GetHostName() Create an endpoint at the first IP address and port IPHostEntry hostentry = Dns.Resolve(Dns.GetHostName()); IPEndPoint endpoint = new IPEndPoint(hostEntry.AddressList[0], 11000); Binding Socket to Endpoint Make the socket wait for incoming data at the endpoint created previously s.bind(endpoint); Note: port number can be anything above 1023 UdpClient - receive The Receive() method allows you to receive data on the UDP port. There is no connection session established, so when a UDP port receives data, you do not necessarily know where it came from (unless you specified it in the UdpClient constructor). public byte[] Receive( ref IPEndPoint remoteep ); The Receive method uses the ref modifier to capture the IPEndPoint of the remote client. The local client has to first create a dummy IPEndPoint and then use it to call the Receive method. The Receive method will then replace the content of this dummy IPEndPoint with that of the remote client: Receiving Data Another endpoint is prepared to store remote endpoint information ReceiveFrom() will block until data is received IPEndPoint sender = new IPEndPoint(IPAddress.An EndPoint senderremote = (EndPoint)sender; byte[] msg = new Byte[256]; Console.WriteLine("Waiting for data..."); s.receivefrom(msg, ref senderremote); 4
5 UdpClient Send UdpClient: Send: Sends a UDP datagram to a remote host. The Send() method has three formats. If the UdpClient object references a remote host address and port, the Send() method does not need to specify the destination of the data. public int Send( byte[] dgram, int bytes); public int Send( byte[] dgram, int bytes, IPEndPoint endpoint ); public int Send( byte[] dgram, int bytes, string hostname, int port ); Sending Data Another endpoint is created to specify the receiver IP address and UDP port byte[] msg = Encoding.ASCII.GetBytes("This is a test"); Console.WriteLine("Sending data."); s.sendto(msg, new IPEndPoint(IPAddress.Parse(" "), 11000)); Closing Socket When no longer used, the socket must be closed s.close(); A Simple UDP Application UDP is a connectionless protocol. Therefore, the programmer must do only two things to make a server application ready to send or receive UDP packets: Create a Socket object Bind the socket to a local IPEndPoint After these two actions are taken, the socket can be used to either accept incoming UDP packets on the IPEndPoint, or send outgoing UDP packets to any other device on the network. The UDP Server Although UDP applications are not really servers or clients by strict definition, It creates a Socket object and binds it to a set IPEndPoint object so it can wait for incoming packets: IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9050); Socket newsock = Socket(AddressFamily.InterNetwork, newsock.bind(ipep); Example of Server I class SimpleUdpServer IPEndPoint localep = new IPEndPoint(IPAddress.Any, 9050); UdpClient server = new UdpClient(localEP); Console.WriteLine("Waiting for a client..."); IPEndPoint remoteep = new IPEndPoint(IPAddress.Any, 0); //dummy IP byte[] data; while (true) data = server.receive(ref remoteep); Console.Write("Received from 0: ", remoteep.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, data.length)); server.send(data, data.length, remoteep); 5
6 /* C# Network Programming by Richard Blum Publisher: Sybex ISBN: */ A UDP Client The UDP client program is similar to its partner server program. Because the client does not need to wait on a specific UDP port for incoming data, it does not use the Bind() method. Instead, it employs a random UDP port assigned by the system when the data is sent, and it uses the same port to receive return messages, so that both the server and client programs use the same port numbers. Simple Client I class SimpleUdpClient UdpClient client = new UdpClient(" ", 9050); IPEndPoint remoteep = new IPEndPoint(IPAddress.Any, 0); byte[] data; string input; while (true) Console.Write("Enter message for server or exit to stop: "); client.send(encoding.ascii.getbytes(input), input.length); data = client.receive(ref remoteep); Console.Write("Echo Received from 0: ", remoteep.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, data.length)); client.close(); public class SimpleUdpClient byte[] IPEndPoint ipep = new IPEndPoint( IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork, EndPoint Remote = (EndPoint)sender; Simple Client II int recv = server.receivefrom(data, ref Remote); Console.WriteLine("Message received from 0:", Remote.ToS tring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, re cv)); while(true) server.sendto(encoding.ascii.getbytes(input), Remo te); recv = server.receivefrom(data, ref Remote); Distinguishing UDP Messages One of the best features of UDP is that it addresses the TCP difficulty of handling messages without honoring their boundaries. UDP preserves the message boundaries of all sent messages. Each ReceiveFrom() method call will read only the data sent as a result of a single SendTo() method call. Recall that a UDP socket, once it s created, can receive messages from any UDP client. For the UDP socket to distinguish which client sent which data, it is imperative that each message be self-contained in a single packet and marked with the sending device s IP information. This allows the receiving device to identify both message and sender. Test Udp Server class TestUdpSrvr int recv; byte[] IPEndPoint ipep = new IPEndPoint(IPAddress.Any, 9050); Socket newsock = new Socket(AddressFamily.InterNetwork, newsock.bind(ipep); Console.WriteLine("Waiting for a client..."); EndPoint tmpremote = (EndPoint)(sender); recv = newsock.receivefrom(data, ref tmpremote); Console.WriteLine("Message received from 0:", tmpremote.tostring()); Console.WriteLine(Encoding.ASCII.GetSt ring(data, 0, recv)); string welcome = "Welcome to my test server"; data = Encoding.ASCII.GetBytes(welcome); newsock.sendto(data, data.length, SocketFlags.None, tmpremote); for (int i = 0; i < 5; i++) recv = newsock.receivefrom(data, ref tmpremote); Console.WriteLine(Encoding.ASCII.GetSt ring(data, 0, recv)); newsock.close(); The result of the program TestUdpSrvr binds a UDP socket to the 9050 port and waits for a client to connect with a greeting message. When this happens, the server sends back a welcome banner and then attempts to receive five messages in a row from the client. 6
7 Test Udp Client public class TestUdpClient byte[] IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork, EndPoint tmpremote = (EndPoint)sender; int recv = server.receivefrom(data, ref tmpremote); Console.WriteLine("Message received from 0:", tmpremote.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); server.sendto(encoding.ascii.getbytes("message 1"), tmpremote); server.sendto(encoding.ascii.getbytes("message 2"), tmpremote); server.sendto(encoding.ascii.getbytes("message 3"), tmpremote); server.sendto(encoding.ascii.getbytes("message 4"), tmpremote); server.sendto(encoding.ascii.getbytes("message 5"), tmpremote); // Multi-Send public class UdpClientMultiSend UdpClient sock = new UdpClient(); IPEndPoint iep = new IPEndPoint(IPAddress. Parse(" "), 9050); byte[] data = Encoding.ASCII.GetBytes("Thi s is a test message"); sock.send(data, data.length, iep); sock.close(); Multi-Send/Recv // Multi-Recv public class UdpClientMultiRecv UdpClient sock = new UdpClient(9050); Console.WriteLine("Ready to receive..."); sock.joinmulticastgroup(ipaddress.parse(" "), 9050); IPEndPoint iep = new IPEndPoint(IPAddress.Any, 0); byte[] data = sock.receive(ref iep); string stringdata = Encoding.ASCII.GetString(data, 0, dat a.length); Console.WriteLine("received: 0 from: 1", stringdata, i ep.tostring()); sock.close(); When UDP Goes Bad While solving the message boundary problem found in TCP communications, UDP introduces some other predicaments that programmers must deal with in UDP programs: Lost data as a result of how the ReceiveFrom() method works Detecting and allowing for lost packets These two UDP issues often cause unexpected dilemmas for network programmers who are more accustomed to working with TCP communications, and you must take them into consideration when creating production-quality UDP applications. class BadUdpClient byte[] data = new byte[30]; IPEndPoint ipep = new IPEndPoint( IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork, server.sendto(data, data.length, SocketFlags.None, ipep); IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); EndPoint tmpremote = (EndPoint)sender; data = new byte[30]; int recv = server.receivefrom(data, ref tmpremote); Udp BadClient Console.WriteLine("Message received from 0:", tmpremote.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); while (true) server.sendto(encoding.ascii.getbytes(input), tmpremote); data = new byte[30]; recv = server.receivefrom(data, ref tmpremote); stringdata = Encoding.ASCII.GetString(data, 0, recv); Result of the UdpBad C:\>BadUdpClient Message received from :9050: Welcome to my test server test message test message longer test message longer test message This is an even longer test message Unhandled Exception: System.Net.Sockets.SocketException: A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketflags, EndPoint& remoteep) at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, EndPoint& remoteep) at BadUdpClient.Main() C:\> BetterUdpClient int i = 30; while (true) class BetterdUdpClient server.sendto(encoding.ascii.getbytes(input), tmpremote); data = new byte[i]; try byte[] data = new byte[30]; recv = server.receivefrom(data, ref tmpremote); IPEndPoint ipep = new IPEndPoint( IPAddress.Parse(" "), 9050); catch (SocketException) Socket server = new Socket(AddressFamily.InterNetwork, Console.WriteLine("WARNING: data lost, retry message."); i += 10; EndPoint tmpremote = (EndPoint)sender; data = new byte[30]; int recv = server.receivefrom(data, ref tmpremote); Console.WriteLine("Message received from 0:", tmpremote.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); 7
8 public class BestUdpClient private static byte[] private static private static EndPoint Remote = (EndPoint)sender; private static int size = 30; BestUdpClient- II private static int AdvSndRcvData(Socket s, byte[] message, EndPoint rmtde vice) int recv = 0; int retry = 0; while (true) Console.WriteLine("Attempt #0", retry); try s.sendto(message, message.length, SocketFlags.None, rmtdevice); data = new byte[size]; recv = s.receivefrom(data, ref Remote); catch (SocketException e) if (e.errorcode == 10054) recv = 0; else if (e.errorcode == 10040) Console.WriteLine("Error receiving packet"); size += 10; recv = 0; if (recv > 0) return recv; else retry++; if (retry > 4) return 0; int recv; IPEndPoint ipep = new IPEndPoint( IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork, int sockopt = (int)server.getsocketoption(socketoptionlevel.socket, Soc ketoptionname.receivetimeout); Console.WriteLine("Default timeout: 0", sockopt); server.setsocketoption(socketoptionlevel.socket, SocketOptionName.R eceivetimeout, 3000); sockopt = (int)server.getsocketoption(socketoptionlevel.socket, Socket OptionName.ReceiveTimeout); Console.WriteLine("New timeout: 0", sockopt); recv = AdvSndRcvData(server, data, ipep); if (recv > 0) else Console.WriteLine("Unable to communicate with remote host"); return; while(true) recv = AdvSndRcvData(server, Encoding.ASCII.GetBytes(input), ipep); if (recv > 0) else Console.WriteLine("Did not receive an answer"); Preventing Lost Packets The other difficult task often encountered with UDP communications is providing for the possibility of lost packets. Because UDP is a connectionless protocol, there is no way for a device to know if a packet it sends actually made it to the remote device. Many games, for instance, use UDP packets to transmit positional information for players in the game. Every few seconds, a player s position and game status are transmitted to other players in the game. If a packet is lost in the network, an updated one will automatically be sent a few seconds later. Using Socket Time-outs Time out Udp Client The ReceiveFrom() method is a blocking function. It will block execution of the program until it receives a data packet. This is a Very Bad Thing in UDP programs because you are not guaranteed to receive a packet. The format of the SetSocketOption() method is as follows: SetSocketOption(SocketOptionLevel so, SocketOptionName sn, int value) The SocketOptionLevel specifies what type of socket option to implement. The SocketOptionName defines the specific option to set, and the last parameter (int value) indicates the set value for the option. /* C# Network Programming by Richard Blum Publisher: Sybex ISBN: */ public class TimeoutUdpClient byte[] int recv; IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Dgram,Pro tocoltype.udp); int sockopt = (int)server.getsocketoption(socketoptionlevel.socket,soc ketoptionname.receivetimeout); Console.WriteLine("Default timeout: 0", sockopt); server.setsocketoption(socketoptionlevel.socket, SocketOptionName.ReceiveTimeout, 3000); sockopt = (int)server.getsocketoption(socketoptionlevel.socket, SocketOptionName.ReceiveTimeout); Console.WriteLine("New timeout: 0", sockopt); EndPoint tmpremote = (EndPoint)sender; recv = server.receivefrom(data, ref tmpremote); Console.WriteLine("Message received from 0:", tmpremote.tostring()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv)); while (true) server.sendto(encoding.ascii.getbytes(input), tmpremote); recv = server.receivefrom(data, ref tmpremote); Catching the Exception Exceptions Now that you know the socket will produce a SocketException When the time-out is reached, you need only to catch the Exception so you can gracefully inform the customer about it and allow some alternatives to the application /* C# NetworkProgramming by Richard Blum Publisher: Sybex ISBN: */ public class ExceptionUdpClient byte[] int recv; IPEndPoint ipep = new IPEndPoint( IPAddress.Parse(" "), 9050); Socket server = new Socket(AddressFamily.InterNetwork, Soc kettype.dgram, ProtocolType.Udp); int sockopt = (int)server.getsocketoption(socketoptionlevel.soc ket, SocketOptionName.ReceiveTimeout); Console.WriteLine("Default timeout: 0", sockopt); server.setsocketoption(socketoptionlevel.socket, SocketOptio nname.receivetimeout, 3000); sockopt = (int)server.getsocketoption(socketoptionlevel.socke t, SocketOptionName.ReceiveTimeout); Console.WriteLine("New timeout: 0", sockopt); EndPoint Remote = (EndPoint)sender; try recv = server.receivefrom(data, ref Remote); Console.WriteLine("Message received from 0:", Remote. ToString()); Console.WriteLine(Encoding.ASCII.GetString(data, 0, rec v)); catch (SocketException) Console.WriteLine("Problemcommunicating with remote server"); return; while(true) server.sendto(encoding.ascii.getbytes(input), ipep); try recv = server.receivefrom(data, ref Remote); catch (SocketException) Console.WriteLine("Error receiving message"); 8
Network Operation System. netstat. ipconfig/tracert/ping. nslookup EEE 448 Computer Networks
EEE 448 Computer Networks with (Network Programming) Lecture #4 Dept of Electrical and Electronics Engineering Çukurova University Network Operation System When you are on the internet or are working in
More informationTransport Layer. The transport layer is responsible for the delivery of a message from one process to another. RSManiaol
Transport Layer Transport Layer The transport layer is responsible for the delivery of a message from one process to another Types of Data Deliveries Client/Server Paradigm An application program on the
More informationECE 650 Systems Programming & Engineering. Spring 2018
ECE 650 Systems Programming & Engineering Spring 2018 Networking Transport Layer Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) TCP/IP Model 2 Transport Layer Problem solved:
More informationTransport Layer (TCP/UDP)
Transport Layer (TCP/UDP) Where we are in the Course Moving on up to the Transport Layer! Application Transport Network Link Physical CSE 461 University of Washington 2 Recall Transport layer provides
More informationELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition
ELEC / COMP 177 Fall 2014 Some slides from Kurose and Ross, Computer Networking, 5 th Edition Project #1 Starts in one week Is your Linux environment all ready? Bring your laptop Work time after quick
More informationCSE 461 Module 10. Introduction to the Transport Layer
CSE 461 Module 10 Introduction to the Transport Layer Last Time We finished up the Network layer Internetworks (IP) Routing (DV/RIP, LS/OSPF, BGP) It was all about routing: how to provide end-to-end delivery
More informationDifferent Layers Lecture 20
Different Layers Lecture 20 10/15/2003 Jian Ren 1 The Network Layer 10/15/2003 Jian Ren 2 Network Layer Functions Transport packet from sending to receiving hosts Network layer protocols in every host,
More informationNetwork Programming. ò Network Protocols ò Communication Connection ò Naming
Network Programming Network Programming ò Network Protocols ò Communication Connection ò Naming Why are these important? You are developing a multi-player game, you will need to know how to: ò Establish
More informationTransport Layer Review
Transport Layer Review Mahalingam Mississippi State University, MS October 1, 2014 Transport Layer Functions Distinguish between different application instances through port numbers Make it easy for applications
More informationChapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1
Chapter 23 Process-to-Process Delivery: UDP, TCP, and SCTP 23.1 Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 23-1 PROCESS-TO-PROCESS DELIVERY 23.2 The transport
More informationChapter 6. What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control
Chapter 6 What happens at the Transport Layer? Services provided Transport protocols UDP TCP Flow control Congestion control OSI Model Hybrid Model Software outside the operating system Software inside
More informationContext. Distributed Systems: Sockets Programming. Alberto Bosio, Associate Professor UM Microelectronic Departement
Distributed Systems: Sockets Programming Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Context Computer Network hosts, routers, communication channels Hosts run applications
More informationNetwork Programming. Introduction to Sockets. Dr. Thaier Hayajneh. Process Layer. Network Layer. Berkeley API
Network Programming Outline Definitions Dr. Thaier Hayajneh Computer Engineering Department Berkeley API Socket definition and types Introduction to Sockets 1 2 Process Process Process Layer TCP SCTP UDP
More informationApplication Programming Interfaces
Application Programming Interfaces The TCP/IP protocol suite provides only the protocols that can be used by processes to communicate across a network. Though standarized, how these protocols are implemented
More informationECE697AA Lecture 3. Today s lecture
ECE697AA Lecture 3 Transport Layer: TCP and UDP Tilman Wolf Department of Electrical and Computer Engineering 09/09/08 Today s lecture Transport layer User datagram protocol (UDP) Reliable data transfer
More informationChapter 2 Applications and
Chapter 2 Applications and Layered Architectures Sockets Socket API API (Application Programming Interface) Provides a standard set of functions that can be called by applications Berkeley UNIX Sockets
More informationEEE-448 COMPUTER NETWORKS (Programming) Week -6 C# & IP Programming. The StringBuilder Class. StringBuilder Classes. StringBuilder with Append
EEE-448 COMPUTER NETWORKS (Programming) Week -6 C# & IP Programming Turgay IBRIKCI, PhD EEE448 Computer Networks Spring 2011 EEE448 Computer Networks Spring 2011 The StringBuilder Class The StringBuilder
More informationECE 650 Systems Programming & Engineering. Spring 2018
ECE 650 Systems Programming & Engineering Spring 2018 Programming with Network Sockets Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Sockets We ve looked at shared memory vs.
More informationDifferent Layers Lecture 21
Different Layers Lecture 21 10/17/2003 Jian Ren 1 The Transport Layer 10/17/2003 Jian Ren 2 Transport Services and Protocols Provide logical communication between app processes running on different hosts
More informationAnnouncements. No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6
Announcements No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6 Copyright c 2002 2017 UMaine Computer Science Department 1 / 33 1 COS 140: Foundations
More information(Refer Slide Time: 1:09)
Computer Networks Prof. S. Ghosh Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecturer # 30 UDP and Client Server Good day, today we will start our discussion
More informationEECS122 Communications Networks Socket Programming. Jörn Altmann
EECS122 Communications Networks Socket Programming Jörn Altmann Questions that will be Addressed During the Lecture What mechanisms are available for a programmer who writes network applications? How to
More informationIntroduction to TCP/IP networking
Introduction to TCP/IP networking TCP/IP protocol family IP : Internet Protocol UDP : User Datagram Protocol RTP, traceroute TCP : Transmission Control Protocol HTTP, FTP, ssh What is an internet? A set
More informationLecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24
Lecture 20 Overview Last Lecture Transport Control Protocol (1) This Lecture Transport Control Protocol (2) Source: chapters 23, 24 Next Lecture Internet Applications Source: chapter 26 COSC244 & TELE202
More informationDistributed Real-Time Control Systems. Module 26 Sockets
Distributed Real-Time Control Systems Module 26 Sockets 1 Network Programming with Sockets Sockets are probably the most widely used objects in programming networked communications. What is a socket? To
More informationInternet and Intranet Protocols and Applications
Internet and Intranet Protocols and Applications Lecture 1b: The Transport Layer in the Internet January 17, 2006 Arthur Goldberg Computer Science Department New York University artg@cs.nyu.edu 01/17/06
More informationTechnology Corner: Internet Packet Sniffers
Technology Corner: Internet Packet Sniffers Nick V. Flor and Kenneth Guillory Anderson School of Management University of New Mexico nickflor@unm.edu 1. SECTION EDITOR S NOTE Welcome to the Technology
More informationOSI Transport Layer. Network Fundamentals Chapter 4. Version Cisco Systems, Inc. All rights reserved. Cisco Public 1
OSI Transport Layer Network Fundamentals Chapter 4 Version 4.0 1 Transport Layer Role and Services Transport layer is responsible for overall end-to-end transfer of application data 2 Transport Layer Role
More informationUNIT IV -- TRANSPORT LAYER
UNIT IV -- TRANSPORT LAYER TABLE OF CONTENTS 4.1. Transport layer. 02 4.2. Reliable delivery service. 03 4.3. Congestion control. 05 4.4. Connection establishment.. 07 4.5. Flow control 09 4.6. Transmission
More informationCommunication in Distributed Systems: Sockets Programming. Operating Systems
Communication in Distributed Systems: Sockets Programming Operating Systems TCP/IP layers Layers Message Application Transport Internet Network interface Messages (UDP) or Streams (TCP) UDP or TCP packets
More informationOSI Transport Layer. objectives
LECTURE 5 OSI Transport Layer objectives 1. Roles of the Transport Layer 1. segmentation of data 2. error detection 3. Multiplexing of upper layer application using port numbers 2. The TCP protocol Communicating
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name
More informationshared storage These mechanisms have already been covered. examples: shared virtual memory message based signals
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name
More informationSocket Programming. Sungkyunkwan University. Hyunseung Choo Copyright Networking Laboratory
Socket Programming Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2019 Networking Laboratory Contents Goals Client-Server mechanism Introduction to socket Programming with socket on
More informationTransport Layer. Gursharan Singh Tatla. Upendra Sharma. 1
Transport Layer Gursharan Singh Tatla mailme@gursharansingh.in Upendra Sharma 1 Introduction The transport layer is the fourth layer from the bottom in the OSI reference model. It is responsible for message
More informationNo book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6
Announcements No book chapter for this topic! Slides are posted online as usual Homework: Will be posted online Due 12/6 Copyright c 2002 2017 UMaine School of Computing and Information S 1 / 33 COS 140:
More informationTransport Layer TCP & UDP Week 7. Module : Computer Networks Lecturers : Lucy White Office : 324
Transport Layer TCP & UDP Week 7 Module : Computer Networks Lecturers : Lucy White lbwhite@wit.ie Office : 324 1 Purpose of the Transport Layer The Transport layer provides for the segmentation of data
More informationQUIZ: Longest Matching Prefix
QUIZ: Longest Matching Prefix A router has the following routing table: 10.50.42.0 /24 Send out on interface Z 10.50.20.0 /24 Send out on interface A 10.50.24.0 /22 Send out on interface B 10.50.20.0 /22
More informationCSCD 330 Network Programming Winter 2019
CSCD 330 Network Programming Winter 2019 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More informationData Transport over IP Networks
Data Transport over IP Networks Derek Konigsberg octo@logicprobe.org AITP University of Central Florida Data Transport over IP Networks p.1/24 Introduction The TCP/IP protocol suite was created by DARPA
More informationCSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?
CSE/EE 461 Lecture 14 Connections Last Time We began on the Transport layer Focus How do we send information reliably? Topics ARQ and sliding windows Application Presentation Session Transport Network
More information05 Transmission Control Protocol (TCP)
SE 4C03 Winter 2003 05 Transmission Control Protocol (TCP) Instructor: W. M. Farmer Revised: 06 February 2003 1 Interprocess Communication Problem: How can a process on one host access a service provided
More informationSOCKET. Valerio Di Valerio
SOCKET Valerio Di Valerio The Problem! Communication between computers connected to a network Network Network applications! A set of processes distributed over a network that communicate via messages!
More informationA set of processes distributed over a network that communicate via messages. Processes communicate via services offered by the operating system
SOCKET Network applications A set of processes distributed over a network that communicate via messages Ex: Browser Web, BitTorrent, ecc Processes communicate via services offered by the operating system
More informationIEMS 5780 / IERG 4080 Building and Deploying Scalable Machine Learning Services
IEMS 5780 / IERG 4080 Building and Deploying Scalable Machine Learning Services Lecture 7 - Network Programming Albert Au Yeung 18th October, 2018 1 / 48 Computer Networking 2 / 48 Data Communication Exchange
More informationWe will cover in this order: 2.1, 2.7, 2.5, 2.4, 2.2
CSE 422 Notes, Set 2 These slides contain materials provided with the text: Computer Networking: A Top Down Approach,5 th edition, by Jim Kurose and Keith Ross, Addison-Wesley, April 2009. Additional figures
More informationtransmission media and network topologies client/server architecture layers, protocols, and sockets
Network Programming 1 Computer Networks transmission media and network topologies client/server architecture layers, protocols, and sockets 2 Network Programming a simple client/server interaction the
More informationCSCI-GA Operating Systems. Networking. Hubertus Franke
CSCI-GA.2250-001 Operating Systems Networking Hubertus Franke frankeh@cs.nyu.edu Source: Ganesh Sittampalam NYU TCP/IP protocol family IP : Internet Protocol UDP : User Datagram Protocol RTP, traceroute
More informationNetworking Technologies and Applications
Networking Technologies and Applications Rolland Vida BME TMIT Transport Protocols UDP User Datagram Protocol TCP Transport Control Protocol and many others UDP One of the core transport protocols Used
More informationEITF25 Internet Techniques and Applications L7: Internet. Stefan Höst
EITF25 Internet Techniques and Applications L7: Internet Stefan Höst What is Internet? Internet consists of a number of networks that exchange data according to traffic agreements. All networks in Internet
More informationConnections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network
Connections Focus How do we connect processes? This is the transport layer Topics Naming processes Connection setup / teardown Flow control Application Presentation Session Transport Network Data Link
More informationOral. Total. Dated Sign (2) (5) (3) (2)
R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer
More informationTransport Layer Overview
Transport Layer Overview Kai Shen Transport-layer Overview Network layer: host-to-host to logical communication between hosts. Transport layer: logical communication between s. multiple comm. s can reside
More informationGroup-A Assignment No. 6
Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text
More informationPresentation Services. Presentation Services: Motivation
Presentation Services need for a presentation services ASN.1 declaring data type encoding data types implementation issues reading: Tannenbaum 7.3.2 Presentation Services: Motivation Question: suppose
More informationCSCD 330 Network Programming Spring 2018
CSCD 330 Network Programming Spring 2018 Lecture 7 Application Layer Socket Programming in Java Reading: Chapter 2, Java links Relevant Links page Some Material in these slides from J.F Kurose and K.W.
More informationCSEP 561 Connections. David Wetherall
CSEP 561 Connections David Wetherall djw@cs.washington.edu Connections Focus How do we (reliably) connect processes? This is the transport layer Topics Naming processes Connection setup / teardown Sliding
More informationWAVV 2005 Colorado Springs, CO. VSE.NET Programming. Handouts. Agenda. Page 1. .NET Programming Example with VSE
.NET Programming Example with VSE Chuck Arney illustro Systems International LLC carney@illustro.com Handouts Download a copy of this presentation www.illustro.com/conferences WAVV2005-2 Agenda Introduction
More informationUNIT IV TRANSPORT LAYER
Transport Layer UNIT IV TRANSPORT LAYER Congestion Control and Quality of Service Ref: Data Communication & Networking, 4 th edition, Forouzan IV-1 DATA TRAFFIC The main focus of congestion control and
More informationJAVA SOCKET PROGRAMMING
JAVA SOCKET PROGRAMMING WHAT IS A SOCKET? Socket The combination of an IP address and a port number. (RFC 793 original TCP specification) The name of the Berkeley-derived application programming interfaces
More informationMemory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)
File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps
More informationInternet Protocol (IP) TCP versus UDP
Internet Protocol (IP) Low-level protocols used by hosts and routers Guides the packets from source to destination host Hides the transmission path phone lines, LANs, WANs, wireless radios, satellite links,
More informationNWEN 243. Networked Applications. Layer 4 TCP and UDP
NWEN 243 Networked Applications Layer 4 TCP and UDP 1 About the second lecturer Aaron Chen Office: AM405 Phone: 463 5114 Email: aaron.chen@ecs.vuw.ac.nz Transport layer and application layer protocols
More informationCS 716: Introduction to communication networks th class; 7 th Oct Instructor: Sridhar Iyer IIT Bombay
CS 716: Introduction to communication networks - 18 th class; 7 th Oct 2011 Instructor: Sridhar Iyer IIT Bombay Reliable Transport We have already designed a reliable communication protocol for an analogy
More informationTransport Layer. Chapter 3: Transport Layer
Transport Layer EECS 3214 Slides courtesy of J.F Kurose and K.W. Ross, All Rights Reserved 29-Jan-18 1-1 Chapter 3: Transport Layer our goals: understand principles behind layer services: multiplexing,
More informationUser Datagram Protocol
Topics Transport Layer TCP s three-way handshake TCP s connection termination sequence TCP s TIME_WAIT state TCP and UDP buffering by the socket layer 2 Introduction UDP is a simple, unreliable datagram
More informationTCP/IP Protocol Suite 1
TCP/IP Protocol Suite 1 Stream Control Transmission Protocol (SCTP) TCP/IP Protocol Suite 2 OBJECTIVES: To introduce SCTP as a new transport-layer protocol. To discuss SCTP services and compare them with
More informationOverview. Last Lecture. This Lecture. Daemon processes and advanced I/O functions
Overview Last Lecture Daemon processes and advanced I/O functions This Lecture Unix domain protocols and non-blocking I/O Source: Chapters 15&16&17 of Stevens book Unix domain sockets A way of performing
More informationThe Transmission Control Protocol (TCP)
The Transmission Control Protocol (TCP) Application Services (Telnet, FTP, e-mail, WWW) Reliable Stream Transport (TCP) Unreliable Transport Service (UDP) Connectionless Packet Delivery Service (IP) Goals
More informationCS 5520/ECE 5590NA: Network Architecture I Spring Lecture 13: UDP and TCP
CS 5520/ECE 5590NA: Network Architecture I Spring 2008 Lecture 13: UDP and TCP Most recent lectures discussed mechanisms to make better use of the IP address space, Internet control messages, and layering
More informationChapter 2: outline. 2.1 principles of network applications. 2.6 P2P applications 2.7 socket programming with UDP and TCP
Chapter 2: outline 2.1 principles of network applications app architectures app requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail SMTP, POP3, IMAP 2.5 DNS 2.6 P2P applications 2.7 socket programming
More informationThe Fundamentals. Port Assignments. Common Protocols. Data Encapsulation. Protocol Communication. Tevfik Ko!ar
CSC 4304 - Systems Programming Fall 2008 Lecture - XXII Network Programming Tevfik Ko!ar Louisiana State University December 2 nd, 2008 1 The Fundamentals The Computer Systems Research Group (CSRG) at
More informationNetwork Programming in Python. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Network Programming in Python Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Transmission Control Protocol (TCP) Connection-oriented Two
More informationUDP CONNECT TO A SERVER
UDP The User Datagram Protocol Stefan D. Bruda Winter 2018 Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationCS 4390 Computer Networks. Transport Services and Protocols
CS 4390 Computer Networks UT D data Session 07 Transport Layer Overview and UDP Adapted from Computer Networking a Top-Down Approach 1996-2012 by J.F Kurose and K.W. Ross, All Rights Reserved Transport
More informationTSIN02 - Internetworking
Lecture 4: Transport Layer Literature: Forouzan: ch 11-12 2004 Image Coding Group, Linköpings Universitet Lecture 4: Outline Transport layer responsibilities UDP TCP 2 Transport layer in OSI model Figure
More informationConcept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space that is provided.
223 Chapter 19 Inter mediate TCP The Transmission Control Protocol/Internet Protocol (TCP/IP) suite of protocols was developed as part of the research that the Defense Advanced Research Projects Agency
More informationComputer Communication Networks Socket Programming
Computer Communication Networks Socket Programming ICEN/ICSI 416 Fall 2018 Prof. Aveek Dutta 1 Application Programming Interface Interface exported by the network Since most network protocols are implemented
More informationCSE 461 Connections. David Wetherall
CSE 461 Connections David Wetherall djw@cs.washington.edu Connections Focus How do we (reliably) connect processes? This is the transport layer Topics Naming processes TCP / UDP Connection setup / teardown
More informationCSC 4900 Computer Networks: P2P and Sockets
CSC 4900 Computer Networks: P2P and Sockets Professor Henry Carter Fall 2017 Recap SMTP is the language that mail servers use to exchange messages. SMTP is push-based... why? You can run SMTP from a telnet
More informationChapter 9: UDP sockets & address conversion function
Chapter 9: UDP sockets & address conversion function 9.1 Elementary UDP sockets:- Introduction to UDP sockets UDP is connectionless, unreliable, datagram protocol TCP is connection-oriented, reliable byte
More informationMotivation of VPN! Overview! VPN addressing and routing! Two basic techniques for VPN! ! How to guarantee privacy of network traffic?!
Overview!! Last Lecture!! Daemon processes and advanced I/O functions!! This Lecture!! VPN, NAT, DHCP!! Source: Chapters 19&22 of Comer s book!! Unix domain protocols and non-blocking I/O!! Source: Chapters
More informationInternetworking Models The OSI Reference Model
Internetworking Models When networks first came into being, computers could typically communicate only with computers from the same manufacturer. In the late 1970s, the Open Systems Interconnection (OSI)
More informationChapter 7 Transport Layer. 7.0 Introduction 7.1 Transport Layer Protocols 7.2 TCP and UDP 7.3 Summary
Chapter 7 Transport Layer 7.0 Introduction 7.1 Transport Layer Protocols 7.2 TCP and UDP 7.3 Summary Transport Layer Transportation of Data Role of the Transport Layer The transport layer is responsible
More informationCSEP 561 Connections. David Wetherall
CSEP 561 Connections David Wetherall djw@cs.washington.edu Connections Focus How do we (reliably) connect processes? This is the transport layer Topics Naming processes TCP / UDP Connection setup / teardown
More informationNetworking and Internetworking 1
Networking and Internetworking 1 Today l Networks and distributed systems l Internet architecture xkcd Networking issues for distributed systems Early networks were designed to meet relatively simple requirements
More informationTransport Layer. Application / Transport Interface. Transport Layer Services. Transport Layer Connections
Application / Transport Interface Application requests service from transport layer Transport Layer Application Layer Prepare Transport service requirements Data for transport Local endpoint node address
More informationGuide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16
Guide To TCP/IP, Second Edition Chapter 5 Transport Layer TCP/IP Protocols Objectives Understand the key features and functions of the User Datagram Protocol (UDP) Explain the mechanisms that drive segmentation,
More informationApplied Networks & Security
Applied Networks & Security TCP/IP Protocol Suite http://condor.depaul.edu/~jkristof/it263/ John Kristoff jtk@depaul.edu IT 263 Spring 2006/2007 John Kristoff - DePaul University 1 ARP overview datalink
More informationOperating Systems and Networks. Network Lecture 8: Transport Layer. Adrian Perrig Network Security Group ETH Zürich
Operating Systems and Networks Network Lecture 8: Transport Layer Adrian Perrig Network Security Group ETH Zürich I was going to tell you a joke about UDP, but I wasn t sure if you were going to get it
More informationOperating Systems and Networks. Network Lecture 8: Transport Layer. Where we are in the Course. Recall. Transport Layer Services.
Operating Systems and s Lecture 8: Transport Layer I was going to tell you a joke about UDP, but I wasn t sure if you were going to get it Adrian Perrig Security Group ETH Zürich 2 Where we are in the
More informationChapter 2 Application Layer
Chapter 2 Application Layer A note on the use of these ppt slides: We re making these slides freely available to all (faculty, students, readers). They re in PowerPoint form so you can add, modify, and
More information4. The transport layer
4.1 The port number One of the most important information contained in the header of a segment are the destination and the source port numbers. The port numbers are necessary to identify the application
More informationTCP/IP-2. Transmission control protocol:
TCP/IP-2 Transmission control protocol: TCP and IP are the workhorses in the Internet. In this section we first discuss how TCP provides reliable, connectionoriented stream service over IP. To do so, TCP
More informationSimulation of TCP Layer
39 Simulation of TCP Layer Preeti Grover, M.Tech, Computer Science, Uttrakhand Technical University, Dehradun ABSTRACT The Transmission Control Protocol (TCP) represents the most deployed transport protocol
More informationCPSC 441 Tutorial - 11 UDP Socket Programming Department of Computer Science University of Calgary
CPSC 441 Tutorial - 11 UDP Programming Department of Computer Science University of Calgary TCP Vs UDP Input: receives packet (TCP receives byte stream ) Output: sends packet (TCP sends byte stream ) What
More informationCSCE 463/612 Networks and Distributed Processing Spring 2018
CSCE 463/612 Networks and Distributed Processing Spring 2018 Transport Layer Dmitri Loguinov Texas A&M University February 22, 2018 Original slides copyright 1996-2004 J.F Kurose and K.W. Ross 1 Chapter
More informationNetworking for Data Acquisition Systems. Fabrice Le Goff - 14/02/ ISOTDAQ
Networking for Data Acquisition Systems Fabrice Le Goff - 14/02/2018 - ISOTDAQ Outline Generalities The OSI Model Ethernet and Local Area Networks IP and Routing TCP, UDP and Transport Efficiency Networking
More informationThe User Datagram Protocol
The User Datagram Protocol Stefan D. Bruda Winter 2018 UDP Very similar to the TCP in terms of API Dissimilar with TCP in terms of innards (and hence programming techniques) Many-to-many communication.
More informationCSE 461 Module 11. Connections
CSE 461 Module 11 Connections This Time More on the Transport Layer Focus How do we connect processes? Topics Naming processes Connection setup / teardown Flow control Application Presentation Session
More information