Contents

Dhcp

Scenario: create a DHCP Ack

  • When I create a packet with:
      Pio::Dhcp::Ack.new(
        source_mac: 'aa:bb:cc:dd:ee:ff',
        destination_mac: '11:22:33:44:55:66',
        source_ip_address: '192.168.0.10',
        destination_ip_address: '192.168.0.1',
        transaction_id: 0xdeadbeef,
        renewal_time_value: 0xdeadbeef,
        rebinding_time_value: 0xdeadbeef,
        ip_address_lease_time: 0xdeadbeef,
        subnet_mask: '255.255.255.0'
      )
  • Then the packet has the following fields and values:
    fieldvalue
    classPio::Dhcp::Ack
    destination_mac11:22:33:44:55:66
    source_macaa:bb:cc:dd:ee:ff
    ether_type2048
    ip_version4
    ip_header_length5
    ip_type_of_service0
    ip_total_length328
    ip_identifier0
    ip_flag0
    ip_fragment0
    ip_ttl128
    ip_protocol17
    ip_header_checksum47177
    source_ip_address192.168.0.10
    destination_ip_address192.168.0.1
    udp_source_port67
    udp_destination_port68
    udp_length308
    udp_checksum7012
    message_type5
    hw_addr_type1
    hw_addr_len6
    hops0
    transaction_id3735928559
    seconds0
    bootp_flags0
    client_ip_address0.0.0.0
    your_ip_address192.168.0.1
    next_server_ip_address0.0.0.0
    relay_agent_ip_address0.0.0.0
    client_mac_addressaa:bb:cc:dd:ee:ff
    subnet_mask255.255.255.0
    server_identifier192.168.0.10
    renewal_time_value3735928559
    rebinding_time_value3735928559
    ip_address_lease_time3735928559

Scenario: create a DHCP Discover

  • When I create a packet with:
      Pio::Dhcp::Discover.new(
        source_mac: '24:db:ac:41:e5:5b',
        transaction_id: 0xdeadbeef
      )
  • Then the packet has the following fields and values:
    fieldvalue
    classPio::Dhcp::Discover
    destination_macff:ff:ff:ff:ff:ff
    source_mac24:db:ac:41:e5:5b
    ether_type2048
    ip_version4
    ip_header_length5
    ip_type_of_service0
    ip_total_length328
    ip_identifier0
    ip_flag0
    ip_fragment0
    ip_ttl128
    ip_protocol17
    ip_header_checksum14758
    source_ip_address0.0.0.0
    destination_ip_address255.255.255.255
    udp_source_port68
    udp_destination_port67
    udp_length308
    udp_checksum34836
    message_type1
    hw_addr_type1
    hw_addr_len6
    hops0
    transaction_id3735928559
    seconds0
    bootp_flags0
    client_ip_address0.0.0.0
    your_ip_address0.0.0.0
    next_server_ip_address0.0.0.0
    relay_agent_ip_address0.0.0.0
    client_mac_address24:db:ac:41:e5:5b
    parameters_list[1, 3, 6, 42]
    client_identifier24:db:ac:41:e5:5b

Scenario: create a DHCP Request

  • When I create a packet with:
      Pio::Dhcp::Request.new(
        source_mac: '24:db:ac:41:e5:5b',
        transaction_id: 0xdeadbeef,
        server_identifier: '192.168.0.1',
        requested_ip_address: '192.168.0.10'
      )
  • Then the packet has the following fields and values:
    fieldvalue
    classPio::Dhcp::Request
    destination_macff:ff:ff:ff:ff:ff
    source_mac24:db:ac:41:e5:5b
    ether_type2048
    ip_version4
    ip_header_length5
    ip_type_of_service0
    ip_total_length328
    ip_identifier0
    ip_flag0
    ip_fragment0
    ip_ttl128
    ip_protocol17
    ip_header_checksum14758
    source_ip_address0.0.0.0
    destination_ip_address255.255.255.255
    udp_source_port68
    udp_destination_port67
    udp_length308
    udp_checksum52915
    message_type3
    hw_addr_type1
    hw_addr_len6
    hops0
    transaction_id3735928559
    seconds0
    bootp_flags0
    client_ip_address0.0.0.0
    your_ip_address0.0.0.0
    next_server_ip_address0.0.0.0
    relay_agent_ip_address0.0.0.0
    client_mac_address24:db:ac:41:e5:5b
    parameters_list[1, 3, 6, 42]
    client_identifier24:db:ac:41:e5:5b
    requested_ip_address192.168.0.10

Scenario: create a DHCP Offer

  • When I create a packet with:
      Pio::Dhcp::Offer.new(
        source_mac: 'aa:bb:cc:dd:ee:ff',
        destination_mac: '11:22:33:44:55:66',
        source_ip_address: '192.168.0.10',
        destination_ip_address: '192.168.0.1',
        transaction_id: 0xdeadbeef,
        renewal_time_value: 0xdeadbeef,
        rebinding_time_value: 0xdeadbeef,
        ip_address_lease_time: 0xdeadbeef,
        subnet_mask: '255.255.255.0'
      )
  • Then the packet has the following fields and values:
    fieldvalue
    classPio::Dhcp::Offer
    destination_mac11:22:33:44:55:66
    source_macaa:bb:cc:dd:ee:ff
    ether_type2048
    ip_version4
    ip_header_length5
    ip_type_of_service0
    ip_total_length328
    ip_identifier0
    ip_flag0
    ip_fragment0
    ip_ttl128
    ip_protocol17
    ip_header_checksum47177
    source_ip_address192.168.0.10
    destination_ip_address192.168.0.1
    udp_source_port67
    udp_destination_port68
    udp_length308
    udp_checksum7780
    message_type2
    hw_addr_type1
    hw_addr_len6
    hops0
    transaction_id3735928559
    seconds0
    bootp_flags0
    client_ip_address0.0.0.0
    your_ip_address192.168.0.1
    next_server_ip_address0.0.0.0
    relay_agent_ip_address0.0.0.0
    client_mac_addressaa:bb:cc:dd:ee:ff
    subnet_mask255.255.255.0
    server_identifier192.168.0.10
    renewal_time_value3735928559
    rebinding_time_value3735928559
    ip_address_lease_time3735928559

Scenario: parse dhcp.pcap

  • Then I parse a file named "dhcp.pcap" with "Pio::Dhcp" class

Source: features/dhcp.feature at commit 40dd0fb6, Pio (GPL license).