STEVEN R. BAGLEY PACKETS
INTRODUCTION Talked about how data is split into packets Allows it to be multiplexed onto the network with data from other machines But exactly how is it split into packets and what do they look like
PACKET SIZE How much data do you carry in a packet? Too little and your network is primarily carrying packet headers Too large and you increase latency
LATENCY Latency is the time taken for a packet to get from one computer to another Related to the speed (or bandwidth) of a network but not the same Can have high-speed networks that have a high-latency Once the packets start arriving the data comes in very quickly But takes a (relatively) long time for the packets to start arriving Sometimes low-latency can be more important than high-speed, particularly for interactive applications High lat
PACKET SIZE AND LATENCY One factor determining latency then is the time the previous packet takes to send The packet is the unit of transmission on a network Next packet cannot be sent until the current one has finished sending As the packet size increases, so does this length of time Increases the potential delay before the next packet can be sent Give example from my 14k4 modem
ETHERNET PACKET SIZE Maximum packet size of 1500 bytes (plus headers) Minimum packet size of 46 bytes (plus headers) Packet Header is 14 bytes (plus 64-bits of preamble) And 4 bytes of error detection at the end Total packet length varies between 64 1514 bytes (plus 8 bytes) Between 67.65% and 98.30% of the network traffic is data Lots of small packets is a very inefficient
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC Sizes are in bytes
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC Sizes are in bytes
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC Preamble 64-bits of alternating 1s and 0s Allows the receiver to lock onto the packet Sizes are in bytes
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC Destination and Source addresses The 48-bit MAC address of the respective machines Note, special MAC address can be used to designate a broadcast packet Broadcast packets are sent to ALL machines Broadcast packet are all ones
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC Frame type identifies what is in the packet Just a number Type numbers are standardised so that equipment from different vendors can interoperate Frames carrying IP packets have the type 0x0800 for instance
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 Data is literally just that the bits you want to send No size field, but packets can vary in length How do we know how big the packet is? Remember the ethernet line is silent after a packet is sent So if carrier disappears, it must be the end of the packet Required to transmit 96-bits of idle line between packets Know the format of the packet so know which bits are data DATA CRC Can anyone spot anything missing from this?
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 Data is literally just that the bits you want to send No size field, but packets can vary in length How do we know how big the packet is? Remember the ethernet line is silent after a packet is sent So if carrier disappears, it must be the end of the packet Required to transmit 96-bits of idle line between packets Know the format of the packet so know which bits are data DATA CRC If carrier drops for any other reason the CRC won t match
ETHERNET PACKET PREAMBLE DEST. SOURCE ADDRESS ADDRESS FRAME TYPE 8 6 6 2 46 1500 4 DATA CRC CRC Cyclic Redundancy Check A number created from the packet Receiver regenerates the same number if they don t match, packet must have been corrupted Enables error detection Error detection, but not correction
IP PACKETS IP packets are similar Again, have a header associated with data Packet (including headers) can be variable size up to 65535 bytes But IP packets have to be carried inside other packets, e.g. Ethernet In reality, the size of the carrying packet will usually define the packet size On Ethernet, IP packet maximum size is usually 1500 bytes Maximum size of IP packet known as the Maximum Transmission Unit
IPv4 PACKET VERSION IHL DSCP TOTAL LENGTH IDENTIFICATION FLAGS FRAGMENTATION OFFSET TIME TO LIVE PROTOCOL HEADER CHECKSUM SOURCE ADDRESS DESTINATION ADDRESS OPTIONS (+ PADDING) DATA (VARIABLE) More complicated, than ethernet but similar concepts (Address, protocol type etc.) Header contains the length of the packet (Total Length in bytes) and the length of the header (IHL in multiples of 32 bit words)
FRAGMENTATION IP packets (unlikely ethernet) will be passed between different networks These networks are heterogenous and so may have different packet sizes Going from a network with a small packet size to one with a large size is not a problem (though less efficient) Going the other way is not possible IP allows packets to be fragmented split into smaller chunks
FRAGMENTATION When fragmented, the data in an IP packet is split into chunks Each chunk is a multiple of 8-bytes long Those new chunks are then sent as IP packets across the other network Identification field used to identify the packet Fragment offset used to specify where the data goes Receiver puts the fragments back together to regenerate the original packet
PATH MTU DISCOVERY IPv6 takes a different approach (also available on IPv4) Does not allow packets to be fragmented Rather it finds out what the largest packet size allowed on that path between two machines Then uses that as its MTU for sending packets
RELIABILITY IP is not a reliable network protocol Rather its classed as a best-effort network Higher level protocols are built on top of IP to provide a reliable connection Not always desirable, can increase latency Do it s best to get the data there but won t guarantee it Interactive applications can work better without latency
TRANSMISSION CONTROL PROTOCOL TCP is the main protocol used on the Internet to provide reliable, end-to-end, virtual connection Connection-oriented protocol Connection explicitly opened and closed between two machines Allows multiple connections between the same two machines Introduces the concept of a port Connection is made between a source port on one machine and a destination port on the other end-to-end because its between two machines like a piece of wire, virtual because its produced entirely in software If the source IP +source port AND destination IP + destination Port match then the connection is for the connection
TRANSMISSION CONTROL PROTOCOL TCP is built entirely on top of IP with its own 20 byte header Needs to solve several problems Out-of-order delivery Packet Loss Not going to look at the header in detail, but contains things like port numbers, sequence numbers etc
OUT OF ORDER DELIVERY IP does not guarantee packets arrive in the order you send them TCP solves the problem of out-of-order delivery by giving every packet a sequence number Can reorder the packets into the right order based on the sequence number might take different routing paths
PACKET LOSS IP does not guarantee to deliver a packet so TCP needs to ensure a packet is received Does this by retransmitting lost packets If no acknowledgement is received, after a certain time period Packet resent And repeat similar to Aloha
PACKET LOSS EVENTS AT HOST A EVENTS AT HOST B SEND PACKET 1 RECEIVE ACK 1 SEND PACKET 2 RECEIVE ACK 1 SEND PACKET 3 RECEIVE PACKET 1 SEND ACK 1 RECEIVE PACKET 2 SEND ACK 2 PACKET LOST A RETRANSMISSION TIMER EXPIRES RESEND PACKET 3 RECEIVE ACK 3 SEND PACKET 4 RECEIVE PACKET 3 SEND ACK 3 RECEIVE PACKET 4 SEND ACK 4 B TIME TIME
PACKET LOSS How long should it wait before retransmission? Depends on how much traffic is on the Internet at that point between the machines TCP has an adaptive transmission time monitors the time between sending the packet and receiving the ACK back Adjusts the time appropriately
WINDOWING Problem with this approach is it slows transmission Sender must wait for ACK before sending next packet Network idle during this time TCP uses a window approach Rather than sending just one packet, TCP will send multiple packets up to a certain window size When it receives an ACK, it can then send some more packets
WINDOWING EVENTS AT HOST A EVENTS AT HOST B SEND PACKET 1 SEND PACKET 2 SEND PACKET 3 RECEIVE ACK 1, SEND PACKET 4 RECEIVE ACK 2, SEND PACKET 5 RECEIVE ACK 3, SEND PACKET 6 RECEIVE PACKET 1, SEND ACK 1 RECEIVE PACKET 2, SEND ACK 2 RECEIVE PACKET 3, SEND ACK 3 RECEIVE PACKET 4, SEND ACK 4 RECEIVE PACKET 5, SEND ACK 5 RECEIVE PACKET 6, SEND ACK 6 A B TIME TIME Notice how we get much better utilisation of the network with this approach With the right window size, you can get almost full network utilisation
TCP WINDOWING TCP allows the receiver to tell the client how much space is free Sender can then adaptively adjust the sending of packets to keep the window full But not overload it