- [10pts] What is the output of the following code? Try to do it manually
(with a calculator). You will see this kind of problem in the exam.
import struct
data = struct.pack(">HB", 266, 17)
for d in data:
print(f"{d:02x}", end=" ")
- [10pts] What is the output of the following code? Try to do it manually
(with a calculator). You will see this kind of problem in the exam.
import struct
data = struct.pack("<BH", 193, 2345)
for d in data:
print(f"{d:02x}", end=" ")
- [10pts] What is the output of the following code? Try to do it manually
(with a calculator). You will see this kind of problem in the exam.
import struct
data = b'\x01\x02\x05'
unpacked = struct.unpack("<HB", data)
print(unpacked)
- [10pts] What is the output of the following code? Try to do it manually
(with a calculator). You will see this kind of problem in the exam.
import struct
data = b'\x01\x02\x05'
unpacked = struct.unpack(">BH", data)
print(unpacked)
- [10pts] Fill in the blanks. The OSI 7-layer model defines the fundamental layers of network communication.
- layer: Bits on wires.
- layer: Provides node-to-node data transfer
between two directly connected nodes.
- layer: Responsible for transferring packets
from one node to another connected in different networks.
- layer: Responsible for transferring
variable-length data sequences from a source to a destination host.
- Session layer: Handles establishing and terminating connections between the local and remote application.
- Presentation layer: Transforms application data, such as encryption/decryption, to the session layer protocol data.
- layer: Handles all of the application data.
- [20pts] Here is a hexdump of a PCAP file.
$ hexdump -C two.pcap
00000000 d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00 |................|
00000010 00 00 04 00 01 00 00 00 68 35 ba 60 d5 14 02 00 |........h5.`....|
00000020 62 00 00 00 62 00 00 00 08 00 27 f3 5a ab 08 00 |b...b...........|
00000030 27 b3 0c 12 08 00 45 00 00 54 cd 04 40 00 40 01 |......E..T..@.@.|
00000040 6f a2 7f 00 00 01 7f 00 00 01 08 00 49 80 00 01 |o...........I...|
00000050 00 01 68 35 ba 60 00 00 00 00 cb 14 02 00 00 00 |..h5.`..........|
00000060 00 00 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d |................|
00000070 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d |.. !"#$%&'()*+,-|
00000080 2e 2f 30 31 32 33 34 35 36 37 68 35 ba 60 db 14 |./01234567h5.`..|
00000090 02 00 62 00 00 00 62 00 00 00 00 00 00 00 00 00 |..b...b.........|
000000a0 00 00 00 00 00 00 08 00 45 00 00 54 cd 05 00 00 |........E..T....|
000000b0 40 01 af a1 7f 00 00 01 7f 00 00 01 00 00 51 80 |@.............Q.|
000000c0 00 01 00 01 68 35 ba 60 00 00 00 00 cb 14 02 00 |....h5.`........|
000000d0 00 00 00 00 10 11 12 13 14 15 16 17 18 19 1a 1b |................|
000000e0 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b |.... !"#$%&'()*+|
000000f0 2c 2d 2e 2f 30 31 32 33 34 35 36 37 |,-./01234567|
000000fc
- Mark the header of the first PCAP packet in the above hexdump.
- Likewise, mark the data of the first PCAP packet.
- Likewise, mark the header of the second PCAP packet.
- For the first PCAP packet, which is an Ethernet frame, what is the sender's (i.e., source) MAC address?
- For the first packet, which is an Ethernet frame, what is the receiver's (i.e., destination) MAC address?