Print this page and give the answers.

Name:______________________________     Alpha:________________________________ 
  1. [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=" ")
    
    
    
    
    
  2. [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=" ")
    
    
    
    
    
  3. [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)
    
    
    
    
    
  4. [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)
    
    
    
    
    
  5. [10pts] Fill in the blanks. The OSI 7-layer model defines the fundamental layers of network communication.

    1. layer: Bits on wires.

    2. layer: Provides node-to-node data transfer between two directly connected nodes.

    3. layer: Responsible for transferring packets from one node to another connected in different networks.

    4. layer: Responsible for transferring variable-length data sequences from a source to a destination host.
    5. Session layer: Handles establishing and terminating connections between the local and remote application.

    6. Presentation layer: Transforms application data, such as encryption/decryption, to the session layer protocol data.

    7. layer: Handles all of the application data.
  6. [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
    
    1. Mark the header of the first PCAP packet in the above hexdump.
    2. Likewise, mark the data of the first PCAP packet.
    3. Likewise, mark the header of the second PCAP packet.
    4. For the first PCAP packet, which is an Ethernet frame, what is the sender's (i.e., source) MAC address?
    5. For the first packet, which is an Ethernet frame, what is the receiver's (i.e., destination) MAC address?