NETW 703 Network Protocols Introduction Dr Eng Amr

  • Slides: 65
Download presentation
NETW 703 Network Protocols Introduction Dr. Eng. Amr T. Abdel-Hamid Spring 2020

NETW 703 Network Protocols Introduction Dr. Eng. Amr T. Abdel-Hamid Spring 2020

Amr Talaat How to develop protocols? (How to develop software? ) te() ea n.

Amr Talaat How to develop protocols? (How to develop software? ) te() ea n. cr ? r = so eces pred nil; r esso = succ n; (n') in n. jo r = so eces pred nil; r = esso succ ind_ n'. f From the first idea. . . to the final solution • A development process that can be structured

Amr Talaat Build and Fix Build first version Simple process model ‣used for small

Amr Talaat Build and Fix Build first version Simple process model ‣used for small projects Modify until client is satisfied Development Operations Mode Maintenance Retirement Problems • no specification phase • begin coding, think about requirements, design etc. later • higher effort for fixing errors in later phases

Amr Talaat Stages of the Development Process ‣ Basic activities (which appear in many

Amr Talaat Stages of the Development Process ‣ Basic activities (which appear in many process models) • Requirements analysis • Design specification • Validation • Implementation • Test and evaluation • Deployment • Maintenance

Amr Talaat Waterfall Model Requirements Design specification and validation Implementation Test and evaluation Deployment

Amr Talaat Waterfall Model Requirements Design specification and validation Implementation Test and evaluation Deployment and maintenance

Amr Talaat Waterfall Model (Problems) Requirements Design specification and validation requirements may change at

Amr Talaat Waterfall Model (Problems) Requirements Design specification and validation requirements may change at any stage Implementation Test and evaluation tests may reveal design flaws and programming errors fixes and patches Deployment and maintenance

Amr Talaat Modified Waterfall model Requirements Design specification and validation Implementation feedback loops Test

Amr Talaat Modified Waterfall model Requirements Design specification and validation Implementation feedback loops Test and evaluation Deployment and maintenance

Amr Talaat V Model Acceptance test Requirements System design System test Architecture design Integration

Amr Talaat V Model Acceptance test Requirements System design System test Architecture design Integration test Module design Implementation Unit test

Amr Talaat Process Models The bottom line: n Choice of a process models depends

Amr Talaat Process Models The bottom line: n Choice of a process models depends on the type and complexity of the project n Network protocols often need revisions and extensions due to changing requirements or problems n Protocol design is an iterative process

Amr Talaat Requirements n Requirements ¨ describe desired behaviour of a protocol ¨ independent

Amr Talaat Requirements n Requirements ¨ describe desired behaviour of a protocol ¨ independent of the later design and implementation (describe what the protocol does, not how) n Requirements Analysis/Engineering has its own process n

Amr Talaat Requirements engineering Customer or user requirements Requirements elicitation Requirements analysis and negotiation

Amr Talaat Requirements engineering Customer or user requirements Requirements elicitation Requirements analysis and negotiation Requirements documentation and specification Negotiated and validated requirements Requirements validation

Amr Talaat Types of Requirements n Functional requirements or use cases ¨ System behaviour

Amr Talaat Types of Requirements n Functional requirements or use cases ¨ System behaviour and data format ¨ Here: procedure rules and message format n Non-functional or quality requirements ¨ e. g. reliability, performance n Design constraints ¨ environment, interfaces

Amr Talaat Requirements documents n Requirements definition ¨ abstract description of the system’s services

Amr Talaat Requirements documents n Requirements definition ¨ abstract description of the system’s services and functions (external behaviour) ¨ mostly written in natural language ¨ for developers and users n Requirements specification ¨ precise description of the system’s functions ¨ may be written in a formal language

Amr Talaat Requirement documents Contents of a Software Requirements Specification (SRS) (according to IEEE

Amr Talaat Requirement documents Contents of a Software Requirements Specification (SRS) (according to IEEE Standard 830 -1998) n n n Introduction (Purpose, Scope, Acronyms, References, Outline) General Description (Context, Functions, Constraints, Assumptions) Specific Requirements ¨ ¨ ¨ n External Interface Requirements Functional Requirements Performance Requirements Design Constraints Quality Requirements Other Requirements Appendices

Amr Talaat Characteristics of Requirements should be. . . n n n n correct

Amr Talaat Characteristics of Requirements should be. . . n n n n correct (developer’s understanding = stakeholder’s needs) consistent (no conflicting goals) unambiguous (formal specification) complete (no under-specification) relevant, design-independent (no over-specification) feasible (possibility to meet all requirements) verifiable/testable (quantifiable statements) traceable (references to the specification)

Amr Talaat Requirements validation n n In general: checking that the specification matches the

Amr Talaat Requirements validation n n In general: checking that the specification matches the user’s requirements Ambiguity - Natural language or formal notation? ¨ easily understandable vs. precise and unambiguous n Making requirements consistent ¨ Resolving conflicts, e. g. prioritization into essential, desirable and optional goals (quality requirements)

Amr Talaat Requirements validation n Testability: Requirements should be quantified (holds also for the

Amr Talaat Requirements validation n Testability: Requirements should be quantified (holds also for the specification) ¨ the server is expected to respond immediately n better: the server has to respond within 5 ms. ¨ the packet is dropped after some unsuccessful retries n better: the packet is dropped after 3 unsuccessful retries. Each retry is triggered after a timeout of 2 x RTT.

Amr Talaat Validation and Verification Requirements Validation Design specification and validation Verification Abstract model

Amr Talaat Validation and Verification Requirements Validation Design specification and validation Verification Abstract model Implementation Implemented software Test and evaluation Deployment and maintenance

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n The following complaint was

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n The following complaint was received by the Pontiac Division of General Motors: Dear Sir; 'This is the second time I have written to you, and I don't blame you for not answering me, because I sounded crazy, but it is a fact that we have a tradition in our family of Ice-Cream for dessert after dinner each night, but the kind of ice cream varies so, every night, after we've eaten, the whole family votes on which kind of ice cream we should have and I drive down to the store to get it. It's also a fact that I recently purchased a new Pontiac and since then my trips to the store have created a problem. You see, every time I buy a vanilla ice-cream, when I start back from the store my car won't start. If I get any other kind of ice cream, the car starts just fine. I want you to know I'm serious about this question, no matter how silly it sounds "What is there about a Pontiac that makes it not start when I get vanilla ice cream, and easy to start whenever I get any other kind? "

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n The Pontiac President was

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n The Pontiac President was understandably skeptical about the letter, but sent an Engineer to check it out anyway. n The Engineer did the following: ¨ Arranged to meet the man just after dinner time, so the two hopped into the car and drove to the ice cream store. It was vanilla ice cream that night and, sure enough, after they came back to the car, it wouldn't start. ¨ The Engineer returned for three more nights. (Give enough time to know the system) n The first night, they got chocolate. The car started. The second night, he got strawberry. The car started. n The third night he ordered vanilla. The car failed to start. n

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n Now the engineer, using

Amr Talaat Modeling: My Car Hates Vanilla Ice Cream n Now the engineer, using logic, arranged to continue his visits for as long as it took to solve the problem. And toward this end he began to take notes: (Note All system Behavior) ¨ He jotted down all sorts of data: time of day, type of gas uses, time to drive back and forth etc. ¨ In a short time, he had a clue: n n the man took less time to buy vanilla than any other flavor. The answer was in the layout of the store. Vanilla, being the most popular flavor, was in a separate case at the front of the store for quick pickup. All the other flavors were kept in the back of the store at a different counter where it took considerably longer to check out the flavor. We see the problem, as we MODEL it

Amr Talaat From Requirements to the Design n Requirements analysis leads to a specification

Amr Talaat From Requirements to the Design n Requirements analysis leads to a specification n Specification states which requirements should be fulfilled ¨ Modeling languages and tools are used to validate specifications. Formal notation and languages: ¨ State machines (today) ¨ Unified Modeling Language (UML), e. g. ¨ n n UML state charts UML protocol state machines UML sequence charts UML use case diagrams Specification and Description Language (SDL) [ITU-T Z. 100] ¨ Message Sequence Charts [ITU-T Z. 120] ¨

Amr Talaat FSM Overview n n Finite State Machine is a tool to model

Amr Talaat FSM Overview n n Finite State Machine is a tool to model the desired behavior of a sequential system. The designer has to develop a finite state model of the system behavior and then designs a circuit that implements this model A FSM consists of several states. Inputs into the machine are combined with the current state of the machine to determine the new state or next state of the machine. Depending on the state of the machine, outputs are generated based on either the state or the state and inputs of the machine.

Amr Talaat FSMs States Current State: State which determines the current behavior of the

Amr Talaat FSMs States Current State: State which determines the current behavior of the machine n Next State: State which machine will have after processing an input event. Next State can be the same as current state n Start State: State in which machine will be when created (power on) n End State: State in which no transition rule is executable n

Amr Talaat Transitions Triggered by input events the FSM moves from one state to

Amr Talaat Transitions Triggered by input events the FSM moves from one state to other based on the Transition Function n Transition Function produces the Output and Next State depending on Current State and Input Event n While in particular state FSM is not active, it is waiting for an input to perform next activity n

Amr Talaat State Transition Diagrams n n Used to visually represent an FSM Emphasis

Amr Talaat State Transition Diagrams n n Used to visually represent an FSM Emphasis is on identifying states and possible transitions Transitio ¨ Circles represent States ns ¨ Arrows represent Transitions 01/11 Initial State Input/Outp ut State S 0 S 1 01/01 11/10 S 3 1 -/11 01/10 S 2 011/00

Amr Talaat Finite State Machines (FSMs) n Finite state machines consist of: ¨ States

Amr Talaat Finite State Machines (FSMs) n Finite state machines consist of: ¨ States ¨ Input Events (or Signals, or Messages) ¨ Transition Functions ¨ Output Events States Input Events Transition Functions Output Events

Amr Talaat Kiss 2 Format n n STG and Tables are only ways to

Amr Talaat Kiss 2 Format n n STG and Tables are only ways to represent FSMs Other techniques are available, Example: Keep it simple stupid trails. kiss 2. i 2. o 1. p 11. s 4 -0 st 0 11 st 3 ………. 0 0

Amr Talaat FSM Example Ø General Machine Description: Ø deliver package of gum after

Amr Talaat FSM Example Ø General Machine Description: Ø deliver package of gum after 15 cents deposited Ø single coin slot for dimes, nickels Ø no change

Amr Talaat Vending Machine Example Reset 0¢ N 5¢ N 10¢ D N, D

Amr Talaat Vending Machine Example Reset 0¢ N 5¢ N 10¢ D N, D 15¢ [open] D

Amr Talaat Mealy FSM n Output is dependent on the inputs and the current

Amr Talaat Mealy FSM n Output is dependent on the inputs and the current state transition condition 1 /output 1 state 2 transition condition 2 /output 2

Amr Talaat Moore FSM n Output is dependent only on the current state transition

Amr Talaat Moore FSM n Output is dependent only on the current state transition condition 1 state 1 / output 1 transition condition 2 state 2 / output 2

Amr Talaat Moore vs. Mealy FSM n n Moore and Mealy FSMs can be

Amr Talaat Moore vs. Mealy FSM n n Moore and Mealy FSMs can be functionally equivalent ¨ Equivalent Mealy FSM can be derived from Moore FSM and vice versa Mealy FSM Has Richer Description and usually requires smaller number of states ¨ Smaller circuit area Mealy FSM computes Outputs as soon as Inputs change ¨ Mealy FSM responds one clock cycle sooner than equivalent Moore FSM has no combinational path between Inputs and Outputs ¨ Moore FSM is more likely to have a shorter critical path

Amr Talaat Mealy FSM - Example n Mealy FSM that Recognizes Sequence “ 10”

Amr Talaat Mealy FSM - Example n Mealy FSM that Recognizes Sequence “ 10” 0 / 0 1 / 0 S 1 0 / 1 Meaning of states: Ø S 0: No elements of the sequence observed Ø S 1: “ 1” observed

Amr Talaat Moore FSM - Example n Moore FSM that Recognizes Sequence “ 10”

Amr Talaat Moore FSM - Example n Moore FSM that Recognizes Sequence “ 10” 0 1 S 0 / 0 reset 1 0 S 1 / 0 1 S 2 / 1 0 Meaning of states: Ø S 0: No elements of the sequence observed Ø S 1: “ 1” observed Ø S 2: “ 0” observed

Amr Talaat Formal definition n An FSM is a 6 -tuple F<S, I, O,

Amr Talaat Formal definition n An FSM is a 6 -tuple F<S, I, O, F, H, s 0> ¨ ¨ ¨ n n S is a set of all states {s 0, s 1, …, sl} I is a set of inputs {i 0, i 1, …, im} O is a set of outputs {o 0, o 1, …, on} F is a next-state function (S x I → S) H is an output function (S → O) s 0 is an initial state Moore-type: Associates outputs with states (as given above, H maps S → O) Mealy-type: Associates outputs with transitions (H maps S x I → O)

Amr Talaat Categories of Finite State Machines n Complete FSM (CFSM) ¨ Completely specified

Amr Talaat Categories of Finite State Machines n Complete FSM (CFSM) ¨ Completely specified finite state machine ¨ Specification domain is on the whole space n Partial FSM (PFSM) ¨ Partially specified finite state machine ¨ Specification domain is part of the whole space n Implementations are usually modeled by CFSM, while specifications could be CFSM or PFSM

Amr Talaat Modeling of Complex Systems n n Typical telecomm system is too complex

Amr Talaat Modeling of Complex Systems n n Typical telecomm system is too complex to be represented with a single FSM. As usually when dealing with complexity we should split a complex problem into a number of smaller components In this case we will have number of concurrent FSMs communicating with each other. Communicating FSM can be ¨ In a single process (task, thread of control) ¨ In separate concurrent processes on same microprocessor ¨ On separate microprocessors communicating to each other Depending on how FSMs are co-located, different methods of communications are possible The two communication mechanisms for concurrent processes can be categorized into Message Passing and Shared Data

Amr Talaat Models of communication § Shared memory Comp-1 memory Comp-2 Variables accessible to

Amr Talaat Models of communication § Shared memory Comp-1 memory Comp-2 Variables accessible to several tasks. Model is useful only for local systems.

Amr Talaat Shared memory n Potential race conditions ( inconsistent results possible) Critical sections

Amr Talaat Shared memory n Potential race conditions ( inconsistent results possible) Critical sections = sections at which exclusive access to resource r (e. g. shared memory) must be guaranteed. process a {. . P(S) //obtain lock. . // critical section V(S) //release lock } process b {. . P(S) //obtain lock. . // critical section V(S) //release lock } This model may be supported by: § mutual exclusion for critical sections § cache coherency protocols Race-free access to shared memory protected by S possible

Amr Talaat Non-blocking/asynchronous message passing n Sender does not have to wait until message

Amr Talaat Non-blocking/asynchronous message passing n Sender does not have to wait until message has arrived; potential problem: buffer overflow … send () … … receive () …

Amr Talaat Blocking/synchronous message passing rendez-vous n Sender will wait until receiver has received

Amr Talaat Blocking/synchronous message passing rendez-vous n Sender will wait until receiver has received message … send () … … receive () …

Amr Talaat Extended rendez-vous Explicit acknowledge from receiver required. Receiver can do checking before

Amr Talaat Extended rendez-vous Explicit acknowledge from receiver required. Receiver can do checking before sending acknowledgement. … send () … … receive () … ack …

Amr Talaat Asynchronous & Synchronous Communications n n Two approaches to implement message passing

Amr Talaat Asynchronous & Synchronous Communications n n Two approaches to implement message passing Synchronous Communication The processes involved in communication are required to participate at the point of communication simultaneously ¨ If Process A attempts to send a message and Process B is not ready to receive it, Process A must wait until Process B is ready ¨ n Asynchronous Communication The processes involved in communication are not required to participate at the point of communication simultaneously ¨ If Process A attempts to send a message and Process B is not ready to receive it, Process A sends it anyway ¨

Amr Talaat Asynchronous Communication using FIFOs n n n Asynchronous communication requires use of

Amr Talaat Asynchronous Communication using FIFOs n n n Asynchronous communication requires use of buffers to store messages The protocol specification methods studied in this course will be mostly based upon Asynchronous Communication In most communicating systems, a FIFO (First In First Out) discipline is enforced on sending and receiving messages During a send event the message is appended to the end of the queue while a receive event removes a message from the front It is possible to modify the communications channel to provide additional communication constructs such as priority signals

Amr Talaat Clayton Tunnel (CFSM Example) train in tunnel Is Train Out? Stop Worker

Amr Talaat Clayton Tunnel (CFSM Example) train in tunnel Is Train Out? Stop Worker A Train 1 Worker B tunnel is clear

Amr Talaat Communicating FSMs Model n n n Protocol is described as a set

Amr Talaat Communicating FSMs Model n n n Protocol is described as a set of Communicating FSMs (CFSMs) Each CFSM represents a component (or process) of the network ¨ In OSI term, a protocol entity, e. g. sender, receiver Each process can be defined by a set of states ¨ The process waits in a state for an event to occur ¨ Messages are received as events by the receiving FSM ¨ When this input event occurs, it transfers to another state, and in doing so can send out messages and performs other tasks Each CFSM is represented by a directed labeled graph where ¨ Nodes represent states (conditions) of the process ¨ Edges represent transitions (events) of the process This model is the model used by the ITU Specification and Description Language (SDL)

Amr Talaat Communicating FSMs Model Sender Receiver 01/01 S 0 01/11 00/10 S 1

Amr Talaat Communicating FSMs Model Sender Receiver 01/01 S 0 01/11 00/10 S 1 process

Amr Talaat Protocol 1: get the time from a stranger n n n Specification:

Amr Talaat Protocol 1: get the time from a stranger n n n Specification: Implement a protocol that obtains the time from a stranger when needed Constraints: you have to be polite: a stranger will not respond unless you precede any question by a polite exchange of “hi's”, and thank the stranger in the end To Draw an FSM we need to Identify: Types of messages ¨ States for both sender and receiver ¨ Transitions between these states ¨

Amr Talaat Example on timeline

Amr Talaat Example on timeline

Amr Talaat client FSM for get_time()

Amr Talaat client FSM for get_time()

Amr Talaat client FSM for get_time() Above (What is time? ) Idle + BYE

Amr Talaat client FSM for get_time() Above (What is time? ) Idle + BYE State 1 State 2 + Hi State 6 State 5 Thanks Bye - Hi + 12: 30 State 4 - What is Time? State 3

Amr Talaat Server FSM for give_time()

Amr Talaat Server FSM for give_time()

Amr Talaat Server FSM for give_time() +Hi Idle State 1 - Hi + What

Amr Talaat Server FSM for give_time() +Hi Idle State 1 - Hi + What is Time? - BYE +Thanks Bye State 5 State 2 State 4 - 12: 30 State 3

Amr Talaat System MSC

Amr Talaat System MSC

Amr Talaat Example 2: Distributed Traffic Light n Specification: We need to control the

Amr Talaat Example 2: Distributed Traffic Light n Specification: We need to control the traffic lights at a four-way intersection ¨ Each direction is equipped with a traffic light and a detector for cars waiting; this is controlled by a computer (Cl_n) ¨ The four clients are connected to a server (S) ¨ n Your task: Write a protocol to ensure that (i) when a car is waiting in front of a light, it will eventually turn green, and (ii) at any given time, only one light is green

Amr Talaat Protocol 2: Server FSM for Intersection

Amr Talaat Protocol 2: Server FSM for Intersection

Amr Talaat Protocol 2: client FSM for intersection

Amr Talaat Protocol 2: client FSM for intersection

Amr Talaat Blocked Client

Amr Talaat Blocked Client

Amr Talaat Client: No Blocking

Amr Talaat Client: No Blocking

Amr Talaat Starvation

Amr Talaat Starvation

Amr Talaat Server: No Blocking/No Starvation

Amr Talaat Server: No Blocking/No Starvation

Amr Talaat Client No Blocking/No Starvation

Amr Talaat Client No Blocking/No Starvation

Amr Talaat Lessons n n Protocols are hard to get right! Combinatorial explosion of

Amr Talaat Lessons n n Protocols are hard to get right! Combinatorial explosion of execution paths – or: “so many things can happen!” How to be sure it's ALWAYS right? How to analyze what a protocol does? Finite State Machines: ¨ Natural “language” to specify and analyze protocols ¨ Mathematical theory and software tools ¨ Check properties such as no deadlock, starvation, etc.

Amr Talaat FSMs - Summary n n Discrete event processes and finite state machines

Amr Talaat FSMs - Summary n n Discrete event processes and finite state machines are key concepts in modeling the dynamic real-time behavior of telecommunications protocols. FSM consist of States (Initial, Current and New), Input Events, Output Events, Transitions In case when “state explosion” is an issue extended FSM (EFSM) may be used so some states are replaced by local variables Complex Telecommunication Systems can be modeled as number of communicating FSMs (CFSMs) Concurrent Program