18 - TCP/IP Layer 3 (TCP and UDP) - Fun, but important Network theory bit - Recap - Networking works by layers - Layer 1 - Machine to Machine - Layer 2 - IP protocol - Layer 3 - Transport Layer - TODAY'S TOPIC - not just individual packets, but entire streams of data - 2 important protocols - TCP - Transmission Control Protocol - THE most important Protocol, such that it is part of the namesake of the whole networking stack (TCP/IP) - UDP - TCP - problems it is trying to solve - layer 2 sends individual packets - so one might think you just do that a whole bunch of times - there are complications - 1. packets get corrupted - 2. When routers get busy, they just throws out packets - 3. Packets are treated independently by routers, so they probably will arrive at the destination in different orders - TCP deals with all of these - TCP promises that all information will arrive safely, re-request any packets that didn't arrive, and puts them all back in the right order again when it does. - throws in a new layer we haven't discussed deeply yet - Ports - analogy - each machine is an apartment building - each room is a port - when a machine wants to communicate, it has to know not only what building it's going to, but also what room - a packet must have a source port, source IP address, destination port, and destination IP address for the connection to be made - A specific Application is "listening" if a specific port - when traffic comes in on a port, the computer passes the data on to whatever application was listening on the port - e.g. - SSH listens on port 22 - Webservers listen on port 80 - Privileged port - any port under 1024 - have to be root (or System Admin on windows) to listen on this port - Up until now, you may think TCP is perfect. - However, TCP has one major tradeoff: - overhead - each TCP connection is a two way connection - TCP is "chattier" - it also requires more memory and CPU - thus it is slower and requires more powerful - On the other hand, if you need to do something fast and with little overhead, and you dont care about dropped or scrambled packets, there is an alternative to TCP - UDP - limited use, but streaming almost always uses it - skype - Command - lsof - list open files - UNIX treats everything as a file - even Network connections - lsof -i - i stands for internet - all your open TCP or UDP connections - Bart Busschots - bartb.ie - impodcast.tv - podfeet.com