Project 4: Reliable Networking
Slide heritage: Previous TAs
Project 4: Reliable Networking Slide heritage: Previous TAs - - PowerPoint PPT Presentation
Project 4: Reliable Networking Slide heritage: Previous TAs Announcements Project 4 has been released I assume youve read the project description Due Friday, April 14th This is a pretty complex project Startearly!
Slide heritage: Previous TAs
UDP TCP Internet Protocol Ethernet (or similar) Host OS UDP Stack network.h minimsg minisocket Transport Layer Network Layer Link Layer
TCP/IP Stack PortOS Network Stack
○ You must find a way to establish a connection between two endpoints
○ Messages are an application level concept ○ Minisocket must maintain correct ordering
○ You must fragment and reassemble the data
Listening Connecting Fail
connection failed minisocket_client_create minisocket_server_create
Connected
received connection connection accepted
Sending
message sent minisocket_send
Receiving
minisocket_receive message received either side calls minisocket_close
Closed
doesn’t reply Other party sends FIN
TCP State Machine Source: Wikipedia/Cube00 License: CC BY-SA 3.0
Welcome to the fun world of distributed systems!
Client Server
MSG_SYN MSG_SYNACK MSG_ACK Non-blocking protocol
Initial Timeout: 100ms * Give up after 12.7s
Client Server
MSG_SYNACK MSG_ACK Lost MSG_SYN MSG_SYN
Timeout
Client Server
MSG_SYN
Timeout
MSG_SYNACK MSG_ACK MSG_SYNACK Lost Note: In this case both parties might retransmit
Client Server
MSG_ACK MSG_SYN
Timeout
MSG_SYNACK Lost MSG_ACK MSG_SYNACK
Server
MSG_SYNACK MSG_ACK Lost Lost
Client
MSG_SYN
Timeout
MSG_SYN MSG_SYN
Timeout
Sender Receiver
MSG_ACK with ack_number=34 MSG_ACK with seq_number=34 and“hodor” seq_number represents how many packets have been sent ⇨ is used to order messages ack_number shows total received packets ⇨ is used to resend lost messages Note: This is a symmetric channel. Both parties can send and receive.
Sender Receiver
seq_number=34 with“hodor” Lost ack_number=34
Timeout
seq_number=34 with“hodor”
Sender Receiver
seq_number=34 with“hodor” ack_number=34
Timeout
Lost seq_number=34 with“hodor” ack_number=34
Participant 1 Participant 2
seq=34,ack=12 with“hodor” seq=12,ack=34 seq=13,ack=34 with“arya” seq=34,ack=13
Client Server
MSG_FIN MSG_ACK Again, this is a symmetric protocol. Both sides can close the connection.
Bytes 1 2 3 4 5 6 7 8 16 24
source_port destination_port source_address protocol destination_address
type
seq_number ack_number
The first 21 bytes are identical to minimsg_header! Use protocol field to multiplex protocols.
Remember that:
Things you must avoid:
Waiting Setup alarm & Put thread on wait queue for port Alarm Fires Remove thread from port’s wait queue & wake up thread Deregister alarm & wake up thread ACK received
But you can implement window sizes > 1 if you want to! (and have the time…)
In network.c: double loss_rate = 0.0; double duplication_rate = 0.0; bool synthetic_network = false;
These change the behavior of the network You have to set this to true for the other values to have any effect!
Your project has been merged with the latest
nothing is missing New files: minisocket, conn-network[1-3]
As always, if you need help, come to office hours