A packet transfer controlling apparatus comprising: a depth storage unit configured to store, in controlling transfer of a packet, a pattern indicative of a type of information to be extracted from the packet and a depth from a head of the packet, the depth being indicative of a position of the information to be extracted, and the pattern and the depth being stored in association with each other; a depth deriving unit configured to derive, when a setting of the pattern is accepted, the depth of the information to be extracted from the input packet by searching the depth storage unit based on the pattern and obtaining the depth stored in association with the pattern; an extracting unit configured to sequentially extract the information from the head of the packet when the input of the packet is accepted; and a determining unit configured to determine whether the information extracted by the extracting unit is positioned at a location deeper than the depth derived by the depth deriving unit, and control to continue the information extraction by the extracting unit when determining that the information is not yet positioned at the location deeper than the derived depth, and to end the information extraction by the extracting unit when determining that the information is positioned at the location deeper than the derived depth, wherein the depth deriving unit is configured to derive the depth for each receiving port, the determining unit is configured to determine whether the information is positioned at the location deeper than the depth derived by the depth deriving unit based on a receiving port of the information extracted by the extracting unit, and the depth deriving unit is configured to search the depth storage unit and find, for each port number, a maximum value of the depth that has been obtained from the depth storage unit and has been distributed over the port number, thereby deriving a depth for each port. a depth storage unit configured to store, in controlling transfer of a packet, a pattern indicative of a type of information to be extracted from the packet and a depth from a head of the packet, the depth being indicative of a position of the information to be extracted, and the pattern and the depth being stored in association with each other; a depth deriving unit configured to derive, when a setting of the pattern is accepted, the depth of the information to be extracted from the input packet by searching the depth storage unit based on the pattern and obtaining the depth stored in association with the pattern; an extracting unit configured to sequentially extract the information from the head of the packet when the input of the packet is accepted; and a determining unit configured to determine whether the information extracted by the extracting unit is positioned at a location deeper than the depth derived by the depth deriving unit, and control to continue the information extraction by the extracting unit when determining that the information is not yet positioned at the location deeper than the derived depth, and to end the information extraction by the extracting unit when determining that the information is positioned at the location deeper than the derived depth, wherein the depth deriving unit is configured to derive the depth for each receiving port, the determining unit is configured to determine whether the information is positioned at the location deeper than the depth derived by the depth deriving unit based on a receiving port of the information extracted by the extracting unit, and the depth deriving unit is configured to search the depth storage unit and find, for each port number, a maximum value of the depth that has been obtained from the depth storage unit and has been distributed over the port number, thereby deriving a depth for each port.