===Socket API User/ OS interface === COP

Similar documents
Mobile Transport Layer Lesson 02 TCP Data Stream and Data Delivery

Connections. Topics. Focus. Presentation Session. Application. Data Link. Transport. Physical. Network

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Transport Layer (TCP/UDP)

CSE/EE 461 Lecture 14. Connections. Last Time. This Time. We began on the Transport layer. Focus How do we send information reliably?

The Transport Layer: TCP & Reliable Data Transfer

Operating Systems and Networks. Network Lecture 8: Transport Layer. Adrian Perrig Network Security Group ETH Zürich

Operating Systems and Networks. Network Lecture 8: Transport Layer. Where we are in the Course. Recall. Transport Layer Services.

Chapter 3 outline. 3.5 connection-oriented transport: TCP segment structure reliable data transfer flow control connection management

TCP (Part 2) Session 10 INST 346 Technologies, Infrastructure and Architecture

ECE 650 Systems Programming & Engineering. Spring 2018

L41: Lab 4 - The TCP State Machine

Computer Networking Introduction

Introduction to Networking. Operating Systems In Depth XXVII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

10 minutes survey (anonymous)

CMPE 150/L : Introduction to Computer Networks. Chen Qian Computer Engineering UCSC Baskin Engineering Lecture 9

CSCI Topics: Internet Programming Fall 2008

Mobile Transport Layer Lesson 10 Timeout Freezing, Selective Retransmission, Transaction Oriented TCP and Explicit Notification Methods

Lecture 12: Transport Layer TCP again

Chapter III: Transport Layer

CS 4390 Computer Networks. Pointers to Corresponding Section of Textbook

Chapter 3- parte B outline

Transport Layer Review

CSC 401 Data and Computer Communications Networks

Chapter 3 Transport Layer

CS4700/CS5700 Fundamentals of Computer Networks

Chapter 3 Transport Layer

CS419: Computer Networks. Lecture 10, Part 2: Apr 11, 2005 Transport: TCP mechanics (RFCs: 793, 1122, 1323, 2018, 2581)

CSE 461 Module 11. Connections

internet technologies and standards

Last Class. CSE 123b Communications Software. Today. Naming Processes/Services. Transmission Control Protocol (TCP) Picking Port Numbers.

NWEN 243. Networked Applications. Layer 4 TCP and UDP

Correcting mistakes. TCP: Overview RFCs: 793, 1122, 1323, 2018, TCP seq. # s and ACKs. GBN in action. TCP segment structure

Transport Protocols & TCP TCP

ECE 435 Network Engineering Lecture 9

User Datagram Protocol

CSCE 463/612 Networks and Distributed Processing Spring 2017

L41: Lab 4 - The TCP State Machine

TCP reliable data transfer. Chapter 3 outline. TCP sender events: TCP sender (simplified) TCP: retransmission scenarios. TCP: retransmission scenarios

internet technologies and standards

Transport layer. UDP: User Datagram Protocol [RFC 768] Review principles: Instantiation in the Internet UDP TCP

Transport layer. Review principles: Instantiation in the Internet UDP TCP. Reliable data transfer Flow control Congestion control

Transport Protocols and TCP: Review

Lecture 3: The Transport Layer: UDP and TCP

Some slides courtesy David Wetherall. Communications Software. Lecture 4: Connections and Flow Control. CSE 123b. Spring 2003.

L41: Lab 4 The TCP State Machine. Lecturelet 4 Dr Robert N. M. Watson and Dr Graeme Jenkinson 2 February 2018

CSE 461 The Transport Layer

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

TCP : Fundamentals of Computer Networks Bill Nace

Chapter 3 outline. 3.5 Connection-oriented transport: TCP. 3.6 Principles of congestion control 3.7 TCP congestion control

CSEP 561 Connections. David Wetherall

Lecture 20 Overview. Last Lecture. This Lecture. Next Lecture. Transport Control Protocol (1) Transport Control Protocol (2) Source: chapters 23, 24

Monitoring Active and Recent Connections

CSE 461 Connections. David Wetherall

The design and implementation of tcp-ip. 07 Lwip Interface (RAW API)

Transport Layer: outline

CNT 6885 Network Review on Transport Layer

Chapter 3 Transport Layer

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

ETSF05/ETSF10 Internet Protocols Transport Layer Protocols

Internetworking With TCP/IP

Internetworking With TCP/IP

Programming Assignment 3: Transmission Control Protocol

P a g e i. Project Report on TCP over SoNIC. Project Report. TCP over SoNIC. Group Members. Abhishek Kumar Maurya

Chapter 3 Transport Layer

CS 356: Computer Network Architectures. Lecture 17: End-to-end Protocols and Lab 3 Chapter 5.1, 5.2. Xiaowei Yang

Status and Policy Entries

Transmission Control Protocol (TCP)

CSEP 561 Connections. David Wetherall

TCP Review. Carey Williamson Department of Computer Science University of Calgary Winter 2018

Lecture 08: The Transport Layer (Part 2) The Transport Layer Protocol (TCP) Dr. Anis Koubaa

Outline. What is TCP protocol? How the TCP Protocol Works SYN Flooding Attack TCP Reset Attack TCP Session Hijacking Attack

End-to-End Protocols. End-to-End Protocols

Lecture 8. TCP/IP Transport Layer (2)

Chapter III: Transport Layer

Chapter 3 Transport Layer

TCP. TCP: Overview. TCP Segment Structure. Maximum Segment Size (MSS) Computer Networks 10/19/2009. CSC 257/457 - Fall

Suprakash Datta. Office: CSEB 3043 Phone: ext Course page:

TCP Basics : Computer Networking. Overview. What s Different From Link Layers? Introduction to TCP. TCP reliability Assigned reading

Transport Layer: Outline

CMSC 417. Computer Networks Prof. Ashok K Agrawala Ashok Agrawala. October 25, 2018

Zero-Copy Socket Splicing

Lenuta Alboaie Computer Networks

CS 640 Introduction to Computer Networks Spring 2009

Lecture 3 The Transport Control Protocol (TCP) Antonio Cianfrani DIET Department Networking Group netlab.uniroma1.it

05 Transmission Control Protocol (TCP)

Transport Protocols. ISO Defined Types of Network Service: rate and acceptable rate of signaled failures.

CSCI-1680 Transport Layer I Rodrigo Fonseca

Kent State University

TRANSMISSION CONTROL PROTOCOL. ETI 2506 TELECOMMUNICATION SYSTEMS Monday, 7 November 2016

CSCD 330 Network Programming

3.5.6 TCP Connection Management

CSCI-1680 Transport Layer I Rodrigo Fonseca

S 3 : the Small Scheme Stack A Scheme TCP/IP Stack Targeting Small Embedded Applications

CSE 4213: Computer Networks II

CS118 Discussion 1A, Week 4. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.

COMP 431 Internet Services & Protocols. Transport Layer Protocols & Services Outline. The Transport Layer Reliable data delivery & flow control in TCP

Operating Systems. 17. Sockets. Paul Krzyzanowski. Rutgers University. Spring /6/ Paul Krzyzanowski

TCP: Transmission Control Protocol UDP: User Datagram Protocol TCP - 1

Stream Control Transmission Protocol (SCTP)

Transcription:

The COP (connection oriented reliable packet stream) protocol COP is a packet oriented transport protocol whose objective is to tame some aspects of the bad behavior of UDP. Application ===Socket API User/ OS interface === COP IP Link 1

COP data structures Ring buffers Ring buffers are used to hold pointers to (1) buffers that have been transmitted but are awaiting acknowledgement (2) buffers containing packets that have been received out of order. typedef struct cop_oqe_type { struct sk_buff *skb; /* buffer address */ unsigned long txtime; /* in jiffies */ } cop_oqe_t; The ring buffers are stored in an array indexed by packet sequence number. 2

The cop_sock The cop_sock is the principal structure controlling protocol operations. It is created in response to an application call to socket(af_inet, SOCK_COP, IPPROTO_COP); It is destroyed when the socket is closed. typedef struct cop_sock { struct inet_sock inet; struct sock *sk; unsigned int state; /* Type of connection AD, FCD, etc */ /* Network and transport header skeletons for fast copy */ struct iphdr iph; struct cop_hdr coph; 3

/* Connection state data */ unsigned char nxtsnd; /* Next send seq num */ unsigned char nxtrcv; /* Next expected pkt */ unsigned char lastack; /* Last ack received */ unsigned char win; /* Offered window */ unsigned char uwin; /* Usable window */ unsigned char dup_acks; /* Duplicate ack ctr */ unsigned char wuppend; /* persist timer armed */ unsigned char maxrxqlen; /* Max offered window */ unsigned int disable; /* Prevents redundant fast retx */ struct timeval lasttx; /* Time of last tx for wup */ /* These ring buffers are indexed by packet sequence numbers */ /* and used to hold pointers to transmitted buffers pending */ /* acks and out of order received packets. For 8 bit seq */ /* SEQ_SPACE_SIZE = 256 */ cop_wqe_t ack_pend[seq_space_size]; cop_wqe_t rcv_pend[seq_space_size]; 4

/* Performance metrics */ unsigned long timeouts; /* Timeouts */ unsigned long fastretx; /* Fast retransmissions */ unsigned long txdrops; /* Synthesized drops */ unsigned long rxdrops; /* Drops for rcv queue */ unsigned long txtotal; /* Total tx data packets */ unsigned long rxtotal; /* Total rx data packets */ unsigned long txwups; /* WUP requests sent */ unsigned long rxwups; /* WUP acks received */ unsigned long txacks; /* ACKs sent */ unsigned long rxacks; /* ACKs received */ unsigned long ooacks; /* out of order acks */ unsigned long tototal; /* Total timeouts */ unsigned long restarts; /* Token bucket flow control data */ unsigned int maxrate; /* max number of packets per jiffy */ unsigned int maxcredit; /* max accumlated credits */ unsigned int millicredits; /* current number of millicredits */ int tickintvl; /* in jiffies */ struct timeval lasttick; /* time of last tick... */ /* Timers */ struct timer_list resend_timer; /* timer for send retransmits */ struct timer_list token_timer; /* timer token bucket timer */ struct timer_list persist_timer; /* persist timer */ /* Locks */ spinlock_t spinlock_t spinlock_t } cop_sock_t; cop_txlock; cop_loglock; cop_rxlock; 5

#define MAX_PORTS (64*1024) #define START_PORT (32*1024) #define COP_HTABLE_SIZE 64 unsigned char port_map[max_ports/8]; struct hlist_head cop_hash[ntp_htable_size]; rwlock_t cop_hash_lock = RW_LOCK_UNLOCKED; 6

The COP state machine The operation of COP (like other protocols) is controlled by a finite state machine Each COP socket exists in exactly one state at any point in time. There are two sources of input to the state machine: The API functions (bind(), listen(), connect(), sendto(), recvfrom(), connect(), close() Receipt of specific packet types. Associated with each state are a set of rules that determine What inputs (API function calls, or received packet types) are legal in the current state. How to respond to legal inputs How to respond to illegal inputs Response rules include The identity of the next state (which can be the current state). Packet type (if any) to send to the other end of the connection Value that an API function should return to its caller. The total number of rules for a fully specified system is: number of states x number of inputs 7

The TCP state machine +---------+ ---------\ active OPEN CLOSED \ ----------- +---------+<---------\ \ create TCB ^ \ \ snd SYN passive OPEN CLOSE \ \ ------------ ---------- \ \ create TCB delete TCB \ \ V \ \ +---------+ CLOSE \ LISTEN ---------- +---------+ delete TCB rcv SYN SEND ----------- ------- V +---------+ snd SYN,ACK / \ snd SYN +---------+ <----------------- ------------------> SYN rcv SYN SYN RCVD <----------------------------------------------- SENT snd ACK ------------------ ------------------- +---------+ rcv ACK of SYN \ / rcv SYN,ACK +---------+ -------------- ----------- x snd ACK V V CLOSE +---------+ ------- ESTAB snd FIN +---------+ CLOSE rcv FIN V ------- ------- +---------+ snd FIN / \ snd ACK +---------+ FIN <----------------- ------------------> CLOSE WAIT-1 ------------------ WAIT +---------+ rcv FIN \ +---------+ rcv ACK of FIN ------- CLOSE -------------- snd ACK ------- V x V snd FIN V +---------+ +---------+ +---------+ FINWAIT-2 CLOSING LAST-ACK +---------+ +---------+ +---------+ rcv ACK of FIN rcv ACK of FIN rcv FIN -------------- Timeout=2MSL -------------- ------- x V ------------ x V \ snd ACK +---------+delete TCB +---------+ ------------------------> TIME WAIT ------------------> CLOSED +---------+ +---------+ TCP Connection State Diagram 8

/* Header flag bits */ #define CPF_CONNECT 1 /* Connect request or connect ACK */ #define CPF_ACK 2 /* ACK number is valid */ #define CPF_FIN1 4 /* Close request */ #define CPF_FIN2 8 /* Close ACK */ #define CPF_WUP 16 /* Window update probe */ #define CPF_RESET 32 #define CPF_SUPV 64 9

Operation of the COP state machine The API as input source One source of input to the state machine is the set of API functions. The table below summarizes the collection of valid inputs and actions. A robust system needs to handle invalid inputs as well. API call Present state Output state Action socket() N/A TCP_CLOSED no action listen() TCP_CLOSED TCP_LISTEN wait for connect connect() TCP_CLOSED TCP_SYN_SENT sendsupv(cpf_connect) wait for connect ack. close() TCP_ESTABLISHED TCP_FIN_WAIT1 drain ouput queue purge receive queue sendsupv(cpf_fin1) wait for fin ack. invoke common release send/recv() TCP_ESTABLISHED TCP_ESTABLISHED no action recv() TCP_FIN_WAIT2 TCP_FIN_WAIT2 if receive queue empty return(0) send() TCP_FIN_WAIT2 TCP_FIN_WAIT2 return(0) State transitions and actions triggered by calls to the COP API 10

Pkt Type Present state Output state Action CPT_DATA TCP_ESTABLISHED TCP_ESTABLISHED no action CPT_SYN1 TCP_LISTEN TCP_ESTABLISHED sendsupv CPF_CONNECT CPF_ACK CPT_SYN2 TCP_SYN_SENT TCP_ESTABLISHED no action CPT_ACK TCP_ESTABLISHED TCP_ESTABLISHED no action CPT_FIN1 TCP_ESTABLISHED TCP_FIN_WAIT2 send ACK of FIN if (recv_queue empty) set sk_shutdown() wakeup interruptible CPT_FIN2 TCP_FIN_WAIT1 TCP_CLOSE proceed with sk_common_release() CPT_RESET TCP_ESTABLISHED TCP_CLOSED drain rx and tx queue and shutdown socket. CPT_RESET TCP_LISTEN TCP_LISTEN no action State transitions and actions triggered by calls to the COP API 11

Exception handling We have addressed the handling of the normal sequence of events in the connection protocol. However, we also need to be able to handle abnormal/erroneous inputs from both the API above and unexpected packet types from below. For incorrect API calls it is first necessary to determine if the call will be delivered to the COP layer or will be handled in the AF_INET layer. For those incorrect calls that are delivered to COP, a proper errno, must be returned. _CLOSE _LISTEN _SYN_SENT _ESTABLISHED bind() 1 2 3 4 connect() 5 1 2 3 listen() 4 5 1 2 send/recv() 3 4 5 1 When incorrect or unexpected packet types are received, it may or may not be necessary to change state and it may or may not be necessary to emit an CFP_SUPV reply. _CLOSE _LISTEN _SYN_SENT _ESTABLISHED syn1 2 3 4 5 syn2 1 2 3 4 data 5 1 2 3 reset 4 5 A A Responsibility for defining a consistent and correct state machine will be distributed among the teams in as shown above. We will have a design review next thursday in which each team proposes its solutions for the 5 situations it is responsible for. Each team should prepare a written pdf document describing in detail the actions that should be taken in each situation for which they are responsible. 12