![Page 1: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/1.jpg)
Lab 2: Admin details
• Lab 2 is out!
• Due: o November 4th, 12 noon
o November 6th, 12 noon (90% cap)
• Assignment and starter code online
• Start early!On average, took students 14 hours to complete Lab 2 last
year
![Page 2: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/2.jpg)
Functionality
![Page 3: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/3.jpg)
Functionality
Write an application that:
• Takes in data from one host
![Page 4: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/4.jpg)
Functionality
Write an application that:
• Takes in data from one host
• Turns those data into packets
![Page 5: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/5.jpg)
Functionality
Write an application that:
• Takes in data from one host
• Turns those data into packets
• Transmits those packets reliably and in-order to the other host
![Page 6: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/6.jpg)
Example
![Page 7: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/7.jpg)
Beware the appearance of simplicity
![Page 8: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/8.jpg)
Why the Internet isn't just "tubes"
• A packet can be corrupted
• A packet can be delayed
• A packet can be dropped
• A packet can be duplicated
![Page 9: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/9.jpg)
corrupted delayed dropped duplicated
![Page 10: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/10.jpg)
corrupted delayed dropped duplicated
Please transfer $100 from my bank account to Phil's
![Page 11: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/11.jpg)
corrupted delayed dropped duplicated
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
![Page 12: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/12.jpg)
corrupted delayed dropped duplicated
![Page 13: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/13.jpg)
corrupted delayed dropped duplicated
Please deposit $100 into my account
Please transfer $100 from my bank account to Phil's
![Page 14: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/14.jpg)
corrupted delayed dropped duplicated
Please deposit $100 into my account
Please transfer $100 from my bank account to Phil's
Please deposit $100 into my account
Please transfer $100 from my bank account to Phil's
![Page 15: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/15.jpg)
corrupted delayed dropped duplicated
![Page 16: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/16.jpg)
corrupted delayed dropped duplicated
Please transfer $100 from my bank account to Phil's
![Page 17: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/17.jpg)
corrupted delayed dropped duplicated
Please transfer $100 from my bank account to Phil's
![Page 18: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/18.jpg)
corrupted delayed dropped duplicated
![Page 19: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/19.jpg)
corrupted delayed dropped duplicated
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
![Page 20: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/20.jpg)
Tools for ordered, reliable streams
• Checksums
• Sequence numbers
• Acknowledgments
• Timeouts
![Page 21: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/21.jpg)
cksums seq nos acks timeouts
![Page 22: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/22.jpg)
cksums seq nos acks timeouts
Hash:
cksum(data) integer
![Page 23: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/23.jpg)
cksums seq nos acks timeouts
Hash:
cksum(data) integer
cksum("a") 1
![Page 24: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/24.jpg)
cksums seq nos acks timeouts
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
![Page 25: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/25.jpg)
cksums seq nos acks timeouts
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
Tag packet with checksum before sending
![Page 26: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/26.jpg)
cksums seq nos acks timeouts
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
Tag packet with checksum before sending
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
cksum("Please ...") cksum("Please ...")
![Page 27: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/27.jpg)
cksums seq nos acks timeouts
Note:
cksum("Please transfer ... $100 ...")
cksum("Please transfer ... $14837135 ...")
![Page 28: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/28.jpg)
cksums seq nos acks timeouts
Note:
cksum("Please transfer ... $100 ...")
cksum("Please transfer ... $14837135 ...")
Please transfer $100 from my bank account to Phil's
Please transfer $14837135 from my bank account to Phil's
cksum("Please ...") cksum("Please ...")
![Page 29: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/29.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
![Page 30: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/30.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
![Page 31: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/31.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Seq no: 152 Seq no: 152
Seq no: 152
![Page 32: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/32.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Seq no: 152 Seq no: 152
Seq no: 152
![Page 33: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/33.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Seq no: 152 Seq no: 152
Seq no: 152
![Page 34: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/34.jpg)
cksums seq nos acks timeouts
Monotonically increasing number appended to packet
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Please transfer $100 from my bank account to Phil's
Seq no: 152 Seq no: 152
Seq no: 152Sender: Last sequence number sent (and last sequence number ack-d)
Receiver: Last sequence number received
![Page 35: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/35.jpg)
cksums seq nos acks timeouts
Receiver acknowledges received packets
If sender does not receive ack, retransmits
![Page 36: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/36.jpg)
cksums seq nos acks timeouts
Receiver acknowledges received packets
If sender does not receive ack, retransmits
Please transfer $100 from my bank account to Phil's
Seq no: 152
![Page 37: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/37.jpg)
cksums seq nos acks timeouts
Receiver acknowledges received packets
If sender does not receive ack, retransmits
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
![Page 38: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/38.jpg)
cksums seq nos acks timeouts
Receiver acknowledges received packets
If sender does not receive ack, retransmits
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
Ack no: 153
![Page 39: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/39.jpg)
Duplicate
Corrupt
Delay
Drop
Checksums
Sequence numbers
Acknowledgments
Timeouts
![Page 40: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/40.jpg)
Stop and wait
If you have a Sender and a Receiver:
• Sender sends a data message.
• Sender waits until receiver acknowledges receptiono If Sender receives ack, sends its next available
packeto If Sender does not receive ack, the Sender re-
transmits the data that had not been acknowledged
![Page 41: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/41.jpg)
Beware the appearance of simplicity
![Page 42: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/42.jpg)
Difficulties
• Conceptual
• The "little" things
![Page 43: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/43.jpg)
Conceptual: Event-based code
![Page 44: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/44.jpg)
Conceptual: Event-based code
• What are the events?
• What parts of code map to events?
• How to respond to events?
• How track state in? When transition between states?
![Page 45: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/45.jpg)
Events
• Receive data packet
• Receive ack packet
• Input goes from empty to having data
• Output goes from full to having room
• Timer expires
• Create a new connection
------
• Receive shutdown from opposite end
• Receive shutdown from input
![Page 46: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/46.jpg)
Conceptual: Event-based code
• What are the events?
• What parts of code map to events?
• How to respond to events?
• How track state in? When transition between states?
![Page 47: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/47.jpg)
Events
• Create a new connection
rel_create
• Receive data packet
• Receive ack packet
rel_recvpkt
• Input goes from empty to having data
rel_read
• Output goes from full to having room
rel_output
• Timer expires
rel_timer
![Page 48: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/48.jpg)
Conceptual: Event-based code
• What are the events?
• What parts of code map to events?
• How to respond to events?
• How track state in? When transition between states?
![Page 49: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/49.jpg)
Events
• Create a new connection
rel_create
• Receive data packet
• Receive ack packet
rel_recvpkt
• Input goes from empty to having data
rel_read
• Output goes from full to having room
rel_output
• Timer expires
rel_timer
![Page 50: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/50.jpg)
Timer expires
![Page 51: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/51.jpg)
cksums seq nos acks timeouts
Receiver acknowledges received packets
If sender does not receive ack, retransmits
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
Please transfer $100 from my bank account to Phil's
Seq no: 152
![Page 52: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/52.jpg)
Timer expires
Timer expiration maps to retransmits
When do we retransmit?
![Page 53: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/53.jpg)
Timer expires
Timer expiration maps to retransmits
When do we retransmit?
• Have unack-ed packet outstanding
• We sent unack-ed packet > TIMEOUT ago
![Page 54: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/54.jpg)
Receive data packet
![Page 55: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/55.jpg)
Receive data packet
• Sanity checks
![Page 56: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/56.jpg)
Receive data packet
• Sanity checkso Does its checksum match?o Are you expecting the sequence number?o Is it the right length?o Has the other end already closed its output stream?
![Page 57: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/57.jpg)
Receive data packet
• Sanity checkso Does its checksum match?o Are you expecting the sequence number?o Is it the right length?o Has the other end already closed its output stream?
• Action takeno Should you send ack?o Should you pass payload to output?
![Page 58: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/58.jpg)
Receive data packet
• Sanity checkso Does its checksum match?o Are you expecting the sequence number?o Is it the right length?o Has the other end already closed its output stream?
• Action takeno Should you send ack?o Should you pass payload to output?
![Page 59: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/59.jpg)
Conceptual: Event-based code
• What are the events?
• What parts of code map to events?
• How to respond to events?
• How track state in? When transition between states?
![Page 60: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/60.jpg)
Ticky-tacky bugs
Computing checksum
htons/htonl/ntohs/ntohlstrcpy
![Page 61: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/61.jpg)
Receive data packet
• Sanity checkso Does its checksum match?o Are you expecting the sequence number?o Is it the right length?o Has the other end already closed its output stream?
• Action takeno Should you send ack?o Should you pass payload to output?
![Page 62: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/62.jpg)
cksum
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno; /* Only valid if length > 8 */
char data[500];
};
typedef struct packet packet_t;
![Page 63: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/63.jpg)
cksum
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno; /* Only valid if length > 8 */
char data[500];
};
typedef struct packet packet_t;
Provided a cksum function in code:
uint16 cksum(const void* data, int len)
![Page 64: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/64.jpg)
cksum
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno;
char data[500];
};
typedef struct packet packet_t;
Provided a cksum function in code:
uint16 cksum(const void* data, int len)
![Page 65: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/65.jpg)
cksum
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno;
char data[500];
};
typedef struct packet packet_t;
Provided a cksum function in code:
uint16 cksum(const void* data, int len)
How do you know what to fill in for cksum field before performing the cksum?
![Page 66: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/66.jpg)
cksum
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno;
char data[500];
};
typedef struct packet packet_t;
Provided a cksum function in code:
uint16 cksum(const void* data, int len)
How do you know what to fill in for cksum field before performing the cksum?
Zero cksum field before performing cksum on packet
Ie: pkt.cksum = 0; pkt.cksum = cksum( <some cast> pkt, len);
![Page 67: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/67.jpg)
Host order/network order
How do I write the number 512?
![Page 68: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/68.jpg)
Host order/network order
How do I write the number 512?
Hint: 512 = 2^9
![Page 69: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/69.jpg)
Host order/network order
How do I write the number 512?
Hint: 512 = 2^9
Binary: 1000000000
Hex: 200
![Page 70: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/70.jpg)
Host order/network order
How do I write the number 512?
Hint: 512 = 2^9
Binary: 1000000000
Hex: 200
MSB LSB
![Page 71: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/71.jpg)
Host order/network order
MSB LSB
Should a machine store this as or ?
How do I write the number 512?
Hint: 512 = 2^9
Binary: 1000000000
Hex: 200
![Page 72: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/72.jpg)
How do I write the number 512?
Hint: 512 = 2^9
Binary: 1000000000
Hex: 200
Host order/network order
MSB LSB
Should a machine store this as or ?
Little-endian
Big-endianNetwork byte order
![Page 73: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/73.jpg)
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno;
char data[500];
};
typedef struct packet packet_t;
Host order/network order
?
?
![Page 74: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/74.jpg)
Host order/network order
struct packet {
uint16_t cksum;
uint16_t len;
uint32_t ackno;
uint32_t seqno;
char data[500];
};
typedef struct packet packet_t;
?
?
htons htonl ntohs ntohl
![Page 75: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/75.jpg)
htons ntohs htonl ntohl
If your host is little-endian:
ntohs( ) htons( )
If your host is big-endian
ntohs( ) htons( )
![Page 76: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/76.jpg)
Example
recvd_pkt.seqno = ntohl(recvd_pkt.seqno);
![Page 77: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/77.jpg)
Example
recvd_pkt.seqno = ntohl(recvd_pkt.seqno);
Design goal:
Limit the places you use ntohl, ntohs, htons, htonl to as few places as possible.
![Page 78: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/78.jpg)
Testing
● Test interoperability with reference solution● Test interoperability with classmates● use test options to simulate bad network connectivity
○ --drop○ --duplicate○ --corrupt○ --delay
![Page 79: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/79.jpg)
Summary
What the network can do to packets
Primitives for reliability
• Checksums
• Sequence numbers
• Acknowledgments
• Timeouts
Event-based code
• What are events?
• How do they map to code?
• How do you respond to them?
• How do you transition between states?
Gotchas
• cksum
• nthos htons ntohl htonl
![Page 80: Lab 2: Admin details Lab 2 is out! Due: o November 4th, 12 noon o November 6th, 12 noon (90% cap) Assignment and starter code online Start early! On average,](https://reader036.vdocuments.us/reader036/viewer/2022070306/5517f6ff550346c6568b4df9/html5/thumbnails/80.jpg)
Words of advice
Start early!
Start by reading/thinking/desiging
Test your implementation thoroughly
Start early!
Figure out when to call conn_input
Start early!