TCP/IP

tenchu

Member

Reaction score: 7
Messages: 39

I'm currently learning the basics of TCP/IP and am struggling with the whole 'model' thing. I had the same problem with the OSI model when learning networking and still don't really get it. I can understand that it conceptualises the procsess of sending somthing across a network and that each layer is modular i.e. can be improved/modified without messing with the other layers, but the actual process eludes me. I mean from the second a user presses a key on the keyboard or clicks a mouse button, I cannot get my head round which layer is then doing what. I've looked high and low for a good explanation for beginners that would describe each layer and what it does but have always been left more confused than when I started. Can anyone gere help?
 

drhowarddrfine

Son of Beastie

Reaction score: 1,142
Messages: 3,096

I mean from the second a user presses a key on the keyboard or clicks a mouse button, I cannot get my head round which layer is then doing what.
To be clear, you understand TCP/IP has nothing to do with any of that, right?
 
  • Thanks
Reactions: OJ
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 39

To be clear, you understand TCP/IP has nothing to do with any of that, right?
I'm well aware, but thanks for asking. I was trying to over emphasise my point i.e. what specifically happens after an application sends data.
 

Emrion

Active Member

Reaction score: 36
Messages: 183

Models exist to account a very complex reality but they aren't reality. Maybe the DoD model is easier to understand and somewhat closer to the real world.

I think if you really want to understand the thing, you need to program some toys that use TCP/IP. A hard way if you never programmed before but that will certainly answer most of the questions you have.
 
OP
OP
T

tenchu

Member

Reaction score: 7
Messages: 39

Models exist to account a very complex reality but they aren't reality. Maybe the DoD model is easier to understand and somewhat closer to the real world.

I think if you really want to understand the thing, you need to program some toys that use TCP/IP. A hard way if you never programmed before but that will certainly answer most of the questions you have.
I've got a raspberry pi 2 and an arduino. I bought them with the intention of learning such things as networking and low level programming. I've not done too bad with the programming part because there are lots of 'hands on' exercises. However the networking side is more difficult because I've not come across any books or resources that provide hands on practice. They all seem to be conceptual, which in practice has meant pages of text with no exercises. I actually learnt a lot just from setting up BSD on a nackered old laptop with a lot of help from members on the forums here. It's a shame there are no resources that have you doing practical exercises.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,298
Messages: 29,745

However the networking side is more difficult because I've not come across any books or resources that provide hands on practice.
Get all three volumes of "TCP/IP Illustrated" by W. Richard Stevens. Volume 1 will tell you everything you need to know about TCP/IP in excruciating detail. Volume 2 is more about socket programming and volume 3 is about things like SSL/TLS. All three volumes contain, besides a ton of information, a lot of examples and exercises. They're collectively known as the "Bible" of TCP/IP.
 

tommiie

Active Member

Reaction score: 40
Messages: 155

Get all three volumes of "TCP/IP Illustrated" by W. Richard Stevens.
Alternatively you can also get the three volumes of "Internetworking with TCP/IP" by Douglas E. Comer. They cover the same topics and its third volume even has a version specific to BSD UNIX.

I've often wondered whether Stevens' books or Comer's are "better" but never found a definitive answer.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,298
Messages: 29,745

Something that keeps tripping everyone up, OSI is a model not a standard.
 

shkhln

Well-Known Member

Reaction score: 171
Messages: 460

Well, OSI was published as ISO 7498, so it's literally a standard. It wasn't intended as a simple conceptual model either, it was supposed to be implemented in software (probably not necessarily with all 7 layers per implementation). However, TCP/IP was never developed with OSI model in mind and does not map to it cleanly by design. One can think about Internet in OSI terms, but it is really quite pointless. (And the mapping on the diagram above is total bullshit, what with the mp3-sockets equivalence.)
 

usdmatt

Daemon

Reaction score: 514
Messages: 1,382

I tend to ignore the OSI model. As mentioned above, it doesn't really map cleanly to how networking is actually implemented. The 5 layer model is far more useful for visualising the various levels -

1 - Physical layer - the actual cable. Could be cat5 or fibre for example
2 - Data link - Defines the format for actually sending signals across the cable and talking to other locally connected devices. In most cases will be ethernet which makes use of MAC addresses to identify hosts.
3 - Network (IP) - Method for communicating across global networks. We use IPv4 & IPv6
4 - Transport Layer (TCP/UDP) - Additional layer over the top of IP which provide things like connection management, retransmission, packet ordering, etc
5 - Application layer - the actual HTTP/DNS/SMTP/ec traffic

It's obvious to see how these are separated and can be replaced without affecting other layers. You can use IPv6 instead of IPv4, or ATM instead of Ethernet, etc.

So a server sending a webpage for example would look like the following -

Layer 5 - Web server generates http data and passes that to the OS network functions to be sent
Layer 4 - Network stack puts html data into a TCP datagram
Layer 3 - TCP data gets IP header/footer added to allow delivery over the Internet
Layer 2 - IP packet gets put into an Ethernet frame to be transferred over the local network
Layer 1 - frame gets sent over wire to next hop
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,298
Messages: 29,745

4 - Transport Layer (TCP/UDP) - Additional layer over the top of IP which provide things like connection management, retransmission, packet ordering, etc
That just shows how bad TCP/IP actually fits in these models. UDP doesn't belong here because it has no connection management, no retransmissions and no ordering.

I rarely use the OSI model, the only things I do use are layer 2, 3 and 7. Layer 2 is "on the wire" (but not the 'wire' itself), layer 3 is IP and layer 7 web or application proxies for example.
 

usdmatt

Daemon

Reaction score: 514
Messages: 1,382

To be fair my description was probably a bit off. Both TCP and UDP clearly sit at exactly the same point in the stack, just above IP, but below any application level. It seems IP was designed purely as a delivery/addressing protocol, then UDP/TCP to provide additional features on top, the most obvious being port numbers to allow multiple applications to run on the same address. That's about all UDP offers other than checksums for the data, with TCP providing more, but increased overhead with it.
 
Top