DESIGN AND IMPLEMENT AND ONLINE EXERCISE FOR TEACHING AND DEVELOPMENT OF A SERVER USING SOCKET PROGRAMMING IN C

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "DESIGN AND IMPLEMENT AND ONLINE EXERCISE FOR TEACHING AND DEVELOPMENT OF A SERVER USING SOCKET PROGRAMMING IN C"

Transcription

1 DESIGN AND IMPLEMENT AND ONLINE EXERCISE FOR TEACHING AND DEVELOPMENT OF A SERVER USING SOCKET PROGRAMMING IN C Elena Ruiz Gonzalez University of Patras University of Granada ERASMUS STUDENT:147 1/100

2 Table of Contents 1 Introduction Motivation Objectives State of art Environment and development platforms Design & Implementation Introduction of the socket tools Function socket Communication domains Types of sockets Order of bytes Creating a socket Sockets address Association of sockets to certain parameters Connection oriented service (TCP) Enable a socket for connection requests Accept connection requests Launch connection requests Connection between client-server sockets Send and receive data through a TCP sockets State diagram of a TCP connection Closing a socket Analysis of resolution Functional requirements ForgeBox managing services Specification of software requirements Functional requirements Non-functional requirements User Cases Design of the solution Client-server model Creation of server Problems. Multi-servers Creation of the client Interface design First curse. Presentation part Second module. Interactive course Third module. Interactive course Fourth module. Course presentation part Compilation and execution model through remote servers /100

3 5.5.1 Creating our jfed scenario RSpec file creation Technologies applied Conclusion and future work Conclusion Future work Appendix Server.c Server1.c Server2.c Server3.c Client.c RSpec Bibliography and reference /100

4 1 Introduction 1.1 Motivation Learning to program is a very complex task that requires the acquisition of knowledge and skills and that cannot be accomplished without the student's own experimentation. The practical part of the subjects in programming is very important, even more than the lectures, since it is when students demonstrate their understanding and internalization of the theoretical concepts. One wonders if the way you learn to program is the most appropriate. Currently students use during their practical lessons the same kind of tools used by professional programmers, although the latter is a very general statement, since these programmers use a wide range of tools and options. The main idea is that students end up using these tools; hence it seems natural that they use them from the beginning. In this paper we have explored the advantages of an interactive environment (FORGE) to learn how to implement a server and client, not only to program, and how to address problems that can arise during implementation and resolve them by oneself. Therefore, what is proposed in this paper is the design and implementation of an environment that, by its nature, is not limited to be a simple development environment, but comprises unique features that include educational guidance specially designed to learn to manage certain tools such as sockets. The following summarizes the main reasons for choosing a web environment as FORGE: The non-dependence on operating systems, since multiplatform execution is achieved through web browsers. The power to monitor our activity (students) when performing exercises at home as the histories of access to the application are saved. Being web-based, remote access is allowed. 4/100

5 1.2 Objectives The main objective of this Final Project is to carry out the design and implementation of exercises with the FORGE platform so that it provides the necessary infrastructure to help students learn how to implement a server and client using sockets in c. This goal can be broken down into several points that are as follows: Students will be able to access the course they want to perform. In our case they can choose the course of implementing a server and client using sockets in c. They will learn in a simple and didactic way to implement (with the help of the given indications), compile and run the process and how to face different problems that can occur in a real situation, learning to identify and solve them. This will provide an accessible environment via the Internet allowing students not to have to worry about the installation, the architecture of the machine, where they are programming or the operating system, which are some of the drawbacks of most programming environments. Thus, it can be used independently of the platform (Unix / Linux, MacOS, Windows, etc.). This greatly facilitates the work for the students if they want to work from home, since they do not need to install the environment on each machine they intend to use with the compatibility problems this might cause (for example, in many subjects the Dev-C ++ program in a Windows environment is used and some students use other operating systems). As an additional task, it will be possible to supplement the programming course with sockets, with short test questions or brief comprehension statements. It will offer a different way of programming in which statements will be merged with practical exercises and theoretical questions in one document all visible to the users of the application. That is, the tool can also be used to display notes on the theory where the readers can test the examples. It will provide real-time interaction of students with the program by means of the terminal of the web environment. 5/100

6 2 State of art 2.1 Environment and development platforms. Currently, in most courses and subjects of introduction to programming, students use a fairly professional environment, but this has not always been the case. Formerly there were no integrated development environments and the student had to manage with a simple text editor and a compiler that could be used independently. With the evolution of programming languages and the need to create software, educational development environments have emerged. These tools have their pros and cons in terms of usability in the field of programming. The use of these environments in performing practices sessions has benefits, since they allow students to become familiar with a professional environment. In addition, an integrated development environment usually brings together a number of tools such as: a text editor, a compiler, and a version controller... All this makes the environment a powerful tool for those who know how to use it. On the other hand integrated development environments have drawbacks for a beginner programmer. These problems are directly related to the amount of utilities they offer, since professional environments frequently need specialized courses in order to learn how to use the tool. Usually it is assumed that students already know some programming language and what is required is the speeding up of the task of programming by using the built-in environments. What for a professional programmer can be an advantage for a beginner can become a disadvantage because the environment acts as a barrier between the task of learning and the student who has to make a double effort: learn to program and learn to use the programming environment. There is an increasing tendancy to facilitate the task of programming of an inexperienced student with the use of environments that are easy to configure and manage. The teacher currently plays an important role in the execution of the practice sessions of students. Traditionally, the teacher s role has been limited to the development of a bulletin with the statements of the practice sessions. In some cases, the student had to start from scratch while in others the teacher will provide a template to fill in. It is noteworthy that, in many cases, the teacher has little capacity to decide the environment, which can be imposed by limitations in the choice of the operating system. But this would no longer be the case since one of the advantages of the development of our online course platform FORGE is that the activity of the student when performing exercises at home can be monitored, as the system records the history of access to the resources. Having a test mode and to use the environment even for distance learning are also possible. Today there are countless applications that support teaching. For instance we can mention PoliformaT (Sakai project) and Moodle, amongst others. Moodle is software designed to help educators create online courses and virtual learning environments. Such online learning systems are sometimes called VLEs (Virtual Learning Environments) or virtual learning environments. 6/100

7 In recent years, distance courses have boomed due to online platforms for conducting these courses. These courses for the community in general are known as Massive Online Courses (Massive Open Online Course (MOOC)). There are several platforms (and constantly increasing) that teach these courses. In addition many of them are directly related to the field of computing and, in particular, of programming. The number of courses that are offered online, both officially and unofficially, is very high. Therefore, in this section we will only focus on those online platforms designed for learning to program in an educational environment or those that are closely related to programming. We shall obviously only highlight those that exhibit environments for writing and executing code online, using a browser. The courses and platforms available specifically designed for programming can be divided into 3 types: 1. -Those where the code is developed locally (on the user s own machine), it runs locally and the solution is verified by sending the answer via a web form. In this case, the user downloads the code, or a set of files (if appropriate), edits the code and runs the program on their machine with the data that has been provided. Then, using a web-form, the user sends the solution after executing the cases. Usually the material accomplished by the distance learner is sent to the teachers who are responsible for reviewing the work. These platforms do not have any execution or online edition. The web environment itself only serves to verify the solution and to show the course content (videos, slides, manuals, etc...). 2. -The code is executed via the Web on the client s side. You write the code in the browser and the results are shown on the web interface itself. This system is quite common in web programming courses: HyperText Markup Language (HTML), Cascading Style Sheets (CSS), JavaScript and other web languages, where the code can easily be run on the client s side. There are other more complex systems that allow translation of the code of a particular language (C, C ++) to Javascript and to run it in the same browser. This is the case of the combination of a compiler that generates the code of a LLVM virtual machine (for example, the compiler clang) with the compiler of LLVM to Javascript denominated Emscripten. This allows you to run programs on the client side written in C. This also applies to the well known Java applets, which allow the user to run Java code in a browser Those that the code that runs on the server and the results are displayed on the client side. This service allows the highest flexibility, since the server has all the necessary components for running the user code and the user does not have to worry about installing the necessary libraries. There are also several ways of treating the code ellaborated by the user. In certain cases a function is requested, and the system checks if it has been completed correctly by hidden test cases. Other platforms have the option of running a terminal, usually using interpreted languages (Python, Javascript), and carrying out interactively executions of the developed code. In some programming contests, it is possible to run the program developed by using an entrance designed by the user. In any case, the execution is performed on the server and non-interactively. Although we have focused in the present case on providing a support platform to facilitate learning programming, in our case in the utilization of sockets, it is interesting to describe different online platforms and MOOC 's dedicated to provide education through web resources (slides, videos, etc.). 7/100

8 The most prominent MOOC 's platforms are Udacity and Coursera. Both have several courses teaching different subjects, most of which are focused on topics of computer science and, in particular programming. In mid-2011, Stanford University, presented a series of online courses on the use of certain oriented programming tools that were completely free. Although they were not the first courses offered in this format, they were widely accepted by the online community. The courses were taught by prestigious teachers, thus the Artificial Intelligence course was presented by Peter Norvig (renowned researcher in AI) and Sebastian Thrun; and machine learning was directed by Andrew Ng. Later on, the number of courses offered expanded, and included options such as Algorithms (Tim Rougharden), Natural Language Processing (Daniel Jurafsky and Chris Manning), Modeling (Daphne Koller) and others. Although initially there was no unified technology platform, the courses usually consisted in videos, questions (Included or not in the videos) and a section of multiple choice questions or problems, as well as tests that were evaluated automatically. The practical part, which is what interests us, usually develops toolkits using downloadable programs where the user must fill in the missing pieces of code, and then send the results using the same executable downloaded or complete a form on the website. Due to the popularity of these courses amongst the online community, simultaneously two platforms were created just to teach various courses using an online format: Udacity and Coursera. There are several differences between the two platforms, both in terms of content and in terms of the tools. Still, it is noteworthy that Coursera included courses presented by various teachers from different universities around the world, while Udacity includes courses that are often taught by professors from prestigious universities, however they are not directly linked to any university. In computer-related courses both platforms provide different mechanisms for evaluating the exercises where programming is required. Coursera still contains downloadables with the code, where the user must have the necessary tools on his computer. Udacity includes a web editor (in principle for Python language) where the user develops its code and runs it on a number of hidden cases and where the user is shown the result of the implementation: if you are right or not. Typically, the code is done after developing a lesson (or video) in order to secure contents. Lately, a wide variety of online education platforms have emerged, including platforms in Spanish such as Miriadax. Khan Academy should also be mentioned, which was founded earlier than those shown above (2006), and included courses in various specialties: computer courses, oriented programming and network configuration. The platform provided an intuitive interface for displaying results in a visual way that helped to understand the course content. Apart from these online schools, there are many other web platforms, which have a variety of courses, most of them related to computers and development in general. Examples are the following: Codeacademy is an online platform created exclusively for teaching programming in different languages. It includes courses for Python, Javascript, HTML, CSS, etc. This platform was created in 8/100

9 September 2011 and the courses are completely free. The interface is quite intuitive and the Web-based courses (HTML, CSS, Javascript) allow for the visualization of the results of the exercises in the environments and development platforms of the browser. One of the few drawbacks of the platform is that it is sometimes difficult to identify errors, especially in HTML and Javascript. Udemy includes courses on different subjects: business management, art, health, languages, music, and technology. As a remarkable feature, instructors can create courses using the platform and can upload additional contents for courses such as transparencies, videos or others. On the platform there are many free courses, although some have a charge which varies between $ 5 and $ 250. Codelearn has different free programming courses. This platform has a powerful web interface that allows you to create and execute code on the same platform. Learncode is designed to reduce the gap between the knowledge learned in college/school and the demands in programming of the real world. An important detail of the platform is that there is a section called "Code Garage" where you can create more complex projects step by step such as a Sudoku, Tic Tac Toe, Minesweeper and more. Codeschool is very similar to the previous platform. It has a lot of courses, mostly oriented towards web development technologies (Javascript, jquery, CSS3, etc) although it also includes more general tutorials such as Git Hub, IOS or Unix. Google also has its own platform for online courses, although these courses are more oriented to mobile platforms (Android) instead of teaching how to program from scratch. On the other hand, it includes programming contests and/or algorithms which aim at solving problems of different degress of difficulty by programming. Although these contests are not intended to teach programming from scratch, there are several websites where problems are presented sorted by difficulty, so you can access these sites to reinforce the already known programming concepts and find an application of the proposed problems. Regarding the web pages and sites the following are worthy of mention: Codeforces, TopCoder, Checkio, USA Computing Olimpiad, Codechef,... Of the sites shown, Check.io is notable for its interface, and its way of showing programming problems as a game where problems of increasing difficulty are solved in order to advance the story. In addition in a similar fashion to the tool presented in this project, it provides a fully online editor (in this case for Python), where the user is able to run the code on the server but visualizes the results on a web interface. After this summary on information regarding the different platforms, online courses and web environments, now we shall formulate the most important question: why use the Forge platform? Forge allows to study and develop new processes and approaches to online learning based on the integration of FIRE facilities and elearning technologies. It injects into the higher education learning sphere the FIRE portfolio of facilities and tools. It introduces the learning community to the concepts of experimentally driven research and increases the overall accessibility and usability of FIRE facilities through the layering of how-to-use resources over the FIRE platforms. The Future Internet Research and Experimentation (FIRE) initiative is intended to ensure that the European Internet Industry evolves towards a Future Internet containing European technology, services 9/100

10 and values. Through the FIRE initiative and other similar regional and global initiatives a variety of facilities have been established to enable such experimentation. These facilities cover a plethora of different domains belonging to the Future Internet ecosystem, such as cloud computing platforms, wireless and sensor network testbeds, Software Defined Networking and OpenFlow facilities, infrastructures for High Performance Computing, Long Term Evolution (LTE) testbeds, smart cities and so on. However, the corresponding cost both for the establishment and operation of these infrastructures is not to be neglected. Hence optimal usage of the facilities is desired by its owners, a goal which in general is not yet achieved today. To increase the usage, several steps can be taken. One approach is to raise the awareness of the facilities within communities that are less familiar with the FIRE initiative. Another is to use the infrastructure not only for research and development, but also for other activities such as teaching through a constructivist approach. This means that students would be enabled to take certain initiatives in their learning, by setting up and conducting scientific experiments based on FIRE. In this way, using FIRE facilities for teaching computer science topics or other scientific domains would not only increase the usage of the facilities, it would also raise FIRE awareness in the long term since the students/experimenters of today are the researchers of tomorrow. And if educational materials were available that actually enable new types/areas of experimentation through FIRE, this would further lower the threshold for experimenters to explore new facilities and technologies. FIRE has invested significantly in the last few years in creating its federation. FIRE strives for a harmonization of tools and APIs to facilitate experimentation and the integration of heterogeneous resources around a single experiment under a single account and by using any experimentation tool that the end user wants. All this effort is currently led by FIRE s flagship project, Fed4FIRE (Integrated project, number , funded by the European Commission through the 7th ICT- Framework Programme, 1 Oct Sep. 2016). FORGE will build upon Fed4FIRE s leadership using the project as our main channel to the FIRE facilities. FORGE will thus adopt Fed4FIRE s tools and proposed mechanisms to aid in our role as an intermediary between the learning community and the FIRE facilities and tools. More specifically, we will adopt the Authentication Authorization Identification mechanisms and the tooling and additionally the APIs targeting experimenters and facilities. FORGE will investigate if these mechanisms can be applied as is or suggest extensions to our Fed4FIRE colleagues (as it is within Fed4FIRE s scope to collect requirements from the FIRE community). In some cases FORGE will also implement wrappers around Fed4FIRE s processes and mechanism in order to ease access to the learning community. For example there might be some fine-grained scheduling needs in FORGE that Fed4FIRE mechanisms do not take into account (e.g. limited time for a group of students to jointly complete a certain task). In such cases FORGE will develop the required mechanisms. The FORGE core will create a set of processes, tools and widgets to facilitate the development of lab courses. The pilot prototype lab courses will generate requirements for learning tools along a number of dimensions including overall functionality and interaction qualities. Especially, during the integration phase with the Learning Management System (LMS) of Lab Course creators, a validation of the development tools will be carried out. Followed by the execution of the Lab Courses where the final validation of the whole FORGE process will be finalized. As explained above, the FORGE core, driven by the requirements of the pilot prototype lab courses, will deliver a set of processes and tools to the learning community. To broaden the scope and the usage of the FORGE utilities, an expansion phase is planned by opening up the platform when starting the second half of the project by issuing an open call which will last for the rest of the project duration. We 10/100

11 expect volunteers from the learning community and elsewhere, who want to exploit FIRE facilities for educational purposes, to contribute to the FORGE ecosystem. The project consortium will support these community-driven courses by implementing requested widgets, tools and APIs, to the best of its ability, considering its limited budget and resources. 11/100

12 3 Design & Implementation Once the behavior of the application is specified, it is necessary to go into the details of the implementation and the technologies to be used to carry out the development of our online course. This design phase is very important because it is the creative part in which the designer defines how the course will be held in terms of implementation and design. It must be kept in mind that course design and implemention are completely different terms, so in the course design what must be implemented is explained, but not how it should be developed. For the course design we shall use several tools. This chapter will explain the design of the course. First we will make a brief introduction about socket programming. We shall discuss the code used to create our client-server scenario. Later on, we shall see how it is created and implemented in the e-learing platform used (Forge) and the compilation and execution model used, as it is important to bear in mind this is an application that allows the execution of programs created by users. 3.1 Introduction of the socket tools. Sockets are one of the tools that operating systems provide for communication between different processes. The particularity that they present with respect to other communication mechanisms (IPC - Inter-Process Communication) is that communication is possible even when both processes are running on different systems connected by a network. In fact, the sockets API is the basis of any application that runs on a network because it offers a library of basic functions that programmers can use to develop network applications. This API allows communication over a variety of networks, but in this manual we will focus on the use of TCP / IP networks. Sockets for TCP / IP allow the communication between two processes that are connected via a TCP / IP network. In a network of this type, each machine is identified by its IP address that must be unique. However, each machine may be running multiple processes simultaneously. Each of these processes is associated with a port number, in order to distinguish the different packages that the machine is recieving (the process of multiplexing). A socket is uniquely identified by an IP address + port number pair. A communication between these two processes is identified by associating these sockets used to send and receive information to and from the network: identifier of the origin socket + identifier of the destination socket. The information is very similar to how you write and read from a file. The information that an application sends through the origin socket can be received by another application through the destination socket and vice versa. There are different types of sockets depending on the protocol stack used for creating the socket. We will focus on the TCP / IP protocols. 12/100

13 The logical relationship between applications, sockets, protocols and ports in a device. There are several things to note about this relationship. First, a program may use more than one socket at the same time. Second, different programs can use the same socket at the same time although this is less common. As shown in the figure, each socket is associated with a TCP or UDP port, as appropriate. When a packet addressed to that port is received, the packet is passed on to the corresponding application. 3.2 Function socket. This section describes some aspects that are necessary to know when working with sockets Communication domains. The sockets are created in what is called a communication domain which defines which protocol stack will be used in the communication. The domains that are defined in the C language are: Domain PF_UNIX, PF_LOCAL PF_INET PF_INET6 PF_IPX PF_NETLINK PF_X25 PF_AX25 PF_APPLETALK PF_PACKET PF_ATMPVC Purpose Processes that communicate through the same UNIX system Processes that communicate using a IPv4 network Processes that communicate using a IPv6 network Processes that communicate using a Novell network Communicataion with kernel processes ITU-T X.25 / ISO-8208 protocol Amateur radio AX.25 Appletalk Access to PVCs ATM Access to PVCs ATM 13/100

14 3.2.2 Types of sockets. In the PF_INET domain, the following types of sockets are defined: Stream Sockets Datagram Sockets Raw Sockets A TCP Stream socket uses the TCP protocol (protocol of the transport layer) that provides bidirectional data flow, connection-oriented, sequenced, without duplication of packets and error free. If we send by the stream socket three objects "A, B, C", they arrive at the destination in the same order "A, B, C". These sockets use TCP ("Transmission Control Protocol") and it is this protocol that ensures the order of objects during transmission. Datagram sockets make use of the UDP Protocol (protocol of the transport layer), which provides a bidirectional data flow, which is not connection-oriented and where packets may arrive out of sequence, packets may be lost or errors might occur. They do not need an accessible connection such as stream sockets; a data packet will be built with destination information and then sent out. Raw sockets allow a lower access level, they can directly access the IP network layer protocol. Their use is much more limited because they are mainly used for developing new communication protocols to obviate the transport layer protocols. 3.3 Order of bytes A peculiarity of the operating systems is the way they store the bytes in memory. To avoid mistakes, the TCP / IP protocol defines a sequence of bytes that is independent of the machine. This byte order is called the order of network (network byte order) and considering its own definition it is equivalent to the order known as big-endian. If working on a Big-endian machine, this factor does not have to be taken into account, however, when working on Little-endian machines, you must have the information in the network order. htons () - host to network short - Converts a short int from machine format to network format. htonl () - host to network long - Converts a long int from machine format to network format. ntohs () - network to host short - Converts a short int from network format to machine format. ntohl () - network to host long - Converts a long int from network format to machine format. 14/100

15 It may be that the system used for programming stores the data in network byte order and no conversion is necessary. But if we try to compile the same source code in another platform host byte order, it will not work. Example: #include <netinet/in.h>... port = htons ( 3490 ); Creating a socket Analogy: For a person to receive calls you must have a phone, to make a connection you must create a socket. #include <sys / types.h> #include <sys / socket.h> #include <netinet / in.h> int socket (int domain, int type, int protocol); Sockets are created by calling the socket () function, which returns the socket identifier, whole number type (equivalent to the concept of file identifier). In the event that an error occurred during the creation of the socket, the function returns -1 and the global variable errno is set to a value that indicates the error that occurred. The function perror ("...") prints out an explanatory message on the error that has occurred. The format of the socket function ()is as follows: sockfd = socket (int domain, int type, int protocol); sockfd: socket ID. It will be used to connect, receive connections, send and receive data, etc. Domain: Marketplace where the connection is made. For this practice, the domain will always be PF_INET. 15/100

16 type: It corresponds to the type of socket that is going to be created, and can take the following values (defined as constants in libraries): SOCK_STREAM, SOCK_DGRAM protocol: Specifies the protocol to be used. A value of 0 indicates that the most appropriate protocol is to be selected (TCP for SOCK_STREAM, SOCK_DGRAM UDP). An example of its use: #include <stdio.h> #include <sys / types.h> #include <sys / socket.h>... int sockfd; sockfd = socket (AF_INET, SOCK_STREAM, 0); Sockets address. The socket () function only creates a socket, but does not assign any value, that is, it does not associated it with any IP address or any port. To perform this association, you must first know a series of structures that are necessary. struct sockaddr { unsigned short sa_family; // PF_* char sa_data[14]; // Dirección de protocolo. ; struct sockaddr_in { short int sin_family; unsigned short sin_port; // PF_INET // Numero de puerto. // Dirección IP. struct in_addr sin_addr; unsigned char sin_zero[8]; // Relleno. ; struct in_addr { unsigned long s_addr; // 4 bytes. 16/100

17 The sockaddr structure is the generic structure used in different functions defined in the Sockets API. As can be seen, it only defines the domain while the data (socket parameters) are unspecified (it simply reserves memory space, but without any structure). This allows the structure to be used independently of the domain that has been used to define the socket. In order to define the parameters that you want to associate with the socket, specific structures for each domain are used. The TCP / IP sockaddr_in structure is equivalent to the sockaddr structure, but allows reference to its elements more easily. The fields of sockaddr_in structure are: sin_family: will always take the values PF_INET. sin_port: Represents the port number, and must be in the order of bytes of the network. sin_addr: This field represents the IP address, and is stored in a specific format. To convert an IP address in text format to an unsigned long with an appropriate order of bytes, the inet_addr().unsigned long function is used. This function converts only IP addresses to a numeric format, it does NOT convert machine names. In case of error, -1 is returned and the errno global variable is activated. Example:... struct sockaddr_in sin;... sin.sin_addr.s_addr=inet_addr(" "); The inverse function is called inet_ntoa (), which converts an address in numeric format to a string of characters. Example:... printf("%s", inet_ntoa(sin.sin_addr));... - sin_zero: It is used only to complete the length of sockaddr. 17/100

18 3.4.2 Association of sockets to certain parameters. #include <sys/types.h> #include <sys/socket.h> int bind(int local_s, const struct sockaddr *addr, int addrlen); The bind () function is used to associate with these parameters an IP address and a port number of the local machine through which data is sent and received. Analogy: To receive a call, you must have a phone number; in order to receive connections, you must assign a name to the socket. You need to call bind () when programming a server. When programming a client. this function is not usually used. The kernel will assign the socket an IP address and the port number available when calling certain functions, for example when calling connect () to get connected to a remote system. On the server you need to call bind () because the port number must be known so that clients can connect. For example if you are programming a telnet server you should call bind () to assign the socket port. In the client application you can call bind () and assign a port number, but this is not necessary because no one will be able to get connected.. The format of the function is as follows: int bind(int sockfd, struct sockaddr *my_addr, int addrlen); sockfd : socket identifier returned by the socket function (). my_addr: It is a pointer to a sockaddr structure containing the local host IP and the port number to be assigned to the socket. addrlen: It must be set to the size of the sockaddr structure: sizeof (struct_sockaddr). Example:... struct sockaddr_in sin;... ret = bind (sockfd, (struct sockaddr *)&sin, sizeof (sin)); if(ret < 0) perror( Error binding the socket ); /100

19 Prior to the call to the bind function () it is necessary to assign values to a variable of type sockaddr_in which will be the parameters associated to the socket. There are some special cases when assigning values to certain fields. If you assign zero to sin_port, the system sets the port number to the first available. To assign the IP address automatically (without having to know beforehand the IP address where the program will be run) the constant: INADDR_ANY can be used. This tells the system that the program will receive messages through any valid IP of the machine, in the case that several would exist. Example:... sin.sin_port = 0; sin.sin_addr.s_addr = htonl (INADDR_ANY);... Importantly, all socket functions expect to receive as parameter a pointer to a sockaddr structure, so it is necessary to perform a type conversion (cast) to this type, as has been done in the previous example. The bind function () (similar to the socket function (), and in general all the functions related to sockets) returns -1 when there has been any error condition, and sets the global variable perror () to the number of the error, so that the perror () function can be directly invoked to display it on screen. 3.5 Connection oriented service (TCP). The following describes the steps required to create a connection- oriented service, both on the client and the server-side. The steps to accomplish this are shown for both cases, invoking different functions, although details will be provided below. 19/100

20 Client Connection- oriented service (TCP) Server socket() bind() listen() accept() socket() [bind()] connect() send() recv() recv() send() Both client and server must create a socket by using the socket () function, in order to communicate. The call to the bind () function of the client is optional because if not invoked, the system will automatically run it and assign it a free port (random). On the other hand, in the server, the call to the bind function is required in order to reserve a specific known port. The server enables the socket to receive connections, calling the listen () function. In the client this step is not necessary because it will not receive connection requests from other processes. The server executes the accept () function and remains in standby until a client gets connected. The client uses connect () to attempt the connection. At that time the accept () function of the server returns a parameter that is a new socket identifier, which is used to transfer data across the network to the customer, thus leaving open the socket previously created to satisfy new requests. Once the connection is established the send and recv () functions are used with the socket descriptor of the previous step, in order to perform the data transfer. To end the connection the close () function is used. Below the calls to all these functions are described in detail. 20/100

21 3.5.1 Enable a socket for connection requests. #include <sys / socket.h> int listen (int sockfd, int backlog); The first step for communication using a connection-oriented service (TCP transport protocol) is the establishment of a TCP connection. In this sense, even if you have created a SOCK_STREAM socket type, the socket is not prepared to make such connection. To enable a socket for connection requests and proceed to the establishment of such a connection, you must use the listen () function. The listen () function is invoked only from the server, and enables the socket to receive connections. It applies only to sockets of the type SOCK_STREAM. The format of the function is as follows: int listen (int sockfd, int backlog); sockfd: socket identifier obtained in the socket () function, which will be used for connections. backlog: Maximum number of connections in the input queue of connections. Incoming connections are on standby in this queue until they are accepted by the accept () function Accept connection requests. #include <sys / types.h> #include <sys / socket.h> int accept (int sockfd, struct sockaddr * addr, socklen_t * addrlen); While the listen () function sets the socket and enables it to receive requests for connection establishment, it is the accept () function that actually waits for these requests. When a request made from a remote process (client) is received, the connection is completed on the server as long as it is waiting in the accept () function. The accept () function is used on the server once the listen () function has been invoked. This function waits until a client establishes a connection with the server. It is a blocking call, that is, the function does not end until a connection has occurred or it is interrupted by a signal. It should be stressed that once there has been a connection, accept () returns a new socket identifier to be used for communication with the client is connected. 21/100

22 The format of the function is as follows: int accept (int sockfd, struct sockaddr * addr, socklen_t * addrlen); sockfd: socket ID enabled to receive connections. addr: Pointer to a sockaddr structure (in our case its equivalent sockadd_in), where the information (IP address and port number) of the process that has performed the connection will be stored. addrlen: It must contain a pointer to a whole value representing the size of the addr structure. It must be set to the size of the sockaddr structure, by calling sizeof (struct sockaddr). If the function writes a smaller number of bytes, the value of addrlen is modified to the number of bytes written. Example:.. int sockfd, new_sockfd; SERVER_ADDR sockaddr_in; remote_addr sockaddr_in; int addrlen; // Create the socket. sockfd = socket (AF_INET, SOCK_STREAM, 0); // Set values in SERVER_ADDR structure. server_addr.sin_family = PF_INET; server_addr.sin port = htons (1234); // Port number where server_addr.sin_addr.s_addr = htonl (INADDR_ANY); // Get the program packages // Attach the socket defined values bind (sockfd, (struct sockaddr *) & SERVER_ADDR, sizeof (struct sockaddr)); // The socket to receive connections is enabled. listen (sockfd, 5); 22/100

23 addrlen = sizeof (struct sockaddr); // You call accept () and the server is waiting for connections. new_sockfd = accept (sockfd, & remote_addr, & addrlen); Launch connection requests. #include <sys / types.h> #include <sys / socket.h> int connect (int sockfd, const struct sockaddr * serv_addr, socklen_t addrlen); This function is invoked from the client to request the establishment of a TCP connection. The connect function() initiates the connection to the remote server of the client. The format of the function is as follows: int connect (int sockfd, struct sockaddr * serv_addr, int addrlen); sockfd: socket identifier returned by the socket () function. serv_addr: sockaddr structure containing the IP address and destination port number. addrlen: It must be initialized to the size of the serv_addr structure passed as parameter. Example:... int sockfd; SERVER_ADDR sockaddr_in; int addrlen; // Create the socket. sockfd = socket (AF_INET, SOCK_STREAM, 0); // Set values in SERVER_ADDR structure. server_addr.sin_family = PF_INET; 23/100

24 server_addr.sin port = htons (1234); // Port number where // You are waiting for the server server_addr.sin_addr.s_addr = inet_addr (" "); // IP address // Server addrlen = sizeof (struct sockaddr); // It calls connect () and makes the connection request to the server connect (sockfd, & SERVER_ADDR, addrlen); Connection between client- server sockets. Once the customer has made the call to connect () and this has been successfully completed (which means that the server was waiting in the accept () function and has left this state and thus created the new socket), the situation is as shown in the Figure: Server Client Sockfd New_Sockfd Sockfd Sockets TCP TCP IP Port TCP TCP IP Figure 1: Sockets, protocols and port. 24/100

25 As shown in the figure, a connection between the socket used by the client in the connect () function and the socket returned by the accept () function is created in the server. This connection will allow communication between two processes using sockets that are connected Send and receive data through a TCP sockets. #include <sys / types.h> #include <sys / socket.h> ssize_t send (int s, const void * buf, size_t len, int flags); Once the connection has been established, data exchange is initiated, using the send ()and recv ()functions. The format of the function send () is as follows: ssize_t send (int sockfd, const void * buf, size_t len, int flags); sockfd: socket identifier to send data. buf: A pointer to the data to be sent. len: Number of bytes to send. flags: By default 0. For more information, consult the online help. The send () function returns the number of bytes sent, which may be less than the amount indicated in the len parameter. The recv () function is used to receive data, and has a format similar to the above: ssize_t recv (int sockfd, void * buf, size_t len, int flags); sockfd: socket identifier for receiving data. 25/100

26 buf: A pointer to a buffer where the received data is stored. Len: Maximum number of bytes to receive. Flags: modify the behavior of the receiving function. For default behavior, set the parameter to 0. The recv () function is blocking, and does not end until it has received some kind of information. It is important to highlight that the len field indicates the maximum number of bytes to be received, but not necessarily this exact number of bytes has to be received. The recv () function returns the number of bytes that have been received. Example:... mens_serv char [100];... mens_clien = "Example"; send (sid, mens_clien, strlen (mens_clien) +1, 0);... recv (sid, mens_serv, 100, 0); State diagram of a TCP connection. The previous figure shows the states a TCP connection can go through. The events and segments that are exchanged in each transition from one state to another are also indicated. As can be seen, when created, a socket is in the CLOSED state. There are two ways of leaving this state: by an active or a passive opening. While the first occurs on the client side when it performs the call to connect () and with it begins the process of establishing the connection, the second occurs at the server once the calls to the listen () and accept () are performed. Thus, on the server the socket used for receiving connection establishment requests changes to the LISTEN state, and waits until the process of establishing the connection is initiated on the client side. After establishing the connection, both the socket created by the client and the socket that returns the accept () function change to the ESTABLISHED state. The socket used by the server to receive requests for connection establishment continues in the LISTEN state. 26/100

27 Data exchange takes place between the sockets that are in the ESTABLISHED state. Once completed, both sockets go to the CLOSED state (after going through a series of intermediate states). The event that causes this closure is the call between both processes (client and server) to the close () function. 3.6 Closing a socket. #include <unistd.h> int close (int fd); You just have to make the call to the function giving as argument the socket descriptor that needs to be closed. It is important that when a socket is not going to be used anymore, the close () call should be performed in order to give indications to the operating system that it must be released. 27/100

28 4 Analysis of resolution. 4.1 Functional requirements. To understand the full operation of the FORGE tool, it is necessary to perform a complete description of the software requirements that define the behavior of the tool, as well as the use cases. A software requirement describes the behavior of a system. The requirements can be divided into two types, the first is the functional requirements that define the internal behavior of the software, whose interactions are described by the use cases. The second type is the non-functional or complementary requirements. The software requirements of the application will be presented. A very important consideration when describing the software is that there is no ambiguity in the terminology used. Therefore, the main terms used to describe the course that are being developed will be explained: User - Is anyone using this tool. Teacher or creator of the course Is the person in charge of defining and creating the content of the training course for students. It is considered a system user. Student - Is the person responsible for solving the exercises, using the developed system. He is considered a user with restrictions Administrator - Is the user with more system privileges. The administrator can make any desire change. ForgeBox e-larning - A set of contents in the form of text or interactive format made up by blocks consisting of a series. Module - is a grouping of visual content that can be divided into two types: Interactive module - the group formed by elements (ssh, switches, etc.) that specify the part of the practice of this tool. Presentation module It refers to the theoretical content of our course. Program - unit set of instructions that allow a computer to perform various functions. Compiler - A program that converts the programming language used by the user into the programming language used by the computer The main element of our project is the creation of the e-learning course by using the FORGE tool. We will take advantage of this tool by using it as a platform because its graphical environment is simple and easy to understand for students. This is the life cycle of the creation of our project: 1. Development of an e-learning course by the teacher or creator. 2. Add the course to the system database. 3. Check the proper functioning of our course. If the behavior is not as desired, return to step 1. 28/100

29 4. Publication of the course. 5. Resolution of the course by the student. 6. Assessment of the exercise by the teacher or creator. FORGE is a great tool because it presents how it plans to use the FORGEBox solution and services.a FORGEBox might be hosted by an organization offering certain courses to its learners, installed in organizations datacentre or dedicated nodes. It can also be hosted by organizations (like the OU) that want to provide access to a larger community of learners. Finally, a cloud deployment will be also possible, supporting learning communities in larger scale. When having FORGEBox installed under a certain domain (e.g. myforgebox.example.org) the Lab Courses can have a target to reference for locating content. Figure 2: FORGE plans. Specifying educational objectives Educational objectives or learning outcomes cover knowledge, skills and personal, social and/or methodological abilities that a learner should have acquired when successfully having finished a learning opportunity. According to the European Qualification Framework (EQF), learning outcomes are defined in terms of knowledge, skills, and competences. Knowledge is the outcome of the assimilation of information through learning. Knowledge is the body of facts, principles, theories and practices that is related to a field of work or study. An example 29/100

Tutorial on Socket Programming

Tutorial on Socket Programming Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Seyed Hossein Mortazavi (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client- server

More information

Introduction to Socket Programming Part I : TCP Clients, Servers; Host information

Introduction to Socket Programming Part I : TCP Clients, Servers; Host information Introduction to Socket Programming Part I : TCP Clients, Servers; Host information Keywords: sockets, client-server, network programming-socket functions, OSI layering, byte-ordering Outline: 1.) Introduction

More information

Socket Programming. Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur

Socket Programming. Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur Socket Programming Kameswari Chebrolu Dept. of Electrical Engineering, IIT Kanpur Background Demultiplexing Convert host-to-host packet delivery service into a process-to-process communication channel

More information

Socket Programming. Srinidhi Varadarajan

Socket Programming. Srinidhi Varadarajan Socket Programming Srinidhi Varadarajan Client-server paradigm Client: initiates contact with server ( speaks first ) typically requests service from server, for Web, client is implemented in browser;

More information

Socket Programming. Request. Reply. Figure 1. Client-Server paradigm

Socket Programming. Request. Reply. Figure 1. Client-Server paradigm Socket Programming 1. Introduction In the classic client-server model, the client sends out requests to the server, and the server does some processing with the request(s) received, and returns a reply

More information

ICT SEcurity BASICS. Course: Software Defined Radio. Angelo Liguori. SP4TE lab. angelo.liguori@uniroma3.it

ICT SEcurity BASICS. Course: Software Defined Radio. Angelo Liguori. SP4TE lab. angelo.liguori@uniroma3.it Course: Software Defined Radio ICT SEcurity BASICS Angelo Liguori angelo.liguori@uniroma3.it SP4TE lab 1 Simple Timing Covert Channel Unintended information about data gets leaked through observing the

More information

Elementary TCP Sockets

Elementary TCP Sockets Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Networks: TCP/IP Socket Calls 1 IPv4 Socket Address Structure Internet socket address structure is named sockaddr_in

More information

Unix Network Programming

Unix Network Programming Introduction to Computer Networks Polly Huang EE NTU http://cc.ee.ntu.edu.tw/~phuang phuang@cc.ee.ntu.edu.tw Unix Network Programming The socket struct and data handling System calls Based on Beej's Guide

More information

ELEN 602: Computer Communications and Networking. Socket Programming Basics

ELEN 602: Computer Communications and Networking. Socket Programming Basics 1 ELEN 602: Computer Communications and Networking Socket Programming Basics A. Introduction In the classic client-server model, the client sends out requests to the server, and the server does some processing

More information

Introduction to Socket programming using C

Introduction to Socket programming using C Introduction to Socket programming using C Goal: learn how to build client/server application that communicate using sockets Vinay Narasimhamurthy S0677790@sms.ed.ac.uk CLIENT SERVER MODEL Sockets are

More information

Computer Network Programming. Intro to Sockets. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University

Computer Network Programming. Intro to Sockets. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University Computer Network Programming Intro to Sockets Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University Intro to Sockets The Client/Server Model Layered Network Structure Sockets Internet

More information

UNIX Sockets. COS 461 Precept 1

UNIX Sockets. COS 461 Precept 1 UNIX Sockets COS 461 Precept 1 Clients and Servers Client program Running on end host Requests service E.g., Web browser Server program Running on end host Provides service E.g., Web server GET /index.html

More information

Implementing Network Software

Implementing Network Software Implementing Network Software Outline Sockets Example Process Models Message Buffers Spring 2007 CSE 30264 1 Sockets Application Programming Interface (API) Socket interface socket : point where an application

More information

Porting applications & DNS issues. socket interface extensions for IPv6. Eva M. Castro. ecastro@dit.upm.es. dit. Porting applications & DNS issues UPM

Porting applications & DNS issues. socket interface extensions for IPv6. Eva M. Castro. ecastro@dit.upm.es. dit. Porting applications & DNS issues UPM socket interface extensions for IPv6 Eva M. Castro ecastro@.upm.es Contents * Introduction * Porting IPv4 applications to IPv6, using socket interface extensions to IPv6. Data structures Conversion functions

More information

The POSIX Socket API

The POSIX Socket API The POSIX Giovanni Agosta Piattaforme Software per la Rete Modulo 2 G. Agosta The POSIX Outline Sockets & TCP Connections 1 Sockets & TCP Connections 2 3 4 G. Agosta The POSIX TCP Connections Preliminaries

More information

NS3 Lab 1 TCP/IP Network Programming in C

NS3 Lab 1 TCP/IP Network Programming in C NS3 Lab 1 TCP/IP Network Programming in C Dr Colin Perkins School of Computing Science University of Glasgow http://csperkins.org/teaching/ns3/ 13/14 January 2015 Introduction The laboratory exercises

More information

Lab 4: Socket Programming: netcat part

Lab 4: Socket Programming: netcat part Lab 4: Socket Programming: netcat part Overview The goal of this lab is to familiarize yourself with application level programming with sockets, specifically stream or TCP sockets, by implementing a client/server

More information

Aalto University School of Electrical Engineering Internet Protocols Name Resolution & Server sockets

Aalto University School of Electrical Engineering Internet Protocols Name Resolution & Server sockets Internet Protocols Name Resolution & Server sockets Pasi Sarolahti 27.1.2016 Agenda Module 1 exercises IPv6 Name Resolution IPv6 address hunt Server sockets Multiplexed I/O Overview of round 2 exercises

More information

What is a socket? Last Year s COMS 4119 Computer Networking Socket Programming. Two essential types of sockets. Socket Programming

What is a socket? Last Year s COMS 4119 Computer Networking Socket Programming. Two essential types of sockets. Socket Programming What is a? Last Year s COMS 4119 Computer Networking Socket Programming Vishal Misra Department of Computer Science An interface between application and network The application creates a The type dictates

More information

INTRODUCTION UNIX NETWORK PROGRAMMING Vol 1, Third Edition by Richard Stevens

INTRODUCTION UNIX NETWORK PROGRAMMING Vol 1, Third Edition by Richard Stevens INTRODUCTION UNIX NETWORK PROGRAMMING Vol 1, Third Edition by Richard Stevens Read: Chapters 1,2, 3, 4 Communications Client Example: Ex: TCP/IP Server Telnet client on local machine to Telnet server on

More information

TCP/IP - Socket Programming

TCP/IP - Socket Programming TCP/IP - Socket Programming jrb@socket.to.me Jim Binkley 1 sockets - overview sockets simple client - server model look at tcpclient/tcpserver.c look at udpclient/udpserver.c tcp/udp contrasts normal master/slave

More information

Socket Programming in C/C++

Socket Programming in C/C++ September 24, 2004 Contact Info Mani Radhakrishnan Office 4224 SEL email mradhakr @ cs. uic. edu Office Hours Tuesday 1-4 PM Introduction Sockets are a protocol independent method of creating a connection

More information

Network Programming with Sockets. Process Management in UNIX

Network Programming with Sockets. Process Management in UNIX Network Programming with Sockets This section is a brief introduction to the basics of networking programming using the BSD Socket interface on the Unix Operating System. Processes in Unix Sockets Stream

More information

Application Architecture

Application Architecture A Course on Internetworking & Network-based Applications CS 6/75995 Internet-based Applications & Systems Design Kent State University Dept. of Science LECT-2 LECT-02, S-1 2 Application Architecture Today

More information

TCP/IP Sockets in C: Practical Guide for Programmers. Michael J. Donahoo Kenneth L. Calvert

TCP/IP Sockets in C: Practical Guide for Programmers. Michael J. Donahoo Kenneth L. Calvert TCP/IP Sockets in C: Practical Guide for Programmers Michael J. Donahoo Kenneth L. Calvert Computer Chat How do we make computers talk? How are they interconnected? Internet Protocol (IP) Internet Protocol

More information

VMCI Sockets Programming Guide VMware ESX/ESXi 4.x VMware Workstation 7.x VMware Server 2.0

VMCI Sockets Programming Guide VMware ESX/ESXi 4.x VMware Workstation 7.x VMware Server 2.0 VMware ESX/ESXi 4.x VMware Workstation 7.x VMware Server 2.0 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition.

More information

Sockets: send, recv Network Applications: HTTP. Copyright University of Illinois CS 241 Staff 1

Sockets: send, recv Network Applications: HTTP. Copyright University of Illinois CS 241 Staff 1 Sockets: send, recv Network Applications: HTTP Copyright University of Illinois CS 241 Staff 1 Announcements Still using this nifty old slide format... MP7 due tomorrow Brighten s office hours Tue 3:30

More information

IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking.

IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking. Aim: IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking. Other Objective of this lab session is to learn how to do socket

More information

Limi Kalita / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 5 (3), 2014, 4802-4807. Socket Programming

Limi Kalita / (IJCSIT) International Journal of Computer Science and Information Technologies, Vol. 5 (3), 2014, 4802-4807. Socket Programming Socket Programming Limi Kalita M.Tech Student, Department of Computer Science and Engineering, Assam Down Town University, Guwahati, India. Abstract: The aim of the paper is to introduce sockets, its deployment

More information

Networks. Inter-process Communication. Pipes. Inter-process Communication

Networks. Inter-process Communication. Pipes. Inter-process Communication Networks Mechanism by which two processes exchange information and coordinate activities Inter-process Communication process CS 217 process Network 1 2 Inter-process Communication Sockets o Processes can

More information

Programmation Systèmes Cours 9 UNIX Domain Sockets

Programmation Systèmes Cours 9 UNIX Domain Sockets Programmation Systèmes Cours 9 UNIX Domain Sockets Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot 2013 2014 URL http://upsilon.cc/zack/teaching/1314/progsyst/

More information

Network Protocol Suites

Network Protocol Suites UNIX Systems Programming Networking with Sockets (Curry, chp.14) Dr. Kivanç Dinçer CENG-332 Lectures Spring 2000 1 Networking Concepts Host Names Each host on the network has a unique host name. On the

More information

Operating Systems Design 16. Networking: Sockets

Operating Systems Design 16. Networking: Sockets Operating Systems Design 16. Networking: Sockets Paul Krzyzanowski pxk@cs.rutgers.edu 1 Sockets IP lets us send data between machines TCP & UDP are transport layer protocols Contain port number to identify

More information

CSCI-1680 Layering and Encapsulation Rodrigo Fonseca

CSCI-1680 Layering and Encapsulation Rodrigo Fonseca CSCI-1680 Layering and Encapsulation Rodrigo Fonseca Based partly on lecture notes by David Mazières, Phil Levis, John Janno< Administrivia Sign and hand in Collaboration Policy Signup for Snowcast milestone

More information

Overview. Socket Programming. Using Ports to Identify Services. UNIX Socket API. Knowing What Port Number To Use. Socket: End Point of Communication

Overview. Socket Programming. Using Ports to Identify Services. UNIX Socket API. Knowing What Port Number To Use. Socket: End Point of Communication Overview Socket Programming EE 122: Intro to Communication Networks Vern Paxson TAs: Lisa Fowler, Daniel Killebrew, Jorge Ortiz Socket Programming: how applications use the network Sockets are a C-language

More information

Communication Networks. Introduction & Socket Programming Yuval Rochman

Communication Networks. Introduction & Socket Programming Yuval Rochman Communication Networks Introduction & Socket Programming Yuval Rochman Administration Staff Lecturer: Prof. Hanoch Levy hanoch AT cs tau Office hours: by appointment Teaching Assistant: Yuval Rochman yuvalroc

More information

Writing a C-based Client/Server

Writing a C-based Client/Server Working the Socket Writing a C-based Client/Server Consider for a moment having the massive power of different computers all simultaneously trying to compute a problem for you -- and still being legal!

More information

The Pocket Guide to TCP/IP Sockets: C Version. Michael J. Donahoo Kenneth L. Calvert

The Pocket Guide to TCP/IP Sockets: C Version. Michael J. Donahoo Kenneth L. Calvert The Pocket Guide to TCP/IP Sockets: C Version Michael J. Donahoo Kenneth L. Calvert Computer Chat How do we make computers talk? How are they interconnected? Internet Protocol (IP) Internet Protocol (IP)

More information

Chapter 3. Internet Applications and Network Programming

Chapter 3. Internet Applications and Network Programming Chapter 3 Internet Applications and Network Programming 1 Introduction The Internet offers users a rich diversity of services none of the services is part of the underlying communication infrastructure

More information

CSE 333 SECTION 6. Networking and sockets

CSE 333 SECTION 6. Networking and sockets CSE 333 SECTION 6 Networking and sockets Goals for Today Overview of IP addresses Look at the IP address structures in C/C++ Overview of DNS Write your own (short!) program to do the domain name IP address

More information

Packet Sniffing and Spoofing Lab

Packet Sniffing and Spoofing Lab SEED Labs Packet Sniffing and Spoofing Lab 1 Packet Sniffing and Spoofing Lab Copyright c 2014 Wenliang Du, Syracuse University. The development of this document is/was funded by the following grants from

More information

Network Programming TDC 561

Network Programming TDC 561 Network Programming TDC 561 Lecture # 1 Dr. Ehab S. Al-Shaer School of Computer Science & Telecommunication DePaul University Chicago, IL 1 Network Programming Goals of this Course: Studying, evaluating

More information

Computer Networks Network architecture

Computer Networks Network architecture Computer Networks Network architecture Saad Mneimneh Computer Science Hunter College of CUNY New York - Networks are like onions - They stink? - Yes, no, they have layers Shrek and Donkey 1 Introduction

More information

BSD Sockets Interface Programmer s Guide

BSD Sockets Interface Programmer s Guide BSD Sockets Interface Programmer s Guide Edition 6 B2355-90136 HP 9000 Networking E0497 Printed in: United States Copyright 1997 Hewlett-Packard Company. Legal Notices The information in this document

More information

Network Programming with Sockets. Anatomy of an Internet Connection

Network Programming with Sockets. Anatomy of an Internet Connection Network Programming with Sockets Anatomy of an Internet Connection Client socket address 128.2.194.242:51213 socket address 208.216.181.15:80 Client Connection socket pair (128.2.194.242:51213, 208.216.181.15:80)

More information

Ethernet. Ethernet. Network Devices

Ethernet. Ethernet. Network Devices Ethernet Babak Kia Adjunct Professor Boston University College of Engineering ENG SC757 - Advanced Microprocessor Design Ethernet Ethernet is a term used to refer to a diverse set of frame based networking

More information

Implementing and testing tftp

Implementing and testing tftp CSE123 Spring 2013 Term Project Implementing and testing tftp Project Description Checkpoint: May 10, 2013 Due: May 29, 2013 For this project you will program a client/server network application in C on

More information

UNIX. Sockets. mgr inż. Marcin Borkowski

UNIX. Sockets. mgr inż. Marcin Borkowski UNIX Sockets Introduction to Sockets Interprocess Communication channel: descriptor based two way communication can connect processes on different machines Three most typical socket types (colloquial names):

More information

Networks class CS144 Introduction to Computer Networking Goal: Teach the concepts underlying networks Prerequisites:

Networks class CS144 Introduction to Computer Networking Goal: Teach the concepts underlying networks Prerequisites: CS144 Introduction to Computer Networking Instructors: Philip Levis and David Mazières CAs: Juan Batiz-Benet, Behram Mistree, Hariny Murli, Matt Sparks, and Tony Wu Section Leader: Aki Kobashi cs144-staff@scs.stanford.edu

More information

Session NM059. TCP/IP Programming on VMS. Geoff Bryant Process Software

Session NM059. TCP/IP Programming on VMS. Geoff Bryant Process Software Session NM059 TCP/IP Programming on VMS Geoff Bryant Process Software Course Roadmap Slide 160 NM055 (11:00-12:00) Important Terms and Concepts TCP/IP and Client/Server Model Sockets and TLI Client/Server

More information

Socket = an interface connection between two (dissimilar) pipes. OS provides this API to connect applications to networks. home.comcast.

Socket = an interface connection between two (dissimilar) pipes. OS provides this API to connect applications to networks. home.comcast. Interprocess communication (Part 2) For an application to send something out as a message, it must arrange its OS to receive its input. The OS is then sends it out either as a UDP datagram on the transport

More information

What is CSG150 about? Fundamentals of Computer Networking. Course Outline. Lecture 1 Outline. Guevara Noubir noubir@ccs.neu.

What is CSG150 about? Fundamentals of Computer Networking. Course Outline. Lecture 1 Outline. Guevara Noubir noubir@ccs.neu. What is CSG150 about? Fundamentals of Computer Networking Guevara Noubir noubir@ccs.neu.edu CSG150 Understand the basic principles of networking: Description of existing networks, and networking mechanisms

More information

Programming guidelines on transition to IPv6

Programming guidelines on transition to IPv6 Programming guidelines on transition to IPv6 Tomás P. de Miguel and Eva M. Castro tmiguel@dit.upm.es eva@gsyc.escet.urjc.es Department of Telematic Systems Engineering (DIT) Technical University of Madrid

More information

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version Version 3.5 JEFFERSON LAB Data Acquisition Group cmsg Developer s Guide J E F F E R S O N L A B D A T A A C Q U I S I T I O N G R O U P cmsg Developer s Guide Elliott Wolin wolin@jlab.org Carl Timmer timmer@jlab.org

More information

Generalised Socket Addresses for Unix Squeak 3.9 11

Generalised Socket Addresses for Unix Squeak 3.9 11 Generalised Socket Addresses for Unix Squeak 3.9 11 Ian Piumarta 2007 06 08 This document describes several new SocketPlugin primitives that allow IPv6 (and arbitrary future other) address formats to be

More information

Core Syllabus. Version 2.6 C OPERATE KNOWLEDGE AREA: OPERATION AND SUPPORT OF INFORMATION SYSTEMS. June 2006

Core Syllabus. Version 2.6 C OPERATE KNOWLEDGE AREA: OPERATION AND SUPPORT OF INFORMATION SYSTEMS. June 2006 Core Syllabus C OPERATE KNOWLEDGE AREA: OPERATION AND SUPPORT OF INFORMATION SYSTEMS Version 2.6 June 2006 EUCIP CORE Version 2.6 Syllabus. The following is the Syllabus for EUCIP CORE Version 2.6, which

More information

Project 4: IP over DNS Due: 11:59 PM, Dec 14, 2015

Project 4: IP over DNS Due: 11:59 PM, Dec 14, 2015 CS168 Computer Networks Jannotti Project 4: IP over DNS Due: 11:59 PM, Dec 14, 2015 Contents 1 Introduction 1 2 Components 1 2.1 Creating the tunnel..................................... 2 2.2 Using the

More information

Chapter 17. Transport-Level Security

Chapter 17. Transport-Level Security Chapter 17 Transport-Level Security Web Security Considerations The World Wide Web is fundamentally a client/server application running over the Internet and TCP/IP intranets The following characteristics

More information

Basic Internet programming Formalities. Hands-on tools for internet programming

Basic Internet programming Formalities. Hands-on tools for internet programming Welcome Basic Internet programming Formalities Hands-on tools for internet programming DD1335 (gruint10) Serafim Dahl serafim@nada.kth.se DD1335 (Lecture 1) Basic Internet Programming Spring 2010 1 / 23

More information

Computer Networks - Xarxes de Computadors

Computer Networks - Xarxes de Computadors Computer Networks - Xarxes de Computadors Teacher: Llorenç Cerdà Slides: http://studies.ac.upc.edu/fib/grau/xc Outline Course Syllabus Unit 2. IP Networks Unit 3. TCP Unit 4. LANs Unit 5. Network applications

More information

Due for Week Group of 3 (max) Percentage awarded for comments, coding practice, layout style, naming convention, completed task.

Due for Week Group of 3 (max) Percentage awarded for comments, coding practice, layout style, naming convention, completed task. EE4607 Project Goals Details Due for Week 11-12. Group of 3 (max) Percentage awarded for comments, coding practice, layout style, naming convention, completed task. Task Create a SDL implementation of

More information

Transport Layer Protocols

Transport Layer Protocols Transport Layer Protocols Version. Transport layer performs two main tasks for the application layer by using the network layer. It provides end to end communication between two applications, and implements

More information

Network Scanning: A New Feature for Digital Copiers

Network Scanning: A New Feature for Digital Copiers Network Scanning: A New Feature for Digital Copiers Abstract Introduction The method of implementing electronic document capture and distribution, known as network scanning, into the traditional copier/printer

More information

Computer Networks/DV2 Lab

Computer Networks/DV2 Lab Computer Networks/DV2 Lab Room: BB 219 Additional Information: http://ti.uni-due.de/ti/en/education/teaching/ss13/netlab Equipment for each group: - 1 Server computer (OS: Windows Server 2008 Standard)

More information

CPS221 Lecture: Layered Network Architecture

CPS221 Lecture: Layered Network Architecture CPS221 Lecture: Layered Network Architecture Objectives last revised 9/10/12 1. To discuss the OSI layered architecture model 2. To discuss the specific implementation of this model in TCP/IP Materials:

More information

Dissertation Title: SOCKS5-based Firewall Support For UDP-based Application. Author: Fung, King Pong

Dissertation Title: SOCKS5-based Firewall Support For UDP-based Application. Author: Fung, King Pong Dissertation Title: SOCKS5-based Firewall Support For UDP-based Application Author: Fung, King Pong MSc in Information Technology The Hong Kong Polytechnic University June 1999 i Abstract Abstract of dissertation

More information

IPv6 Enabling CIFS/SMB Applications

IPv6 Enabling CIFS/SMB Applications IPv6 Enabling CIFS/SMB Applications 2010 Storage Developers Conference Santa Clara Dr David Holder CEng FIET MIEEE david.holder@erion.co.uk http://www.erion.co.uk Background Erion David Holder Over twelve

More information

INUVIKA OPEN VIRTUAL DESKTOP FOUNDATION SERVER

INUVIKA OPEN VIRTUAL DESKTOP FOUNDATION SERVER INUVIKA OPEN VIRTUAL DESKTOP FOUNDATION SERVER ARCHITECTURE OVERVIEW AND SYSTEM REQUIREMENTS Mathieu SCHIRES Version: 1.0.0 Published March 5, 2015 http://www.inuvika.com Contents 1 Introduction 3 2 Architecture

More information

Introduction to Computer Networks

Introduction to Computer Networks Introduction to Computer Networks Chen Yu Indiana University Basic Building Blocks for Computer Networks Nodes PC, server, special-purpose hardware, sensors Switches Links: Twisted pair, coaxial cable,

More information

Objectives of Lecture. Network Architecture. Protocols. Contents

Objectives of Lecture. Network Architecture. Protocols. Contents Objectives of Lecture Network Architecture Show how network architecture can be understood using a layered approach. Introduce the OSI seven layer reference model. Introduce the concepts of internetworking

More information

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET) 2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET) There are three popular applications for exchanging information. Electronic mail exchanges information between people and file

More information

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2

SMTP-32 Library. Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows. Version 5.2 SMTP-32 Library Simple Mail Transfer Protocol Dynamic Link Library for Microsoft Windows Version 5.2 Copyright 1994-2003 by Distinct Corporation All rights reserved Table of Contents 1 Overview... 5 1.1

More information

Measurement of the Usage of Several Secure Internet Protocols from Internet Traces

Measurement of the Usage of Several Secure Internet Protocols from Internet Traces Measurement of the Usage of Several Secure Internet Protocols from Internet Traces Yunfeng Fei, John Jones, Kyriakos Lakkas, Yuhong Zheng Abstract: In recent years many common applications have been modified

More information

Assessment Plan for CS and CIS Degree Programs Computer Science Dept. Texas A&M University - Commerce

Assessment Plan for CS and CIS Degree Programs Computer Science Dept. Texas A&M University - Commerce Assessment Plan for CS and CIS Degree Programs Computer Science Dept. Texas A&M University - Commerce Program Objective #1 (PO1):Students will be able to demonstrate a broad knowledge of Computer Science

More information

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013 Mobility Introduction Android Duration 16 Working days Start Date 1 st Oct 2013 Day 1 1. Introduction to Mobility 1.1. Mobility Paradigm 1.2. Desktop to Mobile 1.3. Evolution of the Mobile 1.4. Smart phone

More information

Network: several computers who can communicate. bus. Main example: Ethernet (1980 today: coaxial cable, twisted pair, 10Mb 1000Gb).

Network: several computers who can communicate. bus. Main example: Ethernet (1980 today: coaxial cable, twisted pair, 10Mb 1000Gb). 1 / 17 Network: several computers who can communicate. Bus topology: bus Main example: Ethernet (1980 today: coaxial cable, twisted pair, 10Mb 1000Gb). Hardware has globally unique MAC addresses (IDs).

More information

< IMPACT > START ACCELERATE IMPACT

< IMPACT > START ACCELERATE IMPACT START ACCELERATE IMPACT IMPACT project has received funding from the European Union Seventh Framework Programme (FP7/2007-2013) under grant agreement n 632828 START ACCELERATE IMPACT WEBINAR #2 Technology

More information

File Transfer And Access (FTP, TFTP, NFS) Chapter 25 By: Sang Oh Spencer Kam Atsuya Takagi

File Transfer And Access (FTP, TFTP, NFS) Chapter 25 By: Sang Oh Spencer Kam Atsuya Takagi File Transfer And Access (FTP, TFTP, NFS) Chapter 25 By: Sang Oh Spencer Kam Atsuya Takagi History of FTP The first proposed file transfer mechanisms were developed for implementation on hosts at M.I.T.

More information

Protocols and Architecture. Protocol Architecture.

Protocols and Architecture. Protocol Architecture. Protocols and Architecture Protocol Architecture. Layered structure of hardware and software to support exchange of data between systems/distributed applications Set of rules for transmission of data between

More information

Interprocess Communication Message Passing

Interprocess Communication Message Passing Interprocess Communication Message Passing IPC facility provides two operations: send(message) message size fixed or variable receive(message) If P and Q wish to communicate, they need to: establish a

More information

Client / Server Programming with TCP/IP Sockets

Client / Server Programming with TCP/IP Sockets Client / Server Programming with TCP/IP Sockets Author: Rajinder Yadav Date: Sept 9, 2007 Revision: Mar 11, 2008 Web: http://devmentor.org Email: rajinder@devmentor.org Table of Content Networks... 2 Diagram

More information

Oct 15, 2004 www.dcs.bbk.ac.uk/~gmagoulas/teaching.html 3. Internet : the vast collection of interconnected networks that all use the TCP/IP protocols

Oct 15, 2004 www.dcs.bbk.ac.uk/~gmagoulas/teaching.html 3. Internet : the vast collection of interconnected networks that all use the TCP/IP protocols E-Commerce Infrastructure II: the World Wide Web The Internet and the World Wide Web are two separate but related things Oct 15, 2004 www.dcs.bbk.ac.uk/~gmagoulas/teaching.html 1 Outline The Internet and

More information

(Refer Slide Time: 02:17)

(Refer Slide Time: 02:17) Internet Technology Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture No #06 IP Subnetting and Addressing (Not audible: (00:46)) Now,

More information

Traffic Analyzer Based on Data Flow Patterns

Traffic Analyzer Based on Data Flow Patterns AUTOMATYKA 2011 Tom 15 Zeszyt 3 Artur Sierszeñ*, ukasz Sturgulewski* Traffic Analyzer Based on Data Flow Patterns 1. Introduction Nowadays, there are many systems of Network Intrusion Detection System

More information

Computer Network. Interconnected collection of autonomous computers that are able to exchange information

Computer Network. Interconnected collection of autonomous computers that are able to exchange information Introduction Computer Network. Interconnected collection of autonomous computers that are able to exchange information No master/slave relationship between the computers in the network Data Communications.

More information

Globus Striped GridFTP Framework and Server. Raj Kettimuthu, ANL and U. Chicago

Globus Striped GridFTP Framework and Server. Raj Kettimuthu, ANL and U. Chicago Globus Striped GridFTP Framework and Server Raj Kettimuthu, ANL and U. Chicago Outline Introduction Features Motivation Architecture Globus XIO Experimental Results 3 August 2005 The Ohio State University

More information

Masters of Science in Information Technology

Masters of Science in Information Technology Objective: At the end of this module, you must be able to 1. Establish a basic understanding of the Internet 2. Understand the Internet's evolution What is Internet? Internet is a vast collection of different

More information

System calls. Problem: How to access resources other than CPU

System calls. Problem: How to access resources other than CPU System calls Problem: How to access resources other than CPU - Disk, network, terminal, other processes - CPU prohibits instructions that would access devices - Only privileged OS kernel can access devices

More information

TCP/IP Sockets in Java: Practical Guide for Programmers

TCP/IP Sockets in Java: Practical Guide for Programmers TCP/IP Sockets in Java: Practical Guide for Programmers Kenneth L. Calvert Michael J. Donahoo Computer Chat! How do we make computers talk?! How are they interconnected? Internet Protocol (IP) Internet

More information

File S1: Supplementary Information of CloudDOE

File S1: Supplementary Information of CloudDOE File S1: Supplementary Information of CloudDOE Table of Contents 1. Prerequisites of CloudDOE... 2 2. An In-depth Discussion of Deploying a Hadoop Cloud... 2 Prerequisites of deployment... 2 Table S1.

More information

GenericServ, a Generic Server for Web Application Development

GenericServ, a Generic Server for Web Application Development EurAsia-ICT 2002, Shiraz-Iran, 29-31 Oct. GenericServ, a Generic Server for Web Application Development Samar TAWBI PHD student tawbi@irit.fr Bilal CHEBARO Assistant professor bchebaro@ul.edu.lb Abstract

More information

CS413: Computer Networks

CS413: Computer Networks CS413: Computer Networks 2005 Fall Term Midterm Exam Solution Student ID: Name: Problem No. Marks Your Marks 1 16 2 5 3 5 4 7 5 4 6 7 7 3 8 3 Total 50 1 [Marking schemes are given in blue color and the

More information

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts

More information

1. Responsive Website Basics: Code with HTML, CSS and JavaScript 2. Responsive Web Design

1. Responsive Website Basics: Code with HTML, CSS and JavaScript 2. Responsive Web Design Massive Open Online Courses (MOOCs): Goldsmiths 1. Responsive Website Basics: Code with HTML, CSS and JavaScript 2. Responsive Web Design As part of a MOOCs specialisation: Responsive website development

More information

Computer Networks. A Top-Down Approach. Behrouz A. Forouzan. and. Firouz Mosharraf. \Connect Mc \ Learn. Hill

Computer Networks. A Top-Down Approach. Behrouz A. Forouzan. and. Firouz Mosharraf. \Connect Mc \ Learn. Hill Computer Networks A Top-Down Approach Behrouz A. Forouzan and Firouz Mosharraf \Connect Mc \ Learn Graw I Succeed* Hill Preface xvii Trademarks xxiii Chapter 1 Introduction 1 1.1 OVERVIEW OF THE INTERNET

More information

Writing Client/Server Programs in C Using Sockets (A Tutorial) Part I. Session 5958. Greg Granger grgran@sas. sas.com. SAS/C & C++ Support

Writing Client/Server Programs in C Using Sockets (A Tutorial) Part I. Session 5958. Greg Granger grgran@sas. sas.com. SAS/C & C++ Support Writing Client/Server Programs in C Using Sockets (A Tutorial) Part I Session 5958 Greg Granger grgran@sas sas.com SAS Slide 1 Feb. 1998 SAS/C & C++ Support SAS Institute Part I: Socket Programming Overview

More information

Virtual KNX/EIB devices in IP networks

Virtual KNX/EIB devices in IP networks WEINZIERL ENGINEERING GmbH WEINZIERL ENGINEERING GMBH F. Heiny, Dr. Y. Kyselytsya, Dr. Th. Weinzierl Bahnhofstr. 6 D-84558 Tyrlaching Tel. +49 (0) 8623 / 987 98-03 E-Mail: info@weinzierl.de Web: www.weinzierl.de

More information

Course Descriptions. preparation.

Course Descriptions. preparation. Course Descriptions CS 101 Intro to Computer Science An introduction to computer science concepts and the role of computers in society. Topics include the history of computing, computer hardware, operating

More information

Developing Web-Based Courses Using an Online Development Guide and Templates

Developing Web-Based Courses Using an Online Development Guide and Templates Session 2247 Developing Web-Based Courses Using an Online Development Guide and Templates James A. Rehg Penn State Altoona Abstract The impact of the web on engineering and engineering technology education

More information

Understanding TCP/IP. Introduction. What is an Architectural Model? APPENDIX

Understanding TCP/IP. Introduction. What is an Architectural Model? APPENDIX APPENDIX A Introduction Understanding TCP/IP To fully understand the architecture of Cisco Centri Firewall, you need to understand the TCP/IP architecture on which the Internet is based. This appendix

More information