Week 12
Students are expected to attempt ALL of the questions in the Multi choice, Short answer and Lab quesitons. They will be discussed and marked at the beginning of the lab.Multi choice
| Question: Which of the below are NOT advantages of memory paging and segmentation? | A) It saves memory B) It adds security C) It increases memory size D) It adds reliability |
| Question: What is the hexadecimal number associated with the IP address 192.168.1.95? | A) 0xC0A8015F B) 0x5F01A8C0 C) 0xF5108A0C D) 0x0C8A10F5 |
| Question: What is the IP address associated with the hexadecimal number 0x0A013D36? | A) 160.16.211.99 B) 10.1.61.54 C) 162.212.16.100 D) 192.168.1.45 |
Short answer
Question: What are three advantages or disadvantages of using the UDP network protocol?Question: What are three advantages or disadvantages of using the TCP network protocol?
Lab questions
Excercise:IP Addresses
An IP address is an unsigned 32-bit integer. Because internet hosts can have different host byte ordering (remember talking about big and little endian machines!) TCP/IP defines a uniform network byte ordering. Unix provides functions htonl(), htons(), ntohl(), ntohs() to convert between network and host byte order.- Use man pages to determine what each of the above functions do.
- partch is a machine on the student network. Using one of the above functions to write a short (~10 line) C program to determine which byte ordering this machine uses.
- Is network byte ordering big or little endian?
- Complete the following table (assuming network byte ordering):
Hex Address Dotted-decimal address 0x0 _______________ 0xffffffff _______________ 0xef000001 _______________ _______________ 205.188.160.121 _______________ 64.12.149.13 _______________ 150.203.24.4 - Write a program hex2dd.c that converts its hex command line
argument to a dotted-decimal string and prints out the result.
Hint: use the "%x" format specifier in sscanf(), consulting
the man pages for this function and inet_ntop().
You can compile it with gcc -o hex2dd hex2dd.c -lnsl.
$ ./hex2dd 0x8002c2f2 128.2.194.242 - Write a program dd2hex.c that converts its
dotted-decimal argument to hex and prints out the result
$ ./dd2hex 128.2.194.242 0x8002c2f2 - Note that if you recompile and run these programs on a system with different endians,
you get different hex numbers generated. However, combining the
conversions should give the same result on either host:
$ ./hex2dd `./dd2hex 128.2.194.242` 128.2.194.242
In-class Group Task
Get into groups of 4 people. Two of the group members should write a server program on one computer and the other two should write a client on another computer. The aim is to get across a secret message of at least 20 characters from the server end to the client end without speaking to each other, apart from vital information such as the IP address and port number for the server.When you have achieved this, there will be a class discussion about the methods people used.
If there is still time left, modify your programs so that you can send files from the server to the client. This will be simpler if you first send an integer representing how large the file is, then receive that many bytes.


