1 An application in BPC: a Web-Server



Similar documents
Transport Layer Protocols

Computer Networks. Chapter 5 Transport Protocols

Computer Networks UDP and TCP

Midterm Exam CMPSCI 453: Computer Networks Fall 2011 Prof. Jim Kurose

Computer Networks Practicum 2015

Overview. Securing TCP/IP. Introduction to TCP/IP (cont d) Introduction to TCP/IP

Chapter 3. Internet Applications and Network Programming

ICOM : Computer Networks Chapter 6: The Transport Layer. By Dr Yi Qian Department of Electronic and Computer Engineering Fall 2006 UPRM

Life of a Packet CS 640,

B-2 Analyzing TCP/IP Networks with Wireshark. Ray Tompkins Founder of Gearbit

This sequence diagram was generated with EventStudio System Designer (

Objectives of Lecture. Network Architecture. Protocols. Contents

COMP 3331/9331: Computer Networks and Applications. Lab Exercise 3: TCP and UDP (Solutions)

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

First Midterm for ECE374 02/25/15 Solution!!

Digital Audio and Video Data

Protocols and Architecture. Protocol Architecture.

Advanced Computer Networks Project 2: File Transfer Application

[Prof. Rupesh G Vaishnav] Page 1

Mathematical Modelling of Computer Networks: Part II. Module 1: Network Coding

Per-Flow Queuing Allot's Approach to Bandwidth Management

CSE331: Introduction to Networks and Security. Lecture 9 Fall 2006

Improving DNS performance using Stateless TCP in FreeBSD 9

CSE 473 Introduction to Computer Networks. Exam 2 Solutions. Your name: 10/31/2013

Computer Networks Homework 1

Chapter 5. Transport layer protocols

Recent advances in transport protocols

Basic Networking Concepts. 1. Introduction 2. Protocols 3. Protocol Layers 4. Network Interconnection/Internet

Disfer. Sink - Sensor Connectivity and Sensor Android Application. Protocol implementation: Charilaos Stais (stais AT aueb.gr)

Transparent Redirection of Network Sockets 1

Computer Networks - CS132/EECS148 - Spring

TCP Performance Management for Dummies

Firewalls. Test your Firewall knowledge. Test your Firewall knowledge (cont) (March 4, 2015)

Names & Addresses. Names & Addresses. Hop-by-Hop Packet Forwarding. Longest-Prefix-Match Forwarding. Longest-Prefix-Match Forwarding

Transparent Redirection of Network Sockets 1

CPS221 Lecture: Layered Network Architecture

First Midterm for ECE374 03/24/11 Solution!!

Ethernet. Ethernet. Network Devices

A Transport Protocol for Multimedia Wireless Sensor Networks

Project 4: (E)DoS Attacks

FILE TRANSFER PROTOCOL INTRODUCTION TO FTP, THE INTERNET'S STANDARD FILE TRANSFER PROTOCOL

Network Security. Chapter 3. Cornelius Diekmann. Version: October 21, Lehrstuhl für Netzarchitekturen und Netzdienste Institut für Informatik

Hands-on Network Traffic Analysis Cyber Defense Boot Camp

PART OF THE PICTURE: The TCP/IP Communications Architecture

Implementing and testing tftp

Internet Firewall CSIS Packet Filtering. Internet Firewall. Examples. Spring 2011 CSIS net15 1. Routers can implement packet filtering

How do I get to

Final exam review, Fall 2005 FSU (CIS-5357) Network Security

Content Distribution Networks (CDN)

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

THE BCS PROFESSIONAL EXAMINATIONS BCS Level 5 Diploma in IT. October 2009 EXAMINERS' REPORT. Computer Networks

Note! The problem set consists of two parts: Part I: The problem specifications pages Part II: The answer pages

Understanding Layer 2, 3, and 4 Protocols

Introduction to IP networking

(Refer Slide Time: 02:17)

Multipath TCP in Practice (Work in Progress) Mark Handley Damon Wischik Costin Raiciu Alan Ford

Data Link Layer(1) Principal service: Transferring data from the network layer of the source machine to the one of the destination machine

CS268 Exam Solutions. 1) End-to-End (20 pts)

Module 1. Introduction. Version 2 CSE IIT, Kharagpur

Key Components of WAN Optimization Controller Functionality

Background (

Chapter 3. TCP/IP Networks. 3.1 Internet Protocol version 4 (IPv4)

Network Security TCP/IP Refresher

We will give some overview of firewalls. Figure 1 explains the position of a firewall. Figure 1: A Firewall

Unit 23. RTP, VoIP. Shyam Parekh

First Midterm for ECE374 03/09/12 Solution!!

Session Initiation Protocol (SIP) The Emerging System in IP Telephony

Final for ECE374 05/06/13 Solution!!

COMP 361 Computer Communications Networks. Fall Semester Midterm Examination

A Meeting Room Scheduling Problem

Improving the Performance of TCP Using Window Adjustment Procedure and Bandwidth Estimation

Lecture 2-ter. 2. A communication example Managing a HTTP v1.0 connection. G.Bianchi, G.Neglia, V.Mancuso

point to point and point to multi point calls over IP

Internet Firewall CSIS Internet Firewall. Spring 2012 CSIS net13 1. Firewalls. Stateless Packet Filtering

DoS: Attack and Defense

Transport and Network Layer

IP Network Layer. Datagram ID FLAG Fragment Offset. IP Datagrams. IP Addresses. IP Addresses. CSCE 515: Computer Network Programming TCP/IP

First Workshop on Open Source and Internet Technology for Scientific Environment: with case studies from Environmental Monitoring

A New Approach to Enhance Performance Through SMTP Protocol

Networking Security IP packet security

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

Firewalls, IDS and IPS

Effect of Packet-Size over Network Performance

Lab Exercise Objective. Requirements. Step 1: Fetch a Trace

Title: DEVELOPING TCP/IP AND UDP TRAFFIC MONITORING TOOL. RAFIQ BIN CHE MAT ( )

1. The subnet must prevent additional packets from entering the congested region until those already present can be processed.

IP - The Internet Protocol

Course Overview: Learn the essential skills needed to set up, configure, support, and troubleshoot your TCP/IP-based network.

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Virtual KNX/EIB devices in IP networks

The Transport Layer and Implica4ons for Network Monitoring. CS 410/510 Spring 2014

Mobile Communications Chapter 9: Mobile Transport Layer

It is the thinnest layer in the OSI model. At the time the model was formulated, it was not clear that a session layer was needed.

OSI Model. Application Presentation Session Transport Network Data Link Physical. EE156 Computer Network Architecture

Configuring Health Monitoring

Modeling Workflow Patterns

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

Transcription:

1 An application in BPC: a Web-Server We briefly describe our web-server case-study, dwelling in particular on some of the more advanced features of the BPC framework, such as timeouts, parametrized events, dynamic thread creation and customized event selection. We also try to convey to the reader a sense of the interaction between the behavioral code and native C ++ code, and of the development process of a behavioral application. 1.1 TCP & HTTP Our web-server application consists of two protocol stacks: one for TCP and one for HTTP. The Transmission Control Protocol (TCP) is a widespread connectionoriented protocol, mainly used for the transfer of data across the internet. The principle feature of TCP is its reliability: it guarantees that data arrives without errors and in the order in which it was sent. To accomplish this, the end parties acknowledge the reception of each TCP segment using a scheme of agreed-upon sequence numbers; segments that are lost or arrive corrupt are not acknowledged, and are then retransmitted. As TCP entails redundancy in the bits being sent, it contains flow and congestion control features, meant to prevent overwhelming an endpoint or clogging the network. The Hypertext Transfer Protocol (HTTP) is a protocol typically used by webservers. The client (the browser) submits HTTP requests to the server, which then performs local actions on behalf of the client and sends responses; in particular, the server might retrieve webpages, send error or redirection messages, or run scripts locally and send the their output to the client. 1.2 The Implementation s Layout Our application consists of two separate sets of threads, one for the TCP layer and one for the HTTP layer. The two layers interact with each other via behavioral events that is, each has a thread constantly waiting for certain events generated by the other. Each layer also has one additional source of input: the TCP layer reads TCP segments off a raw socket, and the HTTP layer reads files from a given directory. These additional inputs are obtained by threads containing non-trivial native C ++ code, and are then translated into behavioral events in order to be passed to other threads. Internally, each layer is designed using a dispatcher architecture: a dispatcher thread handles each incoming segment, classifies it according to its attributes, and then passes it to specific handler threads via behavioral events. These handler threads can then request additional events in order to issue a reply and/or update other threads of the contents of the segment. Handlers typically perform local computation using native C ++ code e.g., calculating TCP checksums or reading files from the directory. Incoming TCP segments containing HTTP

requests are passed between the layers, and the same happens to HTTP replies on their way to the client. To exemplify the server s operation we describe in more detail the handling of TCP connection establishment requests (SYN segments). Initially, the RawSocketReceiver sensor thread reads the incoming segment from the socket. When it is received, the thread requests a tcpsegmentreceived event with the segment as its parameter in order to pass the segment to the TcpDispatcher thread. The TcpDispatcher uses native C ++ code to classify incoming TCP segments according to their attributes, and requests additional events accordingly. SYN requests, for example, are identified by reading the TCP header of the segment and checking whether the SYN flag is set. If so, the thread requests a tcpsynrequest event in order to notify TcpSynHandler the specific handler for SYN requests. The TcpSynHandler thread responds to each request by generating a tcpoutgoingsegment event, with a SYN-ACK segment as its parameter. Finally, this event then gets translated into a tcpsendsegment event handled by the Raw- SocketSender sender thread, which actually sends the SYN-ACK segment to the client. We note that in order to construct the SYN-ACK segment, the TcpSynHandler thread must first acquire a fresh sequence number. This is performed by sending a request to, and receiving a response from, the SequenceNumberAllocator thread the thread in charge of managing the sequence numbers of every TCP connection. SequenceNumberAllocator may handle simultaneous requests for sequence numbers (for the same connection) from multiple threads, and here the BP event selection mechanism guarantees that each outgoing segment has a fresh sequence number: SequenceNumberAllocator handles requests (represented by events) sequentially, and thus race conditions are avoided. Apart from dispatcher and handler threads, additional standalone threads exist in the system: for instance, the requirement that TCP segments be sent only on active connections is enforced by the TcpEnsureActiveConnection thread. This thread uses blocking to ensure that a tcpsynrequest is triggered before other TCP events such as those signalling PUSH or ACK segments are triggered. Likewise, once a FIN segment is triggered, the thread blocks any additional TCP events for that connection. Segment Reordering TCP segments that contain data for the HTTP layer are not guaranteed to arrive in the order in which they were sent. Hence, the TCP layer needs to reorder them before passing them on. During data transfer, TCP segments with data for the HTTP layer cause the triggering of datatohttp events. Each of these events carries the received segment s sequence number as a parameter. The TCP stack knows the expected sequence number of the next data segment: the initial sequence number is stated by the client at the time of connection establishment, and is subsequently incremented for each segment. Whenever an incoming sequence number is greater than the one expected, the stack realizes that a segment is missing; and when this

segment later arrives, reordering takes place. Pseudocode for the SegmentSorter thread, which is in charge of this reordering, appears in Fig. 1. void entrypoint () { // SegmentSorter thread while ( true ) { waited. append ( tcpsynrequest ); waited. append ( datatohttp ); }}; e = lastevent (); if ( e. type () == tcpsynrequest ) storesequencenumber ( e. sequencenumber () ); else if ( e. sequencenumber ()!= expectednumber () ) storedata ( e. data () ); else sendreorderedsegments ( e. data () ); Fig. 1. The SegmentSorter thread waits for tcpsynrequest and datatohttp events. When a tcpsynrequest event occurs, the thread extracts the sequence number for later use. When an actual data segment is received, its sequence number is compared to the expected number. If it does not match, the segment is stored. If it does match, the segment is passed on to the HTTP layer, along with any consecutive segments previously stored, and the expected sequence number is updated. Segment Retransmission When sending out a segment, the TCP stack must wait for an acknowledgment message and if one does not arrive, the segment needs to be resent. There exist several sophisticated retransmission policies, aimed at reducing traffic congestion, which have adjustable retransmission periods. For our case-study we opted for the simplest scheme retransmission after a fixed waiting period. Implementing additional schemes is left for future work. In our implementation, segments leaving the TCP stack on their way to be sent to the client always pass as tcpoutgoingsegment events. Our retransmission mechanism waits for these events and stores the outgoing segments. Then, if they are not acknowledged withing a fixed period of time, it retransmits them. Pseudocode appears in Fig. 2 1. Customized Event Selection During development, we occasionally found customizing the event selection strategy a straightforward method in order to enforce certain requirements. For example, in one case we wanted to ensure that all outgoing segments finish sending prior to sending the segment indicating the connection being closed (a FIN segment) a property that was not trivially 1 The depicted solution spawns a thread dynamically for each outgoing segment, which incurs overhead. In practice, we found that it was more efficient to spawn one Retransmitter thread per connection, and have it handle all of that connection s segments. Nevertheless, we feel Fig. 2 better illustrates the principles of dynamic thread creation.

class Retransmitter : public BThread { void entrypoint () { waited. append ( tcpoutgoingsegment ); }}}; while ( true ) { new PeriodicSender ( lastevent () ); class PeriodicSender : public BThread { PeriodicSender ( Event tcpoutgoingsegment ) { storedsegment = tcpoutgoingsegment ; } void entrypoint () { bool done = false ; while (! done ) { waited. append ( ackforstoredsegment () ); }}}; bsync ( requested, waited, blocked, 2 ); if ( timeoutonlastsync () ) { waited. clear (); requested. append ( tcpsendsegment ( storedsegment ) ); } else done = true ; Fig. 2. Pseudocode for the segment retransmission mechanism. The Retransmitter thread waits-for tcpoutgoingsegment events events that indicate a TCP segment about to be sent and for each such event it spawns an instance of the PeriodicSender thread. The PeriodicSender instance receives through its constructor the segment that it is supposed to monitor. It then waits for an acknowledgment of that segment for 2 seconds. If an acknowledgment message fails to arrive, the thread retransmits the segment, and the process repeats. When an acknowledgment is received, the thread terminates. Note that the ackforstoredsegment method (code omitted) is a predicate it evaluates to true only for tcpackreceived events with the proper acknowledgment information. upheld by the TCP stack. Another example was giving priority to starving connections, namely connections whose events have not been triggered in a while, in order to avoid retransmission of segments and the congestion incurred by it. Pseudocode for a customized event selection function that addresses these two issues appears in Fig. 3.

Event choose ( Vector <Event > enabledevents ) { Vector <Event > candidates = eventsofstarvedconnection ( enabledevents ); }; if ( candidates. contains ( sendtcpfin ) && candidates. containsotherthan ( sendtcpfin ) ) return candidates. otherthan ( sendtcpfin ); else return candidates [0]; Fig. 3. Pseudocode for the customized event selection strategy. At every synchronization point, this function is invoked with the set of enabled events, of which it must select one for triggering. Information from previous iterations may be stored. Our specific implementation gives precedence to previously starved connections: that is, it favors the connection that has waited the longest for an event to be triggered. This part is abstracted away in the method eventsofstarvedconnection. Once a connection is selected, its associated events are the candidates for triggering; among these, we prefer events that are not sendtcpfin, so that pending data transmission requests are addressed before the connection is closed. Otherwise, an arbitrary event is selected.