Answers.Body: <p>You can consider an IP number to be analogous to a business's telephone number (reaching the main switchboard), and the port number to be the telephone extension number for one person. </p>
  
  <p>This probably works better when there is no direct-dial to a specific person, and the main number is handled by an automated system.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T13:32:12.240Z
Answers.Text: That's a nice point. Welcome to [cseducators.se] - I hope we hear more from you in the future!
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T13:45:02.503Z
Answers.Text: I've just noticed @Gypsy-Spellweaver 's comment to the original question, and realised that my answer is much the same.
Answers.UserDisplayName: CSM
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T13:17:47.260Z
Answers.LastActivityDate: 2017-07-02T13:17:47.260Z
Answers.UserDisplayName: CSM
Answers.Body: <p>I'd put a slight tweak on your analogy and go digital: email.</p>
  
  <p>In email, your email address is your IP address. It comes in multiple parts, similar to IP blocks. There are many addresses under one domain, there are many domains under 1 TLD.</p>
  
  <p>When a message is sent to an email address, it gets sent something pretended to the title, for example "Re" and "Fwd". That's similar to the port. They're all going to the same place, but it indicates something about the email that the computer can use to help process it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-01T23:34:44.787Z
Answers.LastActivityDate: 2017-07-01T23:34:44.787Z
Answers.UserDisplayName: thesecretmaster
Answers.Body: <p>As a former student I'd like to confess that for me these attempted analogies about the ports just made a simple thing sound mysterious and in retrospect had absolutely zero insight whatsoever.</p>
  
  <p><strong>What about saying instead that TCP/IP is just a program running on your computer like everything else and ports are just an integer in its configuration.</strong> That'd be a start.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T12:24:36.263Z
Answers.Text: Might work. Might fail. Depends on how much experience the students have.
Answers.UserDisplayName: ItamarG3
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T12:04:37.737Z
Answers.LastActivityDate: 2017-07-03T12:04:37.737Z
Answers.UserDisplayName: n611x007
Answers.Body: <p>Our department is small enough and close-knit enough that most of my students have seen the CS mail room across from the CS main office. A mail room that has a wall of slots, one for each faculty and staff in the department. I tweak the address metaphor and talk about how the mail slot is analogous to a port. Address (IP) gets the letter (packet) to the right building (computer), while the name on the address gets the letter (packet) to the right person (port/service).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-06T23:58:16.833Z
Answers.LastActivityDate: 2017-07-06T23:58:16.833Z
Answers.UserDisplayName: Lewis Baumstark
Answers.Body: <p>Using physical addresses is misleading - it would be clearer to use an email address, or a phone number. </p>
  
  <p>If people still had <a href="https://en.wikipedia.org/wiki/Plain_old_telephone_service" rel="nofollow noreferrer">POTS</a> (telephone) in the house, you have segmented (area code) dynamic addresses, and 'mum, dad, youngest child etc.' which could represent ports - which are ways of reaching the same type of person in each house.</p>
  
  <p>With this analogy, you can explain that people's phone number sometimes changes (but doesn't have to, even if they move location), and there are many different ways of addressing a set of people who might be in a house. Depending on who is at home, a different person might actually handle any specific call.</p>
  
  <p>When someone places an outgoing call, you'd see which house the call was coming from, but not who (until they identify themselves).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T15:14:43.307Z
Answers.Text: I don't understand. What are POTS? I mean, other than stovetop items.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T15:16:44.297Z
Answers.Text: Is it clear enough with that edit?
Answers.UserDisplayName: Sean Houlihane
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T15:18:01.460Z
Answers.Text: Yes, thank you :) I grew up with one (still have one, actually), but never knew it was called that.
Answers.UserDisplayName: Ben I.
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T15:04:41.337Z
Answers.LastActivityDate: 2017-07-03T15:16:14.107Z
Answers.LastEditDate: 2017-07-03T15:16:14.107Z
Answers.UserDisplayName: Sean Houlihane
Answers.Body: <p>How about IP addresses being countries and ports being sea ports? </p>
  
  <p>In the UK it works well because there are so many different sea ports that students recognise from looking at an online map of the British Isles. </p>
  
  <p>You can extend the metaphor by talking about firewalls blocking off access to ports (e.g. sea blockades during WWII) or increasing security by removing external access (landlocked countries don't need to worry about sea invasion). </p>
  
  <p>The main advantage over an address / flat number analogy is that you can extend it by talking about different types of ports (e.g. airports) for different protocols (e.g. UDP / TCP) with various implications for speed / reliability.</p>
  
  <p>No analogy is perfect though - students who want to understand it fully should have experience using or hosting different services on the same server.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T15:43:22.247Z
Answers.Text: This seems confusing. If a sea port like Liverpool is analogous to anything in networking I would expect it to be an interface, rather than a port.
Answers.UserDisplayName: bdsl
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-03T11:36:59.917Z
Answers.Text: I could see this going badly in parts of the US, where some students may be only dimly aware that there are such things as oceans (or other countries)
Answers.UserDisplayName: David Z
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T14:02:04.423Z
Answers.LastActivityDate: 2017-07-02T14:02:04.423Z
Answers.UserDisplayName: pddring
Answers.Body: <p>I don't think the address metaphor is that off-the-mark -- real addresses are more segmented then IP addresses, true, but I don't know if that's really that much of a conceptual barrier.</p>
  
  <p>Regarding ports, I would tweak your metaphor slightly -- a port is more like an apartment number, rather then the apartment itself. That is, the port just serves as an additional piece of information that's a part of your overall address, and can be used to route the mail to the appropriate apartment resident once your mail arrives. </p>
  
  <p>(I guess to extend the metaphor, the people who live in the apartments are programs, and whoever sorts the mail at the apartment is like the operating system.)</p>
  
  <p>What might also help is to explain that at the end of the day, a port is literally just a 16 bit int, nothing more, and that it's up to the receiving computer to do something reasonable with that number. If you emphasize that a port is just a number, it might make it a little easier for your students to independently derive what exactly you can and can't do with ports. After all, there are only so many things you can do with a single piece of metadata.</p>
  
  <p>An alternative/complementary approach might be to focus less on metaphors and instead focus on motivating why we'd need ports in the first place. I'd personally start from the top down, and explain things like this:</p>
  
  <ol>
  <li>Start by explaining how IP addresses are used to route packets.</li>
  <li><p>Explain that once a computer finally receives a packet, we're still not done: the operating system need to figure out which currently-running program to give it to, if at all.</p>
  
  <p>This might also be a good moment to ask your students to discuss and try coming up with a solution themselves -- hopefully, most of them will independently realize they need to include metadata of some kind. You can turn this into a mini-design lesson: an ideal solution should be simple, minimizes packet size, is future-proof, flexible, doesn't break the transport layer abstraction...</p></li>
  <li><p>Tell them about ports, and explain that was the solution people ended up coming up with. </p></li>
  </ol>
  
  <p>The hope is that focusing more on motivation will allow your students to acquire a reasonable conceptual model of how network protocols tend to work, even if they forget the exact details.</p>
  
  <p>I think this approach also does a better job of answering the implicit "why?" question people have when learning new things. (Why ports? Why IP addresses? Why TCP? Why abstract things like this? Why is everything so complicated? etc.) Basically, confront it head-on by presenting things in a problem/motivation -> solution approach.</p>
  
  <p>Caveat: this approach might just be a reflection of how I personally like learning things, so YMMV.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T04:17:46.863Z
Answers.Text: Concurring: port is the apartment number, not the apartment. The apartment dweller has to do something with the delivered mail, akin to the program listening at that port. My success with the apartment building:number::IP:port analogy increased when I started showing pictures of a bank of mailboxes: https://sep.yimg.com/ay/yhst-14044557065217/16-door-cluster-mailbox-sandstone-182.jpg
Answers.UserDisplayName: Bennett Brown
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T10:51:04.363Z
Answers.Text: Why can we ping only houses, not appartments? In other words, a good metaphor would need good counterparts for TCP vs. UDP vs. IP. To begin with, there is in principle no relation between UDP port x and TCP port x (even if, e.g., DNS uses both UDP port 53 and TCP 53); even the fact that their number ranges are the same is not a principal necessity. My point is: Why try to use a metaphor at all to cover every aspect and detail, when pairs of numbers are a simple concept?
Answers.UserDisplayName: Hagen von Eitzen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T00:33:26.017Z
Answers.LastActivityDate: 2017-07-02T00:49:10.163Z
Answers.LastEditDate: 2017-07-02T00:49:10.163Z
Answers.UserDisplayName: Michael0x2a
Answers.Body: <p>I used seats in the room. </p>
  
  <p>The classroom has an address. So, if someone wanted to come and talk to one of the students they would come down the hall and into my room. </p>
  
  <p>But, that only gets them to the room (server). They need to talk to a specific person, so they go to seat 17 so they can talk to Bob. </p>
  
  <p>So Bob's socket is <code>room.123:17</code>. </p>
  
  <p>I tried once to continue and the floor became cable runs, each hallway was a subnet, the corners were routers, and the school map was DNS. That pushed it a little too far :)</p>
  
  <p>Did find though that most kids had at least a passing understanding of ports. Most of them had opened ports on their home routers to play games over the internet. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T04:13:07.660Z
Answers.Text: Seats! Love it. The person in the seat is like the program registered with the OS to listen at that port. The analogy gets at the idea that programs at a port may or may not be the port's usual ilstener (students sit in the wrong seat), might not be running (absent student), and that programs might have assumptions they make about incoming packets. If a love note for Barb at 121:2 is sent to Alice at 121:1, who knows what Alice will do with it? Ignore it? Return receipt reporting incorrect delivery? Respond in a way that noone who knows Alice would have expected?
Answers.UserDisplayName: Bennett Brown
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T14:33:45.777Z
Answers.Text: @BennettBrown That's even better. Bob and Sue switched seats because there's a substitute and now Bob doesn't get his message.
Answers.UserDisplayName: Ryan Nutt
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-02T00:33:14.727Z
Answers.LastActivityDate: 2017-07-02T00:33:14.727Z
Answers.UserDisplayName: Ryan Nutt
Body: <p>What would be a good way to describe ports?  I learned about it using this analogy, but it seems pretty inadequate to me:</p>
  
  <p><em>IP addresses are like street addresses of apartment buildings, and ports are like the apartments therein.</em></p>
  
  <p>IP addresses are not segmented as a street address is, and second, apartments don't seem at all analogous to ports in terms of behavior.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-02T03:13:55.247Z
Comments.Text: I don't know how many times I've seen the IP address compared to a phone number, with the DNS being the phone book. To add ports to that, just add extensions to the phone number. Extensions that are standardized so you always know which extension to connect to for some department. The web department is normally extension 80, the email department uses extension 25. If you have an encrypted phone then you used different extensions.
Comments.UserDisplayName: Gypsy Spellweaver
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-02T10:43:58.000Z
Comments.Text: Analogies are like shoes ... they do not always fit perfectly.
Comments.UserDisplayName: Hagen von Eitzen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-02T19:41:15.113Z
Comments.Text: The apartment street address vs. apartment number is the analogy I use, and it seems to work. Anything could work though - buildings and room numbers, classrooms and seats, pbx and extensions (this may add confusion) - as long as it references one destination with service dependent on who is contacted at that destination
Comments.UserDisplayName: ivanivan
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-07T18:13:19.273Z
Comments.Text: Phone numbers also have the name<->number mapping in form of telephone books (which may be a thing of the past though).
Comments.UserDisplayName: Thorbjørn Ravn Andersen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-07-08T03:08:33.607Z
Comments.Text: why use an analogy? I would maybe use an analogy to explain it to someone not interested in computers to give them a quick idea of what it's for, but if you're actually teaching someone about IP addresses and ports, I don't see how an analogy helps, just tell them how it works. An analogy might actually be counter-productive, in fact.
Comments.UserDisplayName: Dave Cousineau
Tags: <teaching-analogy><networks>
Title: What would be a good analogy for IP addresses and ports?
ThreadText: # What would be a good analogy for IP addresses and ports?
  
  (Asked by: username_0 on 2017-07-01)
  
  What would be a good way to describe ports? I learned about it using this analogy, but it seems pretty inadequate to me:
  
  *IP addresses are like street addresses of apartment buildings, and ports are like the apartments therein.*
  
  IP addresses are not segmented as a street address is, and second, apartments don't seem at all analogous to ports in terms of behavior.
  
  **Tags:** teaching-analogy, networks
  
  > **Comments:**
  > **username_1**: I don't know how many times I've seen the IP address compared to a phone number, with the DNS being the phone book. To add ports to that, just add extensions to the phone number. Extensions that are standardized so you always know which extension to connect to for some department. The web department is normally extension 80, the email department uses extension 25. If you have an encrypted phone then you used different extensions.  
  > **username_2**: Analogies are like shoes ... they do not always fit perfectly.  
  > **username_3**: The apartment street address vs. apartment number is the analogy I use, and it seems to work. Anything could work though - buildings and room numbers, classrooms and seats, pbx and extensions (this may add confusion) - as long as it references one destination with service dependent on who is contacted at that destination  
  > **username_4**: Phone numbers also have the name<->number mapping in form of telephone books (which may be a thing of the past though).  
  > **username_5**: why use an analogy? I would maybe use an analogy to explain it to someone not interested in computers to give them a quick idea of what it's for, but if you're actually teaching someone about IP addresses and ports, I don't see how an analogy helps, just tell them how it works. An analogy might actually be counter-productive, in fact.  
  
  ---
  
  ## 8 answers
  
  ### Answer by username_15 on 2017-07-02. Score: 9 | Accepted answer
  
  I don't think the address metaphor is that off-the-mark -- real addresses are more segmented then IP addresses, true, but I don't know if that's really that much of a conceptual barrier.
  
  Regarding ports, I would tweak your metaphor slightly -- a port is more like an apartment number, rather then the apartment itself. That is, the port just serves as an additional piece of information that's a part of your overall address, and can be used to route the mail to the appropriate apartment resident once your mail arrives.
  
  (I guess to extend the metaphor, the people who live in the apartments are programs, and whoever sorts the mail at the apartment is like the operating system.)
  
  What might also help is to explain that at the end of the day, a port is literally just a 16 bit int, nothing more, and that it's up to the receiving computer to do something reasonable with that number. If you emphasize that a port is just a number, it might make it a little easier for your students to independently derive what exactly you can and can't do with ports. After all, there are only so many things you can do with a single piece of metadata.
  
  An alternative/complementary approach might be to focus less on metaphors and instead focus on motivating why we'd need ports in the first place. I'd personally start from the top down, and explain things like this:
  
  1. Start by explaining how IP addresses are used to route packets.
  2. Explain that once a computer finally receives a packet, we're still not done: the operating system need to figure out which currently-running program to give it to, if at all.
  
     This might also be a good moment to ask your students to discuss and try coming up with a solution themselves -- hopefully, most of them will independently realize they need to include metadata of some kind. You can turn this into a mini-design lesson: an ideal solution should be simple, minimizes packet size, is future-proof, flexible, doesn't break the transport layer abstraction...
  3. Tell them about ports, and explain that was the solution people ended up coming up with.
  
  The hope is that focusing more on motivation will allow your students to acquire a reasonable conceptual model of how network protocols tend to work, even if they forget the exact details.
  
  I think this approach also does a better job of answering the implicit "why?" question people have when learning new things. (Why ports? Why IP addresses? Why TCP? Why abstract things like this? Why is everything so complicated? etc.) Basically, confront it head-on by presenting things in a problem/motivation -> solution approach.
  
  Caveat: this approach might just be a reflection of how I personally like learning things, so YMMV.
  
  > **Comments:**
  > **username_16**: Concurring: port is the apartment number, not the apartment. The apartment dweller has to do something with the delivered mail, akin to the program listening at that port. My success with the apartment building:number::IP:port analogy increased when I started showing pictures of a bank of mailboxes: https://sep.yimg.com/ay/yhst-14044557065217/16-door-cluster-mailbox-sandstone-182.jpg  
  > **username_2**: Why can we ping only houses, not appartments? In other words, a good metaphor would need good counterparts for TCP vs. UDP vs. IP. To begin with, there is in principle no relation between UDP port x and TCP port x (even if, e.g., DNS uses both UDP port 53 and TCP 53); even the fact that their number ranges are the same is not a principal necessity. My point is: Why try to use a metaphor at all to cover every aspect and detail, when pairs of numbers are a simple concept?  
  
  ---
  
  ### Answer by username_17 on 2017-07-02. Score: 12
  
  I used seats in the room.
  
  The classroom has an address. So, if someone wanted to come and talk to one of the students they would come down the hall and into my room.
  
  But, that only gets them to the room (server). They need to talk to a specific person, so they go to seat 17 so they can talk to Bob.
  
  So Bob's socket is `room.123:17`.
  
  I tried once to continue and the floor became cable runs, each hallway was a subnet, the corners were routers, and the school map was DNS. That pushed it a little too far :)
  
  Did find though that most kids had at least a passing understanding of ports. Most of them had opened ports on their home routers to play games over the internet.
  
  > **Comments:**
  > **username_16**: Seats! Love it. The person in the seat is like the program registered with the OS to listen at that port. The analogy gets at the idea that programs at a port may or may not be the port's usual ilstener (students sit in the wrong seat), might not be running (absent student), and that programs might have assumptions they make about incoming packets. If a love note for Barb at 121:2 is sent to Alice at 121:1, who knows what Alice will do with it? Ignore it? Return receipt reporting incorrect delivery? Respond in a way that noone who knows Alice would have expected?  
  > **username_17**: @username_16 That's even better. Bob and Sue switched seats because there's a substitute and now Bob doesn't get his message.  
  
  ---
  
  ### Answer by username_6 on 2017-07-02. Score: 4
  
  You can consider an IP number to be analogous to a business's telephone number (reaching the main switchboard), and the port number to be the telephone extension number for one person.
  
  This probably works better when there is no direct-dial to a specific person, and the main number is handled by an automated system.
  
  > **Comments:**
  > **username_0**: That's a nice point. Welcome to [cseducators.se] - I hope we hear more from you in the future!  
  > **username_6**: I've just noticed @username_1 's comment to the original question, and realised that my answer is much the same.  
  
  ---
  
  ### Answer by username_7 on 2017-07-01. Score: 2
  
  I'd put a slight tweak on your analogy and go digital: email.
  
  In email, your email address is your IP address. It comes in multiple parts, similar to IP blocks. There are many addresses under one domain, there are many domains under 1 TLD.
  
  When a message is sent to an email address, it gets sent something pretended to the title, for example "Re" and "Fwd". That's similar to the port. They're all going to the same place, but it indicates something about the email that the computer can use to help process it.
  
  
  ---
  
  ### Answer by username_8 on 2017-07-03. Score: 2
  
  As a former student I'd like to confess that for me these attempted analogies about the ports just made a simple thing sound mysterious and in retrospect had absolutely zero insight whatsoever.
  
  **What about saying instead that TCP/IP is just a program running on your computer like everything else and ports are just an integer in its configuration.** That'd be a start.
  
  > **Comments:**
  > **username_9**: Might work. Might fail. Depends on how much experience the students have.  
  
  ---
  
  ### Answer by username_10 on 2017-07-06. Score: 1
  
  Our department is small enough and close-knit enough that most of my students have seen the CS mail room across from the CS main office. A mail room that has a wall of slots, one for each faculty and staff in the department. I tweak the address metaphor and talk about how the mail slot is analogous to a port. Address (IP) gets the letter (packet) to the right building (computer), while the name on the address gets the letter (packet) to the right person (port/service).
  
  
  ---
  
  ### Answer by username_11 on 2017-07-03. Score: 1
  
  Using physical addresses is misleading - it would be clearer to use an email address, or a phone number.
  
  If people still had [POTS](https://en.wikipedia.org/wiki/Plain_old_telephone_service) (telephone) in the house, you have segmented (area code) dynamic addresses, and 'mum, dad, youngest child etc.' which could represent ports - which are ways of reaching the same type of person in each house.
  
  With this analogy, you can explain that people's phone number sometimes changes (but doesn't have to, even if they move location), and there are many different ways of addressing a set of people who might be in a house. Depending on who is at home, a different person might actually handle any specific call.
  
  When someone places an outgoing call, you'd see which house the call was coming from, but not who (until they identify themselves).
  
  > **Comments:**
  > **username_0**: I don't understand. What are POTS? I mean, other than stovetop items.  
  > **username_11**: Is it clear enough with that edit?  
  > **username_0**: Yes, thank you :) I grew up with one (still have one, actually), but never knew it was called that.  
  
  ---
  
  ### Answer by username_12 on 2017-07-02. Score: 1
  
  How about IP addresses being countries and ports being sea ports?
  
  In the UK it works well because there are so many different sea ports that students recognise from looking at an online map of the British Isles.
  
  You can extend the metaphor by talking about firewalls blocking off access to ports (e.g. sea blockades during WWII) or increasing security by removing external access (landlocked countries don't need to worry about sea invasion).
  
  The main advantage over an address / flat number analogy is that you can extend it by talking about different types of ports (e.g. airports) for different protocols (e.g. UDP / TCP) with various implications for speed / reliability.
  
  No analogy is perfect though - students who want to understand it fully should have experience using or hosting different services on the same server.
  
  > **Comments:**
  > **username_13**: This seems confusing. If a sea port like Liverpool is analogous to anything in networking I would expect it to be an interface, rather than a port.  
  > **username_14**: I could see this going badly in parts of the US, where some students may be only dimly aware that there are such things as oceans (or other countries)  
  
  ---
  
  