TCP and UDP Protocols
Total Page:16
File Type:pdf, Size:1020Kb
TCP and UDP Protocols Table of Contents TCP / UDP ........................................................................................................................................ 2 TCP .................................................................................................................................................. 4 UDP ................................................................................................................................................. 5 Ports and Service Identifiers ........................................................................................................... 6 Protocols -1 ..................................................................................................................................... 8 Protocols -2 ................................................................................................................................... 10 Protocols -3 ................................................................................................................................... 12 ARP ................................................................................................................................................ 14 DHCP and BOOTP .......................................................................................................................... 16 DHCP Example ............................................................................................................................... 17 DHCP, BOOTP, and RARP Security Issues ...................................................................................... 19 ICMP Security Issues ..................................................................................................................... 21 Notices .......................................................................................................................................... 24 Page 1 of 24 TCP / UDP TCP / UDP Transport Control Protocol (TCP) • Connection-oriented protocol • Guaranteed information delivery; error recovery • Sequencing and acknowledgements • Good for: file transfer, email, web page requests User Datagram Protocol (UDP) • Connection-less oriented protocol • No guarantee of delivery; “best effort” • Speed advantages over TCP • Good for: audio / video streaming 135 **135 Let's take that next step and talk about the protocols of TCP and UDP. In TCP what we have is a connection oriented protocol. We want to send lots of data. It could be out of sequence. So, therefore what we'll do is we'll create sequence numbers on that. And you can acknowledge those sequence numbers as we go along. It's good for things like file transfer, email, and web page requests. What happens if we have something that's not nearly as sensitive and not as time sensitive, and we just want to hope that it gets there? Well, then we can use UDP. This is a Page 2 of 24 connectionless oriented protocol that is like-- they call it best effort. It's what I call send and pray. When you talk to a DNS server and say resolve this for me, and it responds back to you, well if it doesn't make it because it's such a little tiny request, if it doesn't make it, you'll configure your host so that you have a secondary DNS server that you can go to it. Now, it can be used for audio and video streaming if the upper layer application protocols that you're using all have error correction built into them because UDP does not do error correction. But the nice thing about streaming video is if you miss just a couple of packets, all you're going to get is one of those jerks in there. And that's going to be the only thing that actually happens in that whole thing. Now, if you're losing a lot of packets, and you don't have good error correction on this, then you actually are going to lose your stream. And you're going to have to re-associate. But that little piece of video that you missed when I was here to the one where I was here, and you missed that intervening time, really didn't mess up the conversation for you. Page 3 of 24 TCP TCP Transport Control Protocol (TCP) Open Communication Open Ack Data Data Ack Close Communication Close Ack Three-way handshake (TCP Flags) SYN SYN-ACK ACK 136 **136 So, let's look at TCP for a second. When we talk about TCP, we communicate back and forth. And we start this conversation where I say, "I'd like to speak with you." And you acknowledge that I'd like to speak with you. You'd like to speak with me and I acknowledge that you'd like to speak with me. We set up a connection between us and then we do transfer back and forth using the flags of TCP, which are SYN and ACK. The reason why we call it a three- way handshake is because we condense that down to the first as synchronized, SYN. And the response back is SYN and ACK together. That's the only time that we actually put Page 4 of 24 two flags in a single packet. Any other time that we put more than-- two or more flags into a single packet, it is abuse of the protocol. It is not programmed for that. UDP UDP User Datagram Protocol (UDP) Send Data Receive Data 137 **137 UDP is send and receive. I send this out. I receive the data back. I don't even try. If I fail, I go on to another server. That's how and why we configure two DNS servers in case one is really busy. Page 5 of 24 Ports and Service Identifiers Ports and Service Identifiers TCP and UDP use “ports” aka “service identifiers” Managed by the Internet Assigned Numbers Authority (IANA) Ports are numbered 1 through 65535 • 0 – 1023 – “Well-known” ports, assigned to specific services (e.g., DNS = 53, SSH = 22, SMTP = 25) • 1024 – 49151 – “Registered” ports, unassigned, but can be registered through IANA by developers • 49152 – 65535 – “Dynamic” ports, unassigned and open for anyone to use Ephemeral Ports – port used for the source port when establishing a connection • Linux kernels use 32768-61000 • Windows uses 1025-5000 138 **138 The services are going to listen on particular ports. The most important ports we call the well- known ports, sometimes called the service ports, are from zero to ten twenty-three. And there is a port zero, we just don't use it that often. Now, that's well-known ports. Up above that from ten twenty-four to four nine five-- four nine one five one, we have what are called the registered ports, which are unassigned but people use them by convention for a whole bunch of different items out there, some for a gaming server, some for synchronous Page 6 of 24 communication. But they're also restricted use. The last set, what I call the dynamic ports, are above one forty-nine, one fifty-two all the way up to the top. Those are used most of the time for client communications. So, when I, as an end user-- remember my two end users back here for Google? When they came to me and said, "Hey, I want to talk to Google." What I said is, "Well, what's your port?" And they said, "Well, it's twenty thousand." Well, I know that that's probably some upper level ephemeral port. They can use anything that they want. That's fine. I'm going to map the conversation back to them. They should be using four nine one five two and above. So, I get that communication, and I go out and I say, "Okay, here's that communication." What you know as a server on your side Google is that when you come back to me, you know that this firewall is going to hold up in that connection and allow you to pass it through because you came back on the port. You answered back on the port that was requested. And it will map it back to that host. And then that host will go ahead and map that to the application that they are actually using at that moment in time. So, four nine one five two is where you see most of the communication from end user's workstations coming from, up and above there. Now you could call this the ephemeral ports. It's a little bit different. These are Page 7 of 24 used for source ports when establishing some sort of connection. Linux users thirty-two thousand. On Windows uses above ten twenty-five. I think it's for them all to be using above forty-nine one fifty-two. Protocols -1 Protocols -1 ARP Address resolution protocol OSI Layer 2, IP address to MAC address translation RARP Reverse address resolution protocol OSI Layer 2, MAC address to IP address translation PPP Point-to-point protocol OSI Layer 2, encapsulating protocol for sending data ICMP Internet control message protocol OSI Layer 3, diagnostic information and control messages IGMP Internet group management protocol OSI Layer 3, multicast transmissions and control DHCP Dynamic host configuration protocol OSI Layer 3, provides network settings to hosts 139 **139 Let's look at some of the protocols here that we've been talking about. But I wanted to roll them all up and say what they're good for. If you're a good WireShark player in the game-- remember I talked about using WireShark? If you're a good player in the game when it comes to WireShark, you will look for these protocols in the stack Page 8 of 24 and actually see. You can actually see. You can actually download-- there's a bunch of packet capture libraries that are out there that you can actually look at these protocols. And they'll give you each one of them. So, when we talk about these protocols, sometimes they're also called services. It depends on how you're looking at it. Like for instance ARP is the protocol. It's the address resolution protocol. But all the way at the bottom, DHCP is the dynamic host configuration protocol. But usually what we call it is the IP addressing service.