CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

37
CS/EE 145A CS/EE 145A Reliable Reliable Transmission over Transmission over Unreliable Channel Unreliable Channel Netlab.caltech.edu/course Netlab.caltech.edu/course

Transcript of CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Page 1: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

CS/EE 145ACS/EE 145AReliable Reliable

Transmission over Transmission over Unreliable Channel Unreliable Channel

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

Page 2: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1Lab 1

Q&A:Q&A: 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 o

n the client side?n the client side? I did some extra work…I did some extra work… How do you grade my work?How do you grade my work?

Page 3: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1Lab 1 Clients:Clients:

Reference Server:l ocal host

Cl i ent Under Test:Local Host

Page 4: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1Lab 1 Server (Basic Functions):Server (Basic Functions):

Reference Cl i ent:l ocal host

Server Under Test:Local Host

Page 5: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1Lab 1

Server (Advanced Function 1, Multi-Server (Advanced Function 1, Multi-connection):connection):

ReferenceCl i ent1:l ocal host

Server Under Test:l ogi n. cs

ReferenceCl i ent2:l ocal host

ReferenceCl i ent3:l ogi n.cs

Page 6: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1Lab 1 Server (Advanced Function 2, 3-connections):Server (Advanced Function 2, 3-connections):

l ocal host

Server Under Test:l ogi n. cs

fast2.cs

fast1.cs

l ogi n.cs

Page 7: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1: MultiplexingLab 1: Multiplexing

Multiple 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 How to tell the main process when the child processes finish the TCP the child processes finish the TCP connection?connection?

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

Page 8: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1: MultiplexingLab 1: Multiplexing

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

Page 9: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 1: MultiplexingLab 1: Multiplexing

Single Process:Single Process: Check status of all ports with a Check status of all ports with a

single “select” functionsingle “select” function Timeout of the “select”?Timeout of the “select”?

Page 10: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Topics of this threadTopics of this thread

How does TCP/IP work? (roughly)How does TCP/IP work? (roughly) Design and implementation of Design and implementation of

protocolsprotocolsApplication (HTTP, FTP, SSH, Application (HTTP, FTP, SSH, SMTP…)SMTP…)

Transportation (TCP)Transportation (TCP)

Networking (IP)Networking (IP)

MAC MAC

Physical Physical

Lab 1

Lab 2, 3, 4

Page 11: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Reliable Transmission over Reliable Transmission over Unreliable Channel (I)Unreliable Channel (I)

TCP:TCP: Reliable Transmission Reliable Transmission

Guarantee: The packets sent will be Guarantee: The packets sent will be received with the same order.received with the same order.

IP:IP: Unreliable Transmission Unreliable Transmission

Best Efforts: Packets can be dropped, can Best Efforts: Packets can be dropped, can be reordered, can be duplicated, can be …be reordered, can be duplicated, can be …

Page 12: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Reliable Transmission over Reliable Transmission over Unreliable Channel (I)Unreliable Channel (I)

TCP:TCP: Reliable Transmission Reliable Transmission

Guarantee: The packets sent will be Guarantee: The packets sent will be received with the same order.received with the same order.

IP:IP: Unreliable Transmission Unreliable Transmission

Best Efforts: Packets can be dropped, can Best Efforts: Packets can be dropped, can be reordered, can be duplicated, can be …be reordered, can be duplicated, can be …

Stream Stream

Page 13: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Reliable Transmission over Reliable Transmission over Unreliable Channel (I)Unreliable Channel (I)

TCP:TCP: Reliable Transmission Reliable Transmission

Guarantee: The packets sent will be Guarantee: The packets sent will be received with the same order.received with the same order.

IP:IP: Unreliable Transmission Unreliable Transmission

Best Efforts: Packets can be dropped, can Best Efforts: Packets can be dropped, can be reordered, can be duplicated, can be …be reordered, can be duplicated, can be …

Stream Stream

P1, P2, … ???

Page 14: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Reliable Transmission over Reliable Transmission over Unreliable Channel: GoalsUnreliable Channel: Goals

We want the file to be transmitted We want the file to be transmitted without any error.without any error.

We cannot make any assumption on We cannot make any assumption on the channel (The packet may be the channel (The packet may be dropped, re-ordered, duplicated… in dropped, re-ordered, duplicated… in the middle).the middle).

We don’t want to waste time.We don’t want to waste time. We don’t want to waste bandwidth.We don’t want to waste bandwidth.

Page 15: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Reliable Transmission over Reliable Transmission over Unreliable Channel: Unreliable Channel:

DifficultiesDifficulties How to split a file into packets?How to split a file into packets? How to detect errors (packet corruption, How to detect errors (packet corruption,

packet loss, duplication, reordering…)?packet loss, duplication, reordering…)? How to recover from packets How to recover from packets

reordering?reordering? How to recover from loss?How to recover from loss? How to use the bandwidth efficiently?How to use the bandwidth efficiently? How to share the bandwidth fairly?How to share the bandwidth fairly? ……

Page 16: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 2Lab 2 How to split a file into packets?How to split a file into packets? How to detect errors (packet corruption, How to detect errors (packet corruption,

packet loss, duplication, reordering…)?packet loss, duplication, reordering…)? How to recover from packets How to recover from packets

reordering?reordering? How to recover from loss?How to recover from loss? How to use the bandwidth efficiently?How to use the bandwidth efficiently? How to share the bandwidth fairly?How to share the bandwidth fairly? ……

Page 17: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 3Lab 3 How to split a file into packets?How to split a file into packets? How to detect errors (packet corruption, How to detect errors (packet corruption,

packet loss, duplication, reordering…)?packet loss, duplication, reordering…)? How to recover from packets How to recover from packets

reordering?reordering? How to recover from loss?How to recover from loss? How to use the bandwidth efficiently?How to use the bandwidth efficiently? How to share the bandwidth fairly?How to share the bandwidth fairly? ……

Page 18: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Lab 4Lab 4 How to split a file into packets?How to split a file into packets? How to detect errors (packet corruption, How to detect errors (packet corruption,

packet loss, duplication, reordering…)?packet loss, duplication, reordering…)? How to recover from packets How to recover from packets

reordering?reordering? How to recover from loss?How to recover from loss? How to use the bandwidth efficiently?How to use the bandwidth efficiently? How to share the bandwidth fairly?How to share the bandwidth fairly? ……

Page 19: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Split a fileSplit a file

File

File

Sender

Receiver

What’s inside

a packet?

Page 20: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Inside a packetInside a packet

DataData HeaderHeader Help to reassemblyHelp to reassembly Help to detect errorsHelp to detect errors

Page 21: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

One Example: TCP One Example: TCP HeaderHeader

Source: http://linux-ip.net/gl/tcng/node39.htmlSource: http://linux-ip.net/gl/tcng/node39.html

Detect Packet

Corruption

Packet Identificati

on

Page 22: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Sequence Number Sequence Number (Packet ID)(Packet ID)

1 2 3 4 5 6 7 8

File

1 2 3 4 5 6 7 8

File

Sender

Receiver

Page 23: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

In case of packet loss…In case of packet loss…

1 2 3 4 5 6 7 8

File

1 2 4 5 6 7 8

Sender

Receiver

Why?

Please Retransmit: packet 3

Page 24: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

In case of packets In case of packets reordering…reordering…

1 2 3 4 5 6 7 8

File

1 2 34 5 6 7 8

Sender

Receiver

Why?

1 2 3 4 5 6 7 8

Page 25: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

8

Packet duplicationPacket duplication

1 2 3 4 5 6 7 8

File

1 3 42 5 6 7

Sender

Receiver

2

Why?

1 2 3 4 6 7 85

Page 26: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Sequence Number Sequence Number (Packet ID)(Packet ID)

With the packet ID, the receiver side With the packet ID, the receiver side can recover from packet reordering can recover from packet reordering and packet duplication.and packet duplication.

The receiver can detect packet loss. The receiver can detect packet loss. But it has to call sender for But it has to call sender for retransmission.retransmission.

Page 27: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

CS/EE 145A Lab 2CS/EE 145A Lab 2PacketPacket

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

Page 28: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Tasks for Lab 2Tasks for Lab 2( Not a network ( Not a network

programming! programming! ) )Assume there is no “packet Assume there is no “packet

corruption”:corruption”: Design a packet format that can be Design a packet format that can be

used to transmit data reliably, over used to transmit data reliably, over unreliable channelsunreliable channels

Implement conversion from a file to Implement conversion from a file to packets, at sender side.packets, at sender side.

Implement error detection and file Implement error detection and file reassembly, at receiver side.reassembly, at receiver side.

Page 29: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Sequence Number Sequence Number (Packet ID)(Packet ID)

1 2 3 4 5 6 7 8

File

1 2 3 4 5 6 7 8

File

Sender

Receiver

Page 30: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

SenderSender

sender <filename> <PacketSize>sender <filename> <PacketSize> Read the file specified by <filename> (The fiRead the file specified by <filename> (The fi

le contains English characters and numbers le contains English characters and numbers only)only)

Convert this file into packets, each packet hConvert this file into packets, each packet has at most <PacketSize> bytes, including heaas at most <PacketSize> bytes, including header.der.

Save each packet to one file, with a file namSave each packet to one file, with a file name as “P0000001.txt”, “P0000002.txt”, …e as “P0000001.txt”, “P0000002.txt”, …

Page 31: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

ReceiverReceiver

receiver <number of “packets”> <PacketSize> <freceiver <number of “packets”> <PacketSize> <filename>ilename>

Read the files for packets ( “P0000001.txt”, “PRead the files for packets ( “P0000001.txt”, “P0000002.txt”)0000002.txt”)

WARNING: The filenames are always from 1 to WARNING: The filenames are always from 1 to <number of packets>. But packets may not have <number of packets>. But packets may not have the same filenames assigned by the sender, due the same filenames assigned by the sender, due to “packet loss”, “packet reordering” or “pto “packet loss”, “packet reordering” or “packet duplication”.acket duplication”.

Convert the packets into a file, specified by <fileConvert the packets into a file, specified by <filename>. Use one character “#” to indicate eacname>. Use one character “#” to indicate each lost packet. h lost packet.

Page 32: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

ExampleExample

File: “abcdefg” File: “abcdefg” Packet Size=10 bytesPacket Size=10 bytesHeader size = 7 bytesHeader size = 7 bytesPayload = 3 bytesPayload = 3 bytesSender: Output 3 files:Sender: Output 3 files:P0000001.txt: <header>+ “abc”P0000001.txt: <header>+ “abc”P0000002.txt: <header>+ “def”P0000002.txt: <header>+ “def”P0000003.txt: <header>+ “g”P0000003.txt: <header>+ “g”

Page 33: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

ExampleExample

After “reordering” (by a program writtAfter “reordering” (by a program written by TA):en by TA):

P0000001.txt: <header>+ “abc”P0000001.txt: <header>+ “abc”P0000002.txt: <header>+ “g”P0000002.txt: <header>+ “g”P0000003.txt: <header>+ “def”P0000003.txt: <header>+ “def”Receiver:Receiver:Output a file: “abcdefg”Output a file: “abcdefg”

Page 34: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

ExampleExample

After “packet loss” (by a program writtAfter “packet loss” (by a program written by TA):en by TA):

P0000001.txt: <header>+ “g”P0000001.txt: <header>+ “g”P0000002.txt: <header>+ “def”P0000002.txt: <header>+ “def”Receiver:Receiver:Output a file: “#defg”Output a file: “#defg”

Page 35: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

TipsTips

For the unknown commands, use For the unknown commands, use “man”/ “info”.“man”/ “info”.

Be careful of the data structuresBe careful of the data structures Testing: design some small Testing: design some small

examples to test your programexamples to test your program Start Earlier!Start Earlier!

Page 36: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

Submission (due Submission (due Nov 7Nov 7th th

23:59:59)23:59:59)Task: sender.c; receiver.c; readme.txtTask: sender.c; receiver.c; readme.txtMailto: [email protected] Mailto: [email protected] Documents:Documents: How to use the programs: compile, ruHow to use the programs: compile, ru

n… n… Design, testing cases, the problems yoDesign, testing cases, the problems yo

u metu met Any other commentsAny other comments

Page 37: CS/EE 145A Reliable Transmission over Unreliable Channel Netlab.caltech.edu/course.

GradingGrading

Correctness (70%) Correctness (70%) Documentation and comments (20%)Documentation and comments (20%) Program style (10%)Program style (10%)

TA HoursTA Hours

Tue: 20:00 ~22:00 JRG 170Tue: 20:00 ~22:00 JRG 170 Thu: 20:00 ~22:00 JRG 170Thu: 20:00 ~22:00 JRG 170