CS 145A Protocols Netlab.caltech.edu/course
Misc. Extension Extension Textbooks Textbooks
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?
Project 1 Clients: Clients: Get UDP message 1~3 times get TCP message, then client disconnects get TCP message server udpclient udptest1 udpclient udptest2 udpclient udptest3 date tcpclient clienttimeout 8 date (8 seconds) tcpclient servertimeout 12 date (10 seconds)
Project 1 Server (Basic Functions): Server (Basic Functions): Server udpclient udptest1 (see "udptest1") udpclient udptest2 (see "udptest2") udpclient udptest3 (see "udptest3") date tcpclient clienttimeout 8 (see "clienttimeout") date (8) tcpclient servertimeout 12 (See "servertimeout") date (10)
Project 1 Server (Advanced Function 1, Multi-connection): Server (Advanced Function 1, Multi-connection): Login.cs: (script3) server Tcpclient logincs tcp3 8 (see “ tcp3 ” ) udpclient login.cs udp (see "udp") Local: (script3) tcpclient login.cs tcp1 8 (see “ tcp1 ” ) tcpclient login.cs tcp2 8 (get refused) udpclient login.cs udp (see "udp")
Project 1 Server (Advanced Function 2, 5-connections): Server (Advanced Function 2, 5-connections):
Project 1 Multiple Processes: One process for each active TCP connection, one UDP process and one Listening process How to tell the main process when the child processes finish the TCP connection? SIGCHILD (with a handler in the main function)
Project 1 Multiple Threads: Similar to Multiple Processes pthread_create
Project 1 Single Process: One “ select ” for UDP + TCP Listen + All the active TCP connections Timeout of the “ select ” : Check each connection in the active set returned by “ select ”
Protocol
Protocol Specification (External services and internal operations) Specification (External services and internal operations) Verification (completeness and correctness) Verification (completeness and correctness) Implementation Implementation Testing Testing
Protocol Request For Comments Reference Guide: RFC 1000 Reference Guide: RFC 1000 Keywords: RFC 2119 ( “ Must ” / ” Shall ”, “ should ”, “ may ”… ) Keywords: RFC 2119 ( “ Must ” / ” Shall ”, “ should ”, “ may ”… )
Formal Methods State Transition Graph State Transition Graph Petri Net Petri Net Process Algebra Process Algebra …
Petri-Net (By Carl Adam Petri at 1962) Structure: Place Place Transition Transition Arc Arc Dynamic element: Token Token
Petri-Net
Petri-Net
Petri-Net
Petri-Net
Petri-Net
Petri-Net
Petri-Net
Petri-Net Extensions: Weighted Arcs / Multiple Tokens Weighted Arcs / Multiple Tokens Token with different colors Token with different colors Time Petri Net Time Petri Net Random Petri Net Random Petri Net …
State Transition Graph
Basic (FSM): Possible State Set Possible State Set Possible Input Set Possible Input Set Possible Output (Action) Set* Possible Output (Action) Set* State Transition Set: State Transition Set: {(origin_state, input, output, target_state)} Initial State Set Initial State Set
State Transition Graph Extended (EFSM, etc): Variables Variables Timers Timers Non-deterministic behaviors … Non-deterministic behaviors …
+ Timer
States for TCP Connection
Modeling is a bridge.
Lab 2
Task Design a simple protocol for: Two machines talk with each other; Two machines talk with each other; Either machine is able to establish the conversation. Either machine is able to establish the conversation. During the conversation, if one machine sends some message to the other machine, the other machine displays the message on the screen. During the conversation, if one machine sends some message to the other machine, the other machine displays the message on the screen. If one machine does not want to talk any more (or dies, or is disconnected from the network), the other machine should have a way to know about that. (although maybe after some delay – the delay should be bounded.) If one machine does not want to talk any more (or dies, or is disconnected from the network), the other machine should have a way to know about that. (although maybe after some delay – the delay should be bounded.)
Lab 2 Assumptions: We can use TCP (reliable connection) We can use TCP (reliable connection) The TCP may return error when you tries to do socket operations. (not so “ reliable ” !!!) The TCP may return error when you tries to do socket operations. (not so “ reliable ” !!!)
Lab 2 Requirements: Read RFC Read RFC Use state transition graph to help you design Use state transition graph to help you design Use texts to specify the details (use the key words as defined in RFC 2119) Use texts to specify the details (use the key words as defined in RFC 2119) Think about different scenarios to test your design Think about different scenarios to test your design
Lab 2 Grading: Correctness and Completeness (80%) Correctness and Completeness (80%) Feasibility (20%) Feasibility (20%) Due: Nov Submission: As homework submission.