2026-07-12 15:43
Status:
Tags: Coursera Learning Google IT Certificate - Technical Support & Fundamentals IP - TCP Network Bits and Bytes of Computer Networking Networking Internet IT Cybersecurity
BBCN - Module 3- The Transport And Application Layers
==The Transport Layer
-
The Transport Layer:
-
Transport Layer- Allows for traffic to be directed to specific network applications via things like ports, so data coming in from the same server can go to different applications
-
Application Layer- Allows these applications to communicate and request data in a way that they understand
-
Multiplexing and de-multiplexing traffic is done in the transport layer
-
A multiplexer is the ability for nodes on a network to be able to direct traffic towards many different services
-
Demultiplexing is taking traffic that is all aimed at the same at the same node, and delivering it to the proper receiving service
-
Basically, if multiple websites request data from the same server, then multiplexing is getting that data without issue, and then de multiplexing is the data actually being sent out
-
This is handled via Ports
-
Ports- A 16-bit (2 byte) number that is used to direct traffic to specific services running on a networked computer
-
Different network services run on different ports depending on if they are a server or a client
-
The standard for HTTP is on Port 80 think of whenever you set up the server and had to do the little : thing in the url
-
FTP- File transfer protocol, which also uses ports in order to basically transfer files, it is old and outdated but still used in legacy systems, and traditionally listens on Port 21
-
-
The same server might be hosting a large number of these services at different ports, each with different protocols on how to send data whenever requested
-
-
Dissection of a TCP Segment:
-
This is basically the payload of data that is being send via the ports, think of the ethernet frame, or IP datagram, all of which encapsulate the lower you go
-
TCP Segment- Made up of a TCP header and a data section
-
Basically, the header is all the data needed to move the TCP segment, and the data section is the payload from the application layer
-
-
Source Port / Destination Port- the 16 bit number value that holds the port the data is coming from and going to, source ports are specifically chosen high level ports, and also known as ephemeral ports
-
Sequence Number- A 32-bit number that used to keep track of where in a sequence of TCP segments this one is expected to be, lower on the protocol there is limits to the size of how much data can be sent. An ethernet is limited to 1500 bytes, so TCP splits the data up into many segments, this number is just book keeping
-
Acknowledgement Number- the number of the next expected segment, basically expect the next segment and what not
-
Data offset Field- A 4-bit number that communicates how long the TCP header for the segment is, this basically the header length field for datagrams or ethernet frames
-
Control Flags- a reserved six bit spaces for flags inside of the TCP protocol, basically for more storage
-
Window- Specifies the range of sequence numbers that might be sent before an acknowledgment is requited, basically done so that all of the data is being received, and that data not being received is not send
-
Checksum- basically a value to be calculated the same way it is in the network layer, if the value is the same, then the data is (hopefully) uncorrupt. It is basically calculated whenever it is received, and compared with the checksum in the header
-
Urgent Pointer Field- used in conjunction with one of the TCP control flags to point out particular segments that might be more important than others
-
The rest are basically self explanatory
-
-
TCP Control Flags and the Three-way Handshake:
-
TCP establishes connections used to send long large amounts of data
-
The way that TCP establishes a connection is through the use of these different control flags, which are all used in a different order
-
The Six Different TCP Flags:
- URG (Urgent)- A value of one here indicates that the segment is considered urgent and that the urgent pointer field has more data about this, this flag is not normally seen or used
- ACK (acknowledged)- A value of one in the field means that the acknowledgement number field should be examined
- PSH (Push)- The transmitting devices wants the receiving device to push currently-buffered data to the application on the receiving end as soon as possible, basically the data is urgent and you need to send it quick
- RST (Reset)- One of the sides in a TCP connection hasn’t been able to properly recover from a series of missing or malformed segments, basically a flag telling the other TCP segments that something went wrong and they should start from scratch
- SYN (synchronize)- It’s used when first establishing a TCP connection and makes sure the receiving end knows to examine the sequence number field
- FIN (Finish)- When this flag is set to one, it means the transmitting computer doesn’t have any more data to send, and the connection can now be
-
The Threeway Handshake:
-
Computer A sends a segment to Computer B with a SYN flag set, basically say we should establish a connection
-
Then Computer B sends back a TCP segment with both SYN/ACK set so that way they do SYN and the other message is acknowledged
-
Then computer A responses with just the ACK flag set, and now they can start sending data to each other
-
-
Data is always now send and responded to with an ACK flag set, alongside with whatever other data might need to be sent in that given segment
-
Then, when wanting to close the connection, a 4 Way Handshake is done:
-
-
-
TCP Socket States:
-
Sockets- The instantiation of an end-point in a potential TCP connection, think of it as a point in software that basically is used to demonstrate how the sending of the data is going in the Transmission Control Protocol
-
Instantiation- the actual implementation of something defined elsewhere
-
A TCP socket is required to be instantiated by an actual program, this is unlike a port which is more of a virtual descriptive thing
-
You can send out anything you’d like, but you’re only going to get data back if the application has opened a socket on that port
-
The states of different sockets:
- LISTEN- means that a TCP socket is ready and listening for incoming connections, this is something that is seen server side only
- SYN_SENT- a synchronization request has been sent, but the connection has not yet been established, client side only
- SYN-RECEIVED- a socket previously in a LISTEN state has received a synchronization request and send a SYN/ACK back, however, it has not received the finally portion of the 3 way handshake, with the ACK
- ESTABLISHED- The TCP connection is in working order and both sides are free to send data to each other
- FIN_WAIT- A FIN has been sent, but the corresponding ACK from the other end hasn’t been received yet
- CLOSE_WAIT- The connection has been closed at the TCP layer, but that the application that opened the socket has not yet released it’s hold on the socket yet
- CLOSED- The connection has been fully terminated and that no further communication is possible
-
Sockets are defined outside of the TCP protocol, and the flags and what not are the exact same no matter what device or operating system you use, however this is not the same for Sockets, as they might vary from OS to OS
-
-
Connection-oriented and Connectionless Protocols:
-
Connection-oriented protocol- establishes a connection, and uses this to ensure that all data has been properly transmitted
-
This basically means that all data that is sent is acknowledged, so both sides of the connection always know if the data has been sent or not sent
-
There is a lot of reasons why data over the internet might be lost, for example if a large amount of data is being sent to a single router, it might drop your data in favor of other data
-
A construction company can accidentally cut a cord connecting to ISP provides, things like that
-
TCP protects against this with the ACK stuff
-
The IP and Ethernet protocols do have different checksum values to see if data is valid, and they reject it or take it, but they do not send the signal to resend. This is because this is purely done inside of the Transport layer via TCP
-
The issue with this safety is the extra traffic that comes with gaining and closing a connection, so other protocols, like UDP (user datagram protocol) have been established to send data without all the extra safety
-
You set a destination port and then just send out the packet. UDP is used for things like sending a video, where if a single package is not sent, it might not be a big deal, if a single frame or two is not sent, then the video is still watchable. You might even be able to send greater resolution videos because of the saved bandwidth
-
-
Supplemental Reading for System Ports versus Ephemeral Ports:
-
A TCP segment is a code that specifies ports used to establish a network connection.
-
This is one on the service side by telling a specific service to listen for data requests coming into a specific port.
-
Then, that listening port becomes a socket, so a socket in other words is an active port used by a service. Once a socket is activated, a client can send and receive data through it
-
System Ports are identified as ports 1 through 1023. System ports are reserved for common applications like FTP (port 21) and Telnet over TLS/SSL (port 992). Many still are not assigned. Note: Modern operating systems do not use system ports for outbound traffic.
-
User Ports are identified as ports 1024 through 49151. Vendors register user ports for their specific server applications. The IANA has officially registered some but not all of them.
-
Ephemeral Ports (Dynamic or Private Ports) are identified as ports 49152 through 65535. Ephemeral ports are used as temporary ports for private transfers. Only clients use ephemeral ports.
-
Ports allow services to send data to your computer but can also send malware into a client program. Malicious actors might also use port scanning to search for open and unsecured ports or to find weak points in your network security. To protect your network, you should use a firewall to secure your ports and only open sockets as needed.
-
-
Firewalls:
- Firewall- a device that blocks traffic that meets certain criteria
- Firewalls keep networks secure
- They can operate at lots of different layers of the network, like application traffic, or blocking ranges of IP addresses
- However, they are most commonly used with Ports in the Transport layer
- Firewalls operating here allows them to block traffic at given ports, but then also open the traffic at other ports
- Basically, if a server wants to direct access to a given port, like port 80, then it can just allow anyone to access that port, but then disallow any other IP addresses from outside the network to access other ports
==The Application Layer
-
The Application Layer:
- Basically, this is the layer where specific websites, given however they do it, send out data over to be encapsulated by the TCP segment. This can be the video streaming you are watching from your computer from youtube servers. Or photographs that a website might be trying to load, everything like that is here in the application layer
- A lot of protocols are used at this layer, things like HTTP, SMTP, HTTPS, basically all of that
- All of the web servers need to basically speak the same language in order to be able to send out all of this data, even if they use a different protocols, the most common of these is Microsoft IIS, Apache, nginx
- This way, no matter which browser you end up using, you can still speak to any server, they are basically the translators of the requests that a certain server might be making
-
The Application Layer and the OSI Model:
-
There are other types of protocols than TCP/IP, even if it is the most standard one. There might even be other flavors of TCP/IP which combine certain layers together into one layer
-
Open systems interconnections model (OSI Model)- this model is mostly used in academic settings and is used for teaching or certifications
-
It has 7 different layers, consisting of Physical, Data Link, Network, Transport, Session, Presentation, Applicaiton
-
The two addition layers:
- Session Layer- responsible for facilitating the communication between actual applications and the transport layer, it takes the application layer data and abstracts it out to the presentation layer
- Presentation Layer- responsible for making sure that the unencapsulated application layer data is able to be understood by the application in question, so there are no weird conflicts, basically handling encryption or compression of data
-
-
All the Layers Working in Unison:
-
-
Imagine three networks: Network A - (10.1. 1.0/24), Network B - 192.168. 1.0/24, Network C - 172.16. 1.0/24, all are basically just private local networks that are used by someone
-
Router A sits between Network A and Network B, with an interface of 10.1.1.1 in network A, and 192.168.1.254 at network B
-
Router B sits between network B and network C, with an interface of 192.168. 1.1 in network B and an interface 172.16.1.1 in network C
-
Now imagine a work desktop in Network A with a network of 10.1.1.100
-
And a server on network C with an IP address of 172.16.1.100, with a web server storing information at Port 80
-
When the desktop in network A types in the IP address (or site name via DNS) into a web browser, then port is automatically connected to the listening port 80, at which point a TCP connection wants to start
-
The network stack then examine’s it’s own subnet, at which point it realizes that it does not have a device with the 172.16.1.100 IP address, so it has to send the data via the gateway 10.1. 1.1 in order for the router to examine the data. Therefore, the computer looks at it’s arc table to determine what mac address has that IP address
-
If it does not have the given port, it sends out an ARP request FF: FF: FF: FF: FF: FF, at which point the router that got sent to sends back it’s own data and now the mac address is known
-
Now, the operating system knows that it is being asked to start a TCP connection, which basically means that it has to open up it’s own port, say port 50000, in order to have this active sending of data.
-
Therefore, now the networking stack proceeds to start filling out a TCP segment, with all the necessary stuff like the data, the sequence number, the flags, the checksum etc
-
This TCP segment now is passed off to the IP Datagram portion of the network, where the fields are filled in there, like the Source IP, destination IP, and a TTL value of say 64
-
This whole thing happens inside of the computer one, and it knows that it needs to get it to it’s gateway, which it now has the mac address for. It basically then sets up an ethernet frame, which holds the IP datagram data which itself holds the TCP data, all things are filled in like the source destination, and destination destination.
-
This data is then sent as ones and zeros between the computer and the router using varying amounts of voltage
-
The data has now reached the router, and it recognizes the address of where to send the data to. It calculates the checksum and compares the checksum to see that the data it got is correct, now stripping away that ethernet frame and leaving only the IP datagram
-
This datagram is checked for the data, and the TTL value is decremented, with a new checksum being made to include that new TTL value
-
The router then sees that the data it needs to send is only one hop away from network B to C via it’s own routing table. Due to the router’s own ARP table, it knows that it’s connection to network B via 192.168.1.254 can be used to connect to Router B via 192.168.1.1. So it sends the data over to the switch via the mac address stored in that ARP table, and then basically sends it over to router B by first constructing that ethernet frame with the source and destination addresses, wrapping that original IP datagram inside of that new ethernet frame
-
Router B now does the exact same things, removing the ethernet frame, checking the addresses, and recalculating the checksum, seeing now that it can move the data from one network to the other via the two interfaces that it is connected through
-
Sending the data over via once again wrapping it up with the ethernet frame, all the checksums and everything is done
-
The frame is sent out, the switch sees the destination and forwards it over to the server
-
This FINALLY, allows for the receiving computer to check the destination port in the stripped TCP datagram, and seeing that it is the listening port to basically start the second portion of the three way handshake, and send the data back over in essentially the same way to the other network on that open 50000 socket
-
==Glossary
ACK flag: One of the TCP control flags. ACK is short for acknowledge. A value of one in this field means that the acknowledgment number field should be examined
Acknowledgement number: The number of the next expected segment in a TCP sequence
Application layer: The layer that allows network applications to communicate in a way they understand
Application layer payload: The entire contents of whatever data applications want to send to each other
CLOSE: A connection state that indicates that the connection has been fully terminated, and that no further communication is possible
CLOSE_WAIT: A connection state that indicates that the connection has been closed at the TCP layer, but that the application that opened the socket hasn’t released its hold on the socket yet
Connection-oriented protocol: A data-transmission protocol that establishes a connection at the transport layer, and uses this to ensure that all data has been properly transmitted
Connectionless protocol: A data-transmission protocol that allows data to be exchanged without an established connection at the transport layer. The most common of these is known as UDP, or User Datagram Protocol
Data offset field: The number of the next expected segment in a TCP packet/datagram
Demultiplexing: Taking traffic that’s all aimed at the same node and delivering it to the proper receiving service
Destination port: The port of the service the TCP packet is intended for
ESTABLISHED: Status indicating that the TCP connection is in working order, and both sides are free to send each other data
FIN: One of the TCP control flags. FIN is short for finish. When this flag is set to one, it means the transmitting computer doesn’t have any more data to send and the connection can be closed
FIN_WAIT: A TCP socket state indicating that a FIN has been sent, but the corresponding ACK from the other end hasn’t been received yet
Firewall: It is a device that blocks or allows traffic based on established rules
FTP: An older method used for transferring files from one computer to another, but you still see it in use today
Handshake: A way for two devices to ensure that they’re speaking the same protocol and will be able to understand each other
Instantiation: The actual implementation of something defined elsewhere
Listen: It means that a TCP socket is ready and listening for incoming connections
Multiplexing: It means that nodes on the network have the ability to direct traffic toward many different receiving services
Options field: It is sometimes used for more complicated flow control protocols
Port: It is a 16-bit number that’s used to direct traffic to specific services running on a networked computer
Presentation layer: It is responsible for making sure that the unencapsulated application layer data is actually able to be understood by the application in question
PSH flag: One of the TCP control flags. PSH is short for push. This flag means that the transmitting device wants the receiving device to push currently- buffered data to the application on the receiving end as soon as possible
RST flag: One of the TCP control flags. RST is short for reset. This flag means that one of the sides in a TCP connection hasn’t been able to properly recover from a series of missing or malformed segments
Sequence number: A 32-bit number that’s used to keep track of where in a sequence of TCP segments this one is expected to be
Server or Service: A program running on a computer waiting to be asked for data
Session layer: The network layer responsible for facilitating the communication between actual applications and the transport layer
Socket: The instantiation of an endpoint in a potential TCP connection
Source port: A high numbered port chosen from a special section of ports known as ephemeral ports
SYN flag: One of the TCP flags. SYN stands for synchronize. This flag is used when first establishing a TCP connection and make sure the receiving end knows to examine the sequence number field
SYN_RECEIVED: A TCP socket state that means that a socket previously in a listener state, has received a synchronization request and sent a SYN_ACK back
SYN_SENT: A TCP socket state that means that a synchronization request has been sent, but the connection hasn’t been established yet
TCP checksum: A mechanism that makes sure that no data is lost or corrupted during a transfer
TCP segment: A payload section of an IP datagram made up of a TCP header and a data section
TCP window: The range of sequence numbers that might be sent before an acknowledgement is required
URG flag: One of the TCP control flags. URG is short for urgent. A value of one here indicates that the segment is considered urgent and that the urgent pointer field has more data about this
Urgent pointer field: A field used in conjunction with one of the TCP control flags to point out particular segments that might be more important than others




