Distributed Real-Time Control Systems. Lecture 17 C++ Exceptions Synchronous I/O
|
|
- Harold Stone
- 5 years ago
- Views:
Transcription
1 Distributed Real-Time Control Systems Lecture 17 C++ Exceptions Synchronous I/O 1
2 Traditional Error Handling Well behaved code should notonlyfocus on operation under normal conditions but also under error conditions. Unfortunately traditional error handling is based on checkingfunction return values that indicate error states. This makes code ugly and tedious to write. Programmers most often ignore error conditions in the development phase (leave error handling for future work!) which turns code unreliable. Code becomes very complex and hard to maintain. Even with carefull coding, many error conditions are left unhandled. For instance printf() returns the number of characters successfully writen, but no one checks for it. int main() { int *p = (int *)malloc(1000*sizeof(int)); if(p == NULL) { printf( Error Allocating Memory\n ); return -1; FILE *fp = fopen( FILE.TXT, r ); if(fp == NULL) { printf( Error Opening File\n ); free(p); return -2; free(p); fclose(fp); 2
3 C++ Exceptions C++ provides structured error handling (exceptions). You write the code you want to happen in a try section; later in a catch section you write the code to cope with the problems. const int DivideByZero = 10; double divide(double x, double y) { if(y==0) throw DivideByZero; return x/y; int main() { try { divide(10, 0); catch (int i) { if(i==dividebyzero) cerr<<"divide by zero error"; When there is an error the throw keyword interrupts function execution and returns an object to the caller. Anything can be thrown, from built in types to user defined types. The functions exits on a clean way, i.e. temporary objects are destroyed as if the function terminates normally. Code inside the try block is not bloated with error checking, thus more legible and maintainable If no function catches the exception the program terminates. 3
4 Catching Exceptions All arror treatment is done in the catch blocks, depending on the type of the exceptions thrown. An object or reference to a derived class will match an handler to the base class. The catch( ) blockpicksanyexception not found before. If the function cannot treat the exception it should re-throw itto anotherlevel. If no function can treat the error, the program exits. After an exception has been handled the program, execution resumes after the trycatch block. void somefunc(){ try { //somecode that may fail catch (ErrType1 &e1) { //treat exception of type ErrType1 catch (ErrType2 &e2) { //treat exception of type ErrType3 // catch (ErrTypeN &en) { //treat exception of type ErrTypeN catch ( ) //treat default exception { // Exception is not know throw; //re-throw to higher level // Execution resumes here... 4
5 Standard Library Exceptions std::exception The base class for all the exceptions thrown by the C++ standard library. You can ask what( ) and retrieve the optional string with which the exception was initialized. #include <exception> #include <iostream> using namespace std; classmyerr : public exception { public: MyErr(char const*const &msg = ""): exception(msg) { ; int main() { try { throw MyErr("my message"); catch (MyErr& x) { cout << x.what() << endl; 5
6 C++ exception hierarchy 6
7 Error Management in iostream Streams maintain state flags that identify whether I/O was successful and, if not, the reason for the failure: ios::goodbit everything is ok ios::eofbit end-of-file was encountered ios::failbit recoverable error: an I/O operation was not successful ios::badbit fatal error: undefined state State access functions: ios::rdstate() - Returns the stream state flags: ios::eofbit, ios::failbit, ios::badbit, ios::goodbit. ios::eof() - End-of file has been encountered ios::fail() - Format errors have been found but no chars lost (recoverable) ios::bad() - Error with loss of data (nonrecoverable) ios::good() - Is good() if not bad(), fail() and eof(). ios::clear() - Restore stream state Exceptions are disabled by default. To enable them use the member function exceptions(flags) of the object to throw exceptions. Exceptions thrown are objects of the class: std::ios_base::failure #include <iostream> // std::cerr #include <fstream> // std::ifstream int main () { ifstream file; //enable fail() and bad() exceptions in stream file file.exceptions(ifstream::failbit ifstream::badbit); try { file.open ("test.txt"); while (!file.eof()) file.get(); file.close(); catch (ifstream::failure e) { cerr << Exception: << e.what() << endl; return 0; 7
8 The Boost Library General purpose, opensource, multi-platform C++ libraries. Peer reviewed, well documented, currently being included in the C++ Standard Libraries. Useful Libraries in Concurrent Programming: Asio Synchronous and Asynchronous I/O Interprocess Interprocess Communication and Synchronization MPI message passing interfaces sudo apt-get update sudo apt-get install libboost-all-dev 8
9 Boost ASIO Main Concepts Must create at least one io_service object - the link to the operating system's I/O services. YOUR PROGRAM I/O OBJECT I/O objects, such as a serial port, sockets or files, mediate connecting, reading and writing operations : I/O SERVICE Operating System Your program interfaces with the operating system resources via the I/O object or the io_service synchonous or asynchronous calls: (async_)read_some (existing in buffer) (async_)read (fixed amount) (async_)read_until (until delimiter) (async_)read_at (random access streams) (async_)write_some (in buffer) (async_)write (fixed amount) (async_)write_at (random access streams) 9
10 Synchronous Serial Example Compile with g++ V4.7.0 or bigger: g++ -std=c++11 serialread.cpp lpthread lboost_system //SERIALREAD.CPP #include <iostream> #include <boost/asio.hpp> using namespace std; using namespace boost::asio; //SERIALWRITE.CPP #include <iostream> #include <boost/asio.hpp> using namespace std; using namespace boost::asio; int main() { io_service io; //initialize services serial_port sp(io); //create io object boost::system::error_code ec; sp.open( /dev/ttyacm0, ec); //connect to port if( ec ) {cout << Error ; return -1; //set baud rate sp.set_option(serial_port_base::baud_rate(9600),ec); if( ec ) { cout << Error ; return -1; for (;;) { boost::asio::streambuf str; read_until(sp, str, \n ); cout << &str; int main() { io_service io; //initialize services serial_port sp(io); //create io object boost::system::error_code ec; sp.open( /dev/ttyacm0, ec); //connect to port if( ec ) {cout << Error ; return -1; //set baud rate sp.set_option(serial_port_base::baud_rate(9600),ec); if( ec ) { cout << Error ; return -1; for (;;) { string str; getline(cin, str); int nbytes = write(sp, boost::asio::buffer(str)); cout << Wrote << nbytes << bytes to port << endl; 10
11 Boost error handling Boost handles errors via error codes or exceptions. Error code boost::system::error_code Exception boost::system::system_error Functions typically have overloads to accept both cases. //ERROR HANDLING WITH ERROR CODES #include <boost/system/error_code.hpp> #include <boost/asio.hpp> #include <iostream> int main() { io_service io; serial_port sp(io); boost::system::error_code ec; sp.open( /dev/ttyacm0, ec); if(ec) std::cerr << ec.value() << std::endl; //ERROR HANDLING WITH EXCEPTIONS int main() { try { io_service io; serial_port sp(io); sp.open( /dev/ttyacm0 ); catch (boost::system::system_error &e) { boost::system::error_code ec = e.code(); std::cerr << ec.value() << std::endl; 11
12 Boost Synchronous Model 1. Your program initiates the connect operation by calling the I/O object 2. The I/O object forwards the request to the io_service. 3. The io_service calls on the operating system to perform the I/O operation. The program blocks at this point waiting for the execution of the I/O operation. 4. The operating system returns the result of the operation to the io_service. 5. The io_service returns any error in an object of type boost::system::error_code 6. Control returns to your program. 12
13 Boost Asio Stream Buffers boost::asio::buffer( ) is a function that creates a streambuf object that manages raw memory. If can manage POD types (plain old data arrays), vectors of POD and strings. //initialize from char* char d1[128]; auto b1 = boost::asio::buffer(d1); //initialize from char vector std::vector<char> d2(128); auto b2 = boost::asio::buffer(d2); //initialize from char array std::array<char, 128> d3; auto b3 = boost::asio::buffer(d3); 13
14 Boost Asio Communication Functions Boost Asio abstracts communication channels as streams. Streams can be sockets (UDP, TCP, ICMP), serial I/O, files. It provides the following functions to read or write synchronously or asynchronously to streams: async_read(stream, stream_buffer, [completion_test,] completion_handler); read(stream, stream_buffer, [completion_test]); async_write(stream, stream_buffer, [completion_test,] completion_handler); write(stream, stream_buffer, [completion_test]); async_read_until(stream, stream_buffer, delim, completion_handler); read_until(stream, stream_buffer, delim); async_read_at(stream, offset, buffer [, completion_test], completion_handler); read_at(stream, offset, buffer [, completion_test]); async_write_at(stream, offset, buffer [, completion_test], completion_handler) write_at(stream, offset, buffer [, completion_test]) 14
15 Boost Asio Completion Test The completion function is optional. If present, it is called after each successful read, and tells Boost.Asio if the read/write operation is complete (if not, it will continue to read/write); Function prototype is: size_t completion(const boost::system::error_code& err, size_t bytes_transfered) ; Boost.Asio comes with a few helper completion_test functions: transfer_at_least(n) transfer_exactly(n) transfer_all() 15
16 Boost Asio Completion Each read or write operation will end when one of these conditions occur: The supplied buffer is full (for read) or all the data in the buffer has been written (for write). The completion function returns 0 (if you supplied one such function). A delimiter is provided in the (async_)read_until functions (a char, string or regex). An error occurs 16
17 Network Programming with Sockets Sockets are probably the most widely used objects in programming networked communications. What is a socket? To the kernel, a socket is an endpoint of communication: IP address, port number, and protocol (TCP, UDP, etc). To an application, a socket is a file descriptor that lets the application read/write from/to the network Clients and servers communicate with each by reading from and writing to socket. 17
18 The Ethernet Frame-based Technology Ethernet stations communicate by sending each other data packets. Each Ethernet station is given a single 48-bit MAC address, which is used both to specify the destination and the source of each data packet. 18
19 The OSI stack model APDU Application Application Protocol Application 7 PPDU Presentation Presentation Protocol Presentation 6 SPDU Session Session Protocol Session 5 TPDU Transport Trasport Protocol Host-Router communication boundary Transport 4 packet Network Network Network Network 3 Frame Data Link Data Link Data Link Data Link 2 Bit Physical Physical Physical Physical 1 Host-Router internal protocol 19
20 IP Addressing There are two versions of an IP address : IPv4 and IPv6. Because of its prevalence, "IP address" typically refers to those defined by IPv4. Using reserved values for the first octet, network addresses are broken into classes: Class A very large networks (up to 2 24 hosts) Class B large networks (up to 2 16 hosts) Class C small networks (up to 255 hosts) Class D multi-cast messages to multiple hosts Class E addresses not allocated and reserved. 20
21 IP Classes 7 24 Class A: 0 Network ID Host ID Class B: 1 0 Network ID Host ID 21 8 Class C: Network ID Host ID 28 Class D (multicast): Multicast address Class E (reserv ed): unused Class Range within 1st octet Network ID Host ID 27 Possible number of networks Possible number of hosts A a b.c.d ,777,214 B a.b c.d 16,384 65,534 C a.b.c d 2,097,
22 Special Addresses Adapter Loopback Private addresses (will not be routed)
23 Subnet Masking Subnetwork or Subnet is a range of logical addresses within the address space that is assigned to an organization. Subnetworking simplifies routing. Dot-decimal Address Full Network Address Subnet Mask Network Portion Host Portion Binary
24 Address Resolution The Address Resolution Protocol (ARP) is a method for finding a host s hardware address when only its network layer address is known. E.g. IP addresses to MAC addresses. ARP is used in four cases of two hosts communicating: 1. When two hosts are on the same network and one desires to send a packet to the other 2. When two hosts are on different networks and must use a gateway/router to reach the other host 3. When a router needs to forward a packet for one host through another router 4. When a router needs to forward a packet from one host to the destination host on the same network 24
25 Stream Sockets Connection oriented, require handshake Use TCP protocol Local address: IP address and port number. Remote address: IP address and port number. Datagram Sockets Connectionless, low overhead Use UDP protocol Types of Sockets 25
26 Connection-Oriented Model The connection-oriented model is implemented with Stream Sockets using the TCP protocol. TCP provides a variety or error correction and performance features for transmission of byte streams. Implements a client-server architecture. 26
27 Connection Oriented Model Server Listening socket Welcomes some initial contact from a client Connection socket It is created at initial contact of client New socket that is dedicated to the particular client Client Client socket Specify the address of the server process, namely, the IP address of the server and the port number of the process 27
28 Connection-Oriented Model Server Process socket() Client Process socket() bind() listen() accept() get a blocked client read() write() read() 3-way handshake client request server response close notification connect() write() read() close() close() 28
29 Socket Primitives socket() creates a new socket of a certain socket type (tcp,udp), identified by an integer number, and allocates system resources to it. bind() is typically used on the server side, and associates a socket with a socket address structure, i.e. a specified local port number and IP address. listen() is used on the server side, and causes a bound TCP socket to enter listening state. connect() is used on the client side, and assigns a free local port number to a socket. In case of a TCP socket, it causes an attempt to establish a new TCP connection. accept() is used on the server side. It accepts a received incoming attempt to create a new TCP connection from the remote client, and creates a new socket associated with the socket address pair of this connection. send() and recv(), or write() and read(), or sendto() and recvfrom(), are used for sending and receiving data to/from a remote socket. 29
30 Boost Stream Sockets Boost Stream Sockets are part of the ASIO library: #include <boost/asio.hpp> Important classes ip::tcp::acceptor ip::tcp::endpoint ip::tcp::iostream ip::tcp::resolver ip::tcp::socket Important functions socket::socket() acceptor::acceptor() acceptor::accept() ip::tcp::connect() ip::tcp::read() ip::tcp::write() 30
31 //TCPSERVER.CPP #include <boost/asio.hpp> using namespace boost::asio; using ip::tcp; Boost Synchronous TCP Example Compile with g++ V4.7.0 or bigger: g++ -std=c++11 tcpserver.cpp lpthread lboost_system-mt int main() { //initialize services io_service io; //create a listening socket // bind and start listening at port tcp::acceptor acceptor(io, tcp::endpoint(tcp::v4(), 10000)); for (;;) { //create service socket tcp::socket socket(io); //wait client to connect tcp::acceptor.accept(socket); //client isaccessingservice write(socket, buffer( Hello World\n )); //TCPCLIENT.CPP #include <iostream> #include <boost/array.hpp> #include <boost/asio.hpp> using namespace boost::asio; using ip::tcp; int main() { io_service io; boost::system::error_code err; tcp::resolver resolver(io); tcp::resolver::query query( , ); tcp::resolver::iterator endpoint = resolver.resolve(query); tcp::socket socket(io); socket.connect(*endpoint,err); //connect and wait for (;;) { boost::array<char, 128> buf; size_t len = socket.read_some(buffer(buf), err); if (err == error::eof) break; // Closed cleanly by peer. else if (err) std::cout << Unknown Error ; std::cout.write(buf.data(), len); 31
32 Connectionless-Oriented Model The connectionless model uses UDP protocol with no guarantee of delivery. UDP packets may arrive out of order, multiple times, or not at all. UDP hasconsiderably less overhead than TCP Implements a peer-to-peer architecture. 32
33 Connectionless-Oriented Model Server Process socket() bind() Client Process socket() bind() read_from() write_to() request response write_to() read_from() close() close() 33
34 Boost Datagram Sockets Important classes ip::udp::endpoint ip::udp::resolver ip::udp::socket Important functions socket::receive_from() socket::send_to() 34
35 Boost Synchronous UDP Example //UDP SERVER #iinclude <iostream> #include <boost/asio.hpp> using namespace boost::asio; using ip::udp; int main() { io_service io; udp::socket socket(io,udp::endpoint(udp::v4(),10000)); for (;;) { boost::array<char, 1> recv; udp::endpoint client; boost::system::error_code err; //client endpoint retrieved on receive_from socket.receive_from(buffer(recv),client, 0, err); if (err && err!= error::message_size) { std::cout << Error << std::endl; return -1; boost::system::error_code ignored; socket.send_to(buffer( Hello\n ), client, 0, ignored); // UDP CLIENT #iinclude <iostream> #include <boost/asio.hpp> using namespace boost::asio; using ip::udp; int main() { io_service io; udp::resolver resolver(io); udp::resolver::query query(udp::v4(), " ", "10000"); udp::endpoint receiver = *resolver.resolve(query); udp::socket socket(io); socket.open(udp::v4()); boost::array<char, 1> send_buf = {{ 0 ; //send dummy data to initiate communication socket.send_to(buffer(send_buf), receiver); boost::array<char, 128> recv_buf; udp::endpoint sender; size_t len = socket.receive_from( buffer(recv_buf), sender); //write received data to console std::cout.write(recv_buf.data(), len); 35
Distributed Real-Time Control Systems
Distributed Real-Time Control Systems Lecture 18 More on Boost ASIO Ethernet Communications Sockets in C++ 1 Boost Asio Communication Functions Boost Asio abstracts communication channels as streams. Streams
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 informationDistributed Real-Time Control Systems. Chapter 22 Asynchronous I/O The Boost ASIO Library
Distributed Real-Time Control Systems Chapter 22 Asynchronous I/O The Boost ASIO Library 1 Synchronous vs Asyncronous I/O Synchronous (also called rendez-vous model) : The process sending/receiving data
More informationDistributed Real-Time Control Systems
Distributed Real-Time Control Systems Chapter 23 Additional C++ and Boost ASIO Features 1 Callable Objects 2 Function Objects Function objects (or Functors) are objects specifically designed to be used
More informationDistributed Real-Time Control Systems. Lecture 19 Asynchronous Communications
Distributed Real-Time Control Systems Lecture 19 Asynchronous Communications 1 Synchronous vs Asyncronous I/O Synchronous: The process sending/receiving data executed the write/read operation and waits
More informationDistributed Real-Time Control Systems. Lecture 24 Asynchronous Socket Communications
Distributed Real-Time Control Systems Lecture 24 Asynchronous Socket Communications with Boost ASIO 1 Boost Asynchronous I/O (ASIO) Boost::Asio allows implements a service for asynchronous I/O: boost::asio::io_service
More informationTCP /IP Fundamentals Mr. Cantu
TCP /IP Fundamentals Mr. Cantu OSI Model and TCP/IP Model Comparison TCP / IP Protocols (Application Layer) The TCP/IP subprotocols listed in this layer are services that support a number of network functions:
More informationNETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science
NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket
More informationInternetwork Protocols
Internetwork Protocols Background to IP IP, and related protocols Internetworking Terms (1) Communications Network Facility that provides data transfer service An internet Collection of communications
More informationECE4110 Internetwork Programming. Introduction and Overview
ECE4110 Internetwork Programming Introduction and Overview 1 EXAMPLE GENERAL NETWORK ALGORITHM Listen to wire Are signals detected Detect a preamble Yes Read Destination Address No data carrying or noise?
More informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 19 November 7, 2018 CPSC 427, Lecture 19, November 7, 2018 1/18 Exceptions Thowing an Exception Catching an Exception CPSC 427, Lecture
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 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 informationIntroduction to Internetworking
Introduction to Internetworking Introductory terms Communications Network Facility that provides data transfer services An internet Collection of communications networks interconnected by bridges and/or
More informationDeveloped By : Ms. K. M. Sanghavi
Developed By : Ms. K. M. Sanghavi Designing Our Own Manipulators We can design our own manipulators for certain special purpose.the general form for creating a manipulator without any arguments is: ostream
More informationA Client-Server Exchange
Socket programming A Client-Server Exchange A server process and one or more client processes Server manages some resource. Server provides service by manipulating resource for clients. 1. Client sends
More informationTCP/IP and the OSI Model
TCP/IP BASICS TCP/IP and the OSI Model TCP/IP BASICS The network protocol of the Internet Composed of six main protocols IP Internet Protocol UDP User Datagram Protocol TCP Transmission Control Protocol
More informationLecture 5 Files and Streams
Lecture 5 Files and Streams Introduction C programs can store results & information permanently on disk using file handling functions These functions let you write either text or binary data to a file,
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 informationEEC-484/584 Computer Networks
EEC-484/584 Computer Networks Lecture 15 wenbing@ieee.org (Lecture nodes are based on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall) Outline 2 Review of last lecture The network layer
More informationET4254 Communications and Networking 1
Topic 9 Internet Protocols Aims:- basic protocol functions internetworking principles connectionless internetworking IP IPv6 IPSec 1 Protocol Functions have a small set of functions that form basis of
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 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 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 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 informationThe TCP Protocol Stack
The TCP Protocol Stack Michael Brockway February 16, 2018 Introduction - Layered archtecture Networking software is desgined in a layered fashion The bottom layer is the services offered by the underlying
More informationInternet Protocols (chapter 18)
Internet Protocols (chapter 18) CSE 3213 Fall 2011 Internetworking Terms 1 TCP/IP Concepts Connectionless Operation Internetworking involves connectionless operation at the level of the Internet Protocol
More informationIntroduction. Lecture 5 Files and Streams FILE * FILE *
Introduction Lecture Files and Streams C programs can store results & information permanently on disk using file handling functions These functions let you write either text or binary data to a file, and
More informationRMIT University. Data Communication and Net-Centric Computing COSC 1111/2061. Lecture 2. Internetworking IPv4, IPv6
RMIT University Data Communication and Net-Centric Computing COSC 1111/2061 Internetworking IPv4, IPv6 Technology Slide 1 Lecture Overview During this lecture, we will understand The principles of Internetworking
More informationChapter 6. The Protocol TCP/IP. Introduction to Protocols
Chapter 6 The Protocol TCP/IP 1 Introduction to Protocols A protocol is a set of rules that governs the communications between computers on a network. These rules include guidelines that regulate the following
More informationChapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet
Chapter 2 - Part 1 The TCP/IP Protocol: The Language of the Internet Protocols A protocol is a language or set of rules that two or more computers use to communicate 2 Protocol Analogy: Phone Call Parties
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 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 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 informationOn Distributed Communications, Rand Report RM-3420-PR, Paul Baran, August 1964
The requirements for a future all-digital-data distributed network which provides common user service for a wide range of users having different requirements is considered. The use of a standard format
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 informationSEN366 (SEN374) (Introduction to) Computer Networks
SEN366 (SEN374) (Introduction to) Computer Networks Prof. Dr. Hasan Hüseyin BALIK (12 th Week) The Internet Protocol 12.Outline Principles of Internetworking Internet Protocol Operation Internet Protocol
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 information06/02/ Local & Metropolitan Area Networks 0. INTRODUCTION. 1. History and Future of TCP/IP ACOE322
1 Local & Metropolitan Area Networks ACOE322 Lecture 5 TCP/IP Protocol suite and IP addressing 1 0. INTRODUCTION We shall cover in this topic: 1. The relation of TCP/IP with internet and OSI model 2. Internet
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 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 informationComputer Networks. Lecture 9 Network and transport layers, IP, TCP, UDP protocols
Computer Networks Lecture 9 Network and transport layers, IP, TCP, UDP protocols Network layer The Network layer, or OSI Layer 3, provides services to exchange the individual pieces of data over the network
More informationETSF05/ETSF10 Internet Protocols Network Layer Protocols
ETSF05/ETSF10 Internet Protocols Network Layer Protocols 2016 Jens Andersson Agenda Internetworking IPv4/IPv6 Framentation/Reassembly ICMPv4/ICMPv6 IPv4 to IPv6 transition VPN/Ipsec NAT (Network Address
More informationPART X. Internetworking Part 1. (Concept, IP Addressing, IP Routing, IP Datagrams, Address Resolution)
PART X Internetworking Part 1 (Concept, IP Addressing, IP Routing, IP Datagrams, Address Resolution) CS422 Part 10 1 Spring 1999 Motivation For Internetworking LANs Low cost Limited distance WANs High
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 informationData Communication Prof. A. Pal Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 34 TCP/ IP I
Data Communication Prof. A. Pal Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 34 TCP/ IP I Hello and welcome to today s lecture on TCP/IP. (Refer Slide
More informationSocket Programming for TCP and UDP
CSCI4430 Data Communication and Computer Networks Socket Programming for TCP and UDP ZHANG, Mi Jan. 19, 2017 Outline Socket Programming for TCP Introduction What is TCP What is socket TCP socket programming
More informationVorlesung Kommunikationsnetze
Picture 15 13 Vorlesung Kommunikationsnetze Prof. Dr. H. P. Großmann mit B. Wiegel sowie A. Schmeiser und M. Rabel Sommersemester 2009 Institut für Organisation und Management von Informationssystemen
More informationIP - The Internet Protocol
IP - The Internet Protocol 1 Orientation IP s current version is Version 4 (IPv4). It is specified in RFC 891. TCP UDP Transport Layer ICMP IP IGMP Network Layer ARP Network Access Link Layer Media 2 IP:
More informationCS 351 Week 15. Course Review
CS 351 Week 15 Course Review Objectives: 1. To review the contents from different weeks. 2. To have a complete understanding of important concepts from different weeks. Concepts: 1. Important Concepts
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 informationUNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.
UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)
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 informationPractical Session #09 Exceptions & Networking. Tom Mahler
Practical Session #09 Exceptions & Networking Tom Mahler 1 In This Recitation We ll Cover Exceptions Java Sockets Datagram vs. Stream The Client-Server Model 2 Exceptions 3 Exceptions Java uses exceptions
More informationGuide to Networking Essentials, 6 th Edition. Chapter 5: Network Protocols
Guide to Networking Essentials, 6 th Edition Chapter 5: Network Protocols Objectives Describe the purpose of a network protocol, the layers in the TCP/IP architecture, and the protocols in each TCP/IP
More informationCHAPTER-2 IP CONCEPTS
CHAPTER-2 IP CONCEPTS Page: 1 IP Concepts IP is a very important protocol in modern internetworking; you can't really comprehend modern networking without a good understanding of IP. Unfortunately, IP
More informationIP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia
IP - The Internet Protocol Based on the slides of Dr. Jorg Liebeherr, University of Virginia Orientation IP (Internet Protocol) is a Network Layer Protocol. IP: The waist of the hourglass IP is the waist
More informationLecture 17 Overview. Last Lecture. Wide Area Networking (2) This Lecture. Internet Protocol (1) Source: chapters 2.2, 2.3,18.4, 19.1, 9.
Lecture 17 Overview Last Lecture Wide Area Networking (2) This Lecture Internet Protocol (1) Source: chapters 2.2, 2.3,18.4, 19.1, 9.2 Next Lecture Internet Protocol (2) Source: chapters 19.1, 19.2, 22,1
More informationIP: Addressing, ARP, Routing
IP: Addressing, ARP, Routing Network Protocols and Standards Autumn 2004-2005 Oct 21, 2004 CS573: Network Protocols and Standards 1 IPv4 IP Datagram Format IPv4 Addressing ARP and RARP IP Routing Basics
More informationAssignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland
Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland t Your task Write a simple file server Client has to be implemented in Java Server has to be implemented
More informationNetwork Protocols - Revision
Network Protocols - Revision Luke Anderson luke@lukeanderson.com.au 18 th May 2018 University Of Sydney Overview 1. The Layers 1.1 OSI Model 1.2 Layer 1: Physical 1.3 Layer 2: Data Link MAC Addresses 1.4
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals Interprocess Communication 2 Message Passing Indirect
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals... Interprocess Communication 2 Message Passing
More informationIP Addressing and Subnetting
IP Addressing and Subnetting Internet Layer The purpose of the Internet layer is to send packets from a network node and have them arrive at the destination node independent of the path taken. Internet
More informationMcGraw-Hill The McGraw-Hill Companies, Inc., 2000
!! McGraw-Hill The McGraw-Hill Companies, Inc., 2000 "#$% & '$# )1 ) ) )6 ) )* )- ). )0 )1! )11 )1 )1 )16 )1 3'' 4", ( ( $ ( $ $$+, $$, /+ & 23,4 )/+ &4 $ 53" Network Layer Position of network layer Figure
More information05-01 Discussion Notes
05-01 Discussion Notes PIC 10B Spring 2018 1 Exceptions 1.1 Introduction Exceptions are used to signify that a function is being used incorrectly. Once an exception is thrown, it is up to the programmer
More informationG52CPP C++ Programming Lecture 17
G52CPP C++ Programming Lecture 17 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last Lecture Exceptions How to throw (return) different error values as exceptions And catch the exceptions
More informationProf. Shervin Shirmohammadi SITE, University of Ottawa. Internet Protocol (IP) Lecture 2: Prof. Shervin Shirmohammadi CEG
Lecture 2: Internet Protocol (IP) Prof. Shervin Shirmohammadi SITE, University of Ottawa Prof. Shervin Shirmohammadi CEG 4185 2-1 Network Layer Provides the upper layers with independence from the data
More informationIS 0020 Program Design and Software Tools
1 Introduction 2 IS 0020 Program Design and Software Tools Exception Handling Lecture 12 November 23, 200 Exceptions Indicates problem occurred in program Not common An "exception" to a program that usually
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 informationInterconnecting Networks with TCP/IP. 2000, Cisco Systems, Inc. 8-1
Interconnecting Networks with TCP/IP 2000, Cisco Systems, Inc. 8-1 Objectives Upon completion of this chapter you will be able to perform the following tasks: Identify the IP protocol stack, its protocol
More informationDefining Networks with the OSI Model. Module 2
Defining Networks with the OSI Model Module 2 Objectives Skills Concepts Objective Domain Description Objective Domain Number Understanding OSI Basics Defining the Communications Subnetwork Defining the
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 information19: Networking. Networking Hardware. Mark Handley
19: Networking Mark Handley Networking Hardware Lots of different hardware: Modem byte at a time, FDDI, SONET packet at a time ATM (including some DSL) 53-byte cell at a time Reality is that most networking
More informationInterconnecting Networks with TCP/IP
Chapter 8 Interconnecting s with TCP/IP 1999, Cisco Systems, Inc. 8-1 Introduction to TCP/IP Internet TCP/IP Early protocol suite Universal 1999, Cisco Systems, Inc. www.cisco.com ICND 8-2 TCP/IP Protocol
More informationCSCI 102L - Data Structures Midterm Exam #1 Fall 2011
Print Your Name: Page 1 of 8 Signature: Aludra Loginname: CSCI 102L - Data Structures Midterm Exam #1 Fall 2011 (10:00am - 11:12am, Wednesday, October 5) Instructor: Bill Cheng Problems Problem #1 (24
More informationChapter Motivation For Internetworking
Chapter 17-20 Internetworking Part 1 (Concept, IP Addressing, IP Routing, IP Datagrams, Address Resolution 1 Motivation For Internetworking LANs Low cost Limited distance WANs High cost Unlimited distance
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 information! Errors can be dealt with at place error occurs
UCLA Stat 1D Statistical Computing and Visualization in C++ Instructor: Ivo Dinov, Asst. Prof. in Statistics / Neurology University of California, Los Angeles, Winter 200 http://www.stat.ucla.edu/~dinov/courses_students.html
More informationCOMP322 - Introduction to C++ Lecture 10 - Overloading Operators and Exceptions
COMP322 - Introduction to C++ Lecture 10 - Overloading Operators and Exceptions Dan Pomerantz School of Computer Science 19 March 2012 Overloading operators in classes It is useful sometimes to define
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 informationCSC209H Lecture 9. Dan Zingaro. March 11, 2015
CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess
More informationInterprocess Communication
Interprocess Communication Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved. 0-13-239227-5 Introduction Applications, services
More informationIP Address Assignment
IP Address Assignment An IP address does not identify a specific computer. Instead, each IP address identifies a connection between a computer and a network. A computer with multiple network connections
More informationIntroduction to Client-Server Model
Preview Introduction to Client-Server Model Motivation of Client-Server Model Terminologies and Concepts in Client-Server Model Connectionless vs. Connection-Oriented Stateless vs. Stateful Server Identify
More informationThis talk will cover the basics of IP addressing and subnetting. Topics covered will include:
This talk will cover the basics of IP addressing and subnetting. Topics covered will include: What is an IP Address? What are Classes? What is a Network Address? What are Subnet Masks and Subnet Addresses?
More informationLecture 2 Communication services The Trasport Layer. Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it
Lecture 2 Communication services The Trasport Layer Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it The structure edge: applications and hosts core: routers of s access s, media:
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 informationData and Computer Communications. Chapter 2 Protocol Architecture, TCP/IP, and Internet-Based Applications
Data and Computer Communications Chapter 2 Protocol Architecture, TCP/IP, and Internet-Based s 1 Need For Protocol Architecture data exchange can involve complex procedures better if task broken into subtasks
More informationCS102 C++ Exception Handling & Namespaces
CS102 C++ Exception Handling & Namespaces Bill Cheng http://merlot.usc.edu/cs102-s12 1 Topics to cover C Structs (Ch 10) C++ Classes (Ch 11) Constructors Destructors Member functions Exception Handling
More informationOverview of TCP/IP Overview of TCP/IP protocol: TCP/IP architectural models TCP protocol layers.
Overview of TCP/IP 3 Overview of TCP/IP protocol: TCP/IP architectural models TCP protocol layers. 4 2 5 6 3 7 8 4 9 10 5 11 12 6 13 14 7 15 16 8 17 18 9 19 20 10 21 Why TCP/IP? Packet based Provides decentralized
More informationCSC 330 Object-Oriented Programming. Exception Handling CSC 330
Object-Oriented Programming Exception Handling 1 C++ Exception Handling Topics Exception Handling C++ Exception Handling Basics Throwing and Catching Exceptions Constructors, Destructors and Exceptions
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 informationInternetworking Terms. Internet Structure. Internet Structure. Chapter 15&16 Internetworking. Internetwork Structure & Terms
Chapter 15&16 Internetworking Internetwork Structure & Terms Internetworking Architecture Features Connection/Connectionless Architecture Fragmentation & Reassembly Internet Protocol & Services Addressing
More informationIntroduction Layer 3. IP-Header: and RFC-760 Addressing schemes Subnetting Routing. Layer 3 Solution in Trains
Chapter 2.3 Layer 3 Network Layer 1 Content Introduction Layer 3 IP Protocol IP-Header: www.ietf.org and RFC-760 Addressing schemes Subnetting Routing Layer 3 Solution in Trains Communication Matrix (Information
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 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 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 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 information