CS 145A Protocols . Misc. Extension Extension Textbooks Textbooks.

34
CS 145A CS 145A Protocols Protocols Netlab.caltech.edu/course Netlab.caltech.edu/course

description

Project 1 Q&A: Can the tcp client send two packets instead of one? Can the tcp client send two packets instead of one? What happens if the udp client cannot receive my message? What happens if the udp client cannot receive my message? Shall I receive and print the message on the client side? Shall I receive and print the message on the client side? How do you grade my work? How do you grade my work?

Transcript of CS 145A Protocols . Misc. Extension Extension Textbooks Textbooks.

Page 1: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

CS 145ACS 145AProtocolsProtocols

Netlab.caltech.edu/courseNetlab.caltech.edu/course

Page 2: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Misc.Misc. ExtensionExtension TextbooksTextbooks

Page 3: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project Project 11Q&A:Q&A: Can the tcp client send two packets insCan the tcp client send two packets instead of one?tead of one? What happens if the udp client cannot What happens if the udp client cannot receive my message?receive my message? Shall I receive and print the message oShall I receive and print the message on the client side?n the client side? How do you grade my work?How do you grade my work?

Page 4: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1 Clients:Clients:

Reference Server:l ocal host

Cl i ent Under Test:Local Host

Get UDP message 1~3 timesget TCP message, then client disconnectsget TCP message

<script1>server <port> <port>udpclient 127.0.0.1 <port> udptest1udpclient 127.0.0.1 <port> udptest2udpclient 127.0.0.1 <port> udptest3datetcpclient 127.0.0.1 <port> clienttimeout 8date (8 seconds)tcpclient 127.0.0.1 <port> servertimeout 12 date (10 seconds)

Page 5: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1 Server (Basic Functions):Server (Basic Functions):

Reference Cl i ent:l ocal host

Server Under Test:Local Host

<script2>Server <port> <port>udpclient 127.0.0.1 <port> udptest1 (see "udptest1")udpclient 127.0.0.1 <port> udptest2(see "udptest2")udpclient 127.0.0.1 <port> udptest3(see "udptest3")datetcpclient 127.0.0.1 <port> clienttimeout 8(see "clienttimeout")date (8)tcpclient 127.0.0.1 <port> servertimeout 12 (See "servertimeout")date (10)

Page 6: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1 Server (Advanced Function 1, Multi-Server (Advanced Function 1, Multi-

connection):connection):

Reference Cl i ent1:l ocal host

Server Under Test:l ogi n. cs

Reference Cl i ent2:l ocal host

Reference Cl i ent3:l ogi n. cs

Login.cs: (script3)server <port> <port>Tcpclient logincs <port> tcp3 8(see “tcp3”)udpclient login.cs <port> udp(see "udp")Local: (script3)tcpclient login.cs <port> tcp1 8(see “tcp1”)tcpclient login.cs <port> tcp2 8(get refused)udpclient login.cs <port> udp(see "udp")

Page 7: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1 Server (Advanced Function 2, 5-connections):Server (Advanced Function 2, 5-connections):

l ocal host

Server Under Test :l ogi n. cs

f ast1. cs

i ts. cal tech

fast2. cs

wei xl . cs

l ogi n. cs

Page 8: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1Multiple Processes:Multiple Processes: One process for each active TCP One process for each active TCP

connection, one UDP process and one connection, one UDP process and one Listening processListening process

How to tell the main process when the How to tell the main process when the child processes finish the TCP child processes finish the TCP connection?connection?

SIGCHILD (with a handler in the main SIGCHILD (with a handler in the main function)function)

Page 9: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1Multiple Threads:Multiple Threads: Similar to Multiple ProcessesSimilar to Multiple Processes pthread_createpthread_create

Page 10: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Project 1Project 1Single Process:Single Process: One “select” for UDP + TCP Listen One “select” for UDP + TCP Listen

+ All the active TCP connections+ All the active TCP connections Timeout of the “select”: Timeout of the “select”:

Check each connection in the active Check each connection in the active set returned by “select”set returned by “select”

},10][{min

eCurrentTimiTimeLastActiveectionActiveConni

Page 11: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

ProtocolProtocol

Page 12: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

ProtocolProtocol Specification (External services and Specification (External services and

internal operations)internal operations) Verification (completeness and Verification (completeness and

correctness)correctness) Implementation Implementation Testing Testing

Page 13: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

ProtocolProtocolRequest For CommentsRequest For Comments http://http://www.ietf.org/rfcwww.ietf.org/rfc Reference Guide: RFC 1000Reference Guide: RFC 1000 Keywords: RFC 2119 (“Must”/”ShalKeywords: RFC 2119 (“Must”/”Shall”, “should”, “may”…)l”, “should”, “may”…)

Page 14: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Formal MethodsFormal Methods State Transition GraphState Transition Graph Petri NetPetri Net Process AlgebraProcess Algebra ……

Page 15: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net(By Carl Adam Petri at 1962)(By Carl Adam Petri at 1962)Structure:Structure: PlacePlace TransitionTransition ArcArcDynamic element:Dynamic element: TokenToken

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 16: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 17: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 18: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 19: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 20: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 21: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 22: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-Net

Client Request

Connection onServer

ListeningServer

Data Sent byClient

Disconnectionby Client

Page 23: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Petri-NetPetri-NetExtensions:Extensions:• Weighted Arcs / Multiple TokensWeighted Arcs / Multiple Tokens• Token with different colorsToken with different colors• Time Petri NetTime Petri Net• Random Petri NetRandom Petri Net• ……

Page 24: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

State Transition GraphState Transition Graph

I nitialConnectionList

={}

Listen

Start/

UDPCommunication UDP got msg/

/ read msg and reply

I ncoming Sock: i /

TCPConnection

TCPCommunication

Sock i is activated/

Something to read/Read sock i and reply

/ ConnectionList=ConnectionList+{i}

Client Disconnect/ConnectionList

=connectionList-{i}

Page 25: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

State Transition GraphState Transition GraphBasic (FSM):Basic (FSM): Possible State SetPossible State Set Possible Input SetPossible Input Set Possible Output (Action) Set*Possible Output (Action) Set* State Transition Set: State Transition Set: {(origin_state, input, output, target_stat{(origin_state, input, output, target_state)}e)} Initial State SetInitial State Set

I nitialConnectionList

={}

Listen

UDPCommunication

TCPConnection

TCPCommunication

Something to read/Read sock i and reply

/ ConnectionList=ConnectionList+{i}

Page 26: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

State Transition GraphState Transition GraphExtended (EFSM, etc):Extended (EFSM, etc): VariablesVariables TimersTimers Non-deterministic behaviors…Non-deterministic behaviors…

Page 27: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

+ Timer+ Timer

I nitialConnectionList

={}

Listen

Start/

UDPCommunication UDP got msg//

read msg and reply

I ncoming Sock: i/

TCPConnection

TCPCommunication

TI MEOUT of i/

Something to read/

Read sock i andreply

/ConnectionList=ConnectionList+{i}

Client Disconnect/

ConnectionList=connectionList-{i}

ConnectonTimeout

/ ConnectionList

=connectionList-{i}

Sock i is activated/

Page 28: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

States for TCP States for TCP ConnectionConnection

Page 29: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Modeling is a Modeling is a bridge.bridge.

Page 30: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Lab 2Lab 2

Page 31: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

TaskTaskDesign a simple protocol for:Design a simple protocol for: Two machines talk with each other;Two machines talk with each other; Either machine is able to establish the Either machine is able to establish the

conversation. conversation. During the conversation, if one machine sends During the conversation, if one machine sends

some message to the other machine, the other some message to the other machine, the other machine displays the message on the screen. machine displays the message on the screen.

If one machine does not want to talk any more If one machine does not want to talk any more (or dies, or is disconnected from the network), (or dies, or is disconnected from the network), the other machine should have a way to know the other machine should have a way to know about that. (although maybe after some delay about that. (although maybe after some delay – the delay should be bounded.)– the delay should be bounded.)

Page 32: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Lab 2Lab 2Assumptions:Assumptions: We can use TCP (reliable We can use TCP (reliable

connection)connection) The TCP may return error when you The TCP may return error when you

tries to do socket operations. (not so tries to do socket operations. (not so “reliable”!!!)“reliable”!!!)

Page 33: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Lab 2Lab 2Requirements:Requirements: Read RFC 2119.Read RFC 2119. Use state transition graph to help you Use state transition graph to help you

designdesign Use texts to specify the details (use Use texts to specify the details (use

the key words as defined in RFC 2119)the key words as defined in RFC 2119) Think about different scenarios to test Think about different scenarios to test

your designyour design

Page 34: CS 145A Protocols  . Misc. Extension Extension Textbooks Textbooks.

Lab 2Lab 2Grading:Grading: Correctness and Completeness Correctness and Completeness

(80%)(80%) Feasibility (20%)Feasibility (20%)

Due: Due: Nov.1Nov.1 2002 2002Submission: As homework submission.Submission: As homework submission.