HW 11: Network Addressing
Instructions
- You must turn in a sheet of paper that is neatly typed or written answering the questions below. (You are strongly encouraged to type your homework.)
- This homework is graded out of 90 points. Point values are associated to each question.
Questions
- (5 points) What are the two parts of a packet? Which stores the address and what stores the data?
- (5 points) What does it mean for the Internet to be "packet switched"?
- (5 points) What are the different layers of the protocol stack and what purpose do they serve in delivering a packet?
- (5 points) An Internet address (version 4) is stored in how many bytes?
- (5 points) A domain name, unlike an IP address, is more human usable, what protocol enables domain names to be resolved into IP addresses?
- (15 points) Using the
host
command line tool, resolve the following domain names to an IPv4 address(es). Indicate those that also have IPv6 addresses, and also, rerun host a few times, indicate which hosts IP addressed changed on subsequent runs.www.cis.upenn.edu
www.cs.swarthmore.edu
www.usna.edu
facebook.com
microsoft.com
- (5 points) What is the purpose of the port address? How many bytes and what C type would naturally store a port address?
- (5 points) TCP provides reliable data transmission, but at what cost? Why might you want to use UDP over TCP?
- (20 points) For each of the descriptions below of a network type, indicate
the type that best matches that description. Options include:
struct in_addr
,in_addr_t
,s_addr
,struct sockaddr
,struct sockaddr_in
,sin_family
,sin_port
,sin_addr
,struct addrinfo
,ai_family
,ai_addr
.- Specifies the address type, e.g.,
AF_INET
, for theaddrinfo
structure. - Specifies the addres type, e.g.,
AF_INET
, for thesockaddr_in
structure. - A type defined as a
uint32
- A generic address structure for sockets
- A structure to store an IPv4 Internet address
- An unsigned short storing the port for a
sockaddr_in
- Structure used to hint at IP addresses for resolving as well as storing results.
- Member of the
sockaddr_in
that stores the address - The sole member of the
in_addr
structure - A generic socket address returned in a
addrinfo
- A specific address structure for sockets to store IP, port pairs
- Specifies the address type, e.g.,
- (5 points) The following functions are opposites,
inet_ntoa()
andinet_aton()
, what are their purposes? Provide a small example. - (5 points) When assign a port to a socket address, which of these two
conversion should you use and why?
htnos()
vs.nths()
. (10 points) Consider setting the address 10.4.32.41 on port 22. Complete the code below to do that.
struct sockaddr_in saddr; //TODO: what assignments come next?