👨‍💻
Guide
Laura's GithubSimon's Github
  • What is this gitbook for?
  • 🛠️Useful tools
    • 🏁Header files
    • 🧱C Structures
    • 🔗Linked Lists (todo)
    • 📄Makefiles
    • 🔄Switch statement
    • 🗃️File descriptors (FD)
  • 🖌️MiniLibX
    • MiniLibX Helper Function
    • MiniLibX Hook Examples
  • 0️⃣ Rank 00
    • Libft
      • 📑LIBC functions
        • ft_isalpha
        • ft_isdigit
        • ft_isalnum
        • ft_isascii
        • ft_isprint
        • ft_strlen
        • ft_memset
        • ft_bzero
        • ft_memcpy
        • ft_memmove
        • ft_strlcpy
        • ft_strlcat
        • ft_toupper
        • ft_tolower
        • ft_strchr
        • ft_strrchr
        • ft_strncmp
        • ft_memchr
        • ft_memcmp
        • ft_strnstr
        • ft_atoi
        • ft_calloc
        • ft_strdup
      • 📑Additional functions
        • ft_substr
        • ft_strjoin
        • ft_strtrim
        • ft_split
        • ft_itoa
        • ft_strmapi
        • ft_striteri
        • ft_putchar_fd
        • ft_putstr_fd
        • ft_putendl_fd
        • ft_putnbr_fd
      • 📑Bonus functions
        • ft_lstnew
        • ft_lstadd_front
        • ft_lstsize
        • ft_lstlast
        • ft_lstadd_back
        • ft_lstdelone
        • ft_lstclear
        • ft_lstiter
        • ft_lstmap
  • 1️⃣ Rank 01
    • Born2beRoot
      • 📠What's a virtual machine ?
      • 📠Install your virtual machine
      • 📠P2P Evaluation - Questions
    • ft_printf
      • ▪️Variadic functions
      • ▪️Building the thing
    • get_next_line
      • ▪️open() & read()
      • ▪️Static variables
      • ▪️Building the thing
      • ▪️Commented solution
  • 2️⃣ Rank 02
    • so_long
      • ▪️Understand so_long
      • ▪️Core concepts
      • ▪️Building the thing
    • pipex
      • ▪️Understand pipex
      • ▪️Functions used
      • ▪️Building the thing
    • minitalk
      • ▪️Understand minitalk
      • ▪️Functions used
      • ▪️Building the thing
    • push_swap
      • ▪️Algorithms
      • ◾Building the thing
    • FdF
      • 🗡️Understand FdF
      • 🗡️Graphics programming
      • 🗡️Building the thing
  • 3️⃣ RANK 03
    • Philosophers
      • ▪️Understand Philosophers
      • ▪️Functions used
      • ▪️Building the thing
    • Minishell
      • ▪️Understand Minishell
      • ▪️Functions
      • ◾Building the thing
  • 4️⃣ RANK 04
    • CPP (00 - 04) (doing)
      • CPP00
      • CPP01
      • CPP02
      • CPP03
      • CPP04 (doing)
    • NetPractice
      • Theory
      • Level 1 & 2
    • MiniRT
      • Understand MiniRT
      • Building the thing
  • 5️⃣ RANK 05
    • CPP (05-09) (to-do)
      • CPP05
      • CPP06 (to-do)
      • CPP07
      • CPP08 (to-do)
      • CPP09 (to-do)
    • Inception (doing)
      • 🕓The basics (Docker, Images, etc...)
      • Project Files
    • webserv (to-do)
  • 6️⃣ rank 06
    • ft_transcendence (to-do)
  • 🛂Exams
    • Exam Rank 02
      • Level 1
        • first_word
        • fizz_buzz
        • *ft_putstr
        • *ft_strcpy
        • *ft_strlen
        • ft_swap
        • repeat_alpha
        • rev_print
        • rot_13
        • rotone
        • search_and_replace
        • ulstr
      • Level 2
        • alpha_mirror
        • camel_to_snake
        • do_op
        • *ft_atoi
        • *ft_strcmp
        • ft_strcspn
        • ft_strspn
        • *ft_strdup
        • ft_strpbrk
        • ft_strrev
        • inter
        • last_word
        • ft_is_power_2
        • max
        • print_bits
        • reverse_bits
        • wdmatch
        • swap_bits
        • union
        • snake_to_camel
      • Level 3
        • add_prime_sum
        • epur_str
        • expand_str
        • ft_atoi_base
        • ft_list_size
        • ft_range
        • ft_rrange
        • hidenp
        • lcm
        • paramsum
        • pgcd
        • print_hex
        • rstr_capitalizer
        • str_capitalizer
        • tab_mult
      • Level 4
        • flood_fil
        • fprime
        • ft_split
        • ft_itoa
        • ft_list_foreach
        • ft_list_remove
        • rev_wstr
        • rotstring
        • sort_int_tab
        • sort_list
    • Exam Rank 03
    • Exam Rank 04
    • Exam Rank 05
      • Module 0
  • 👥Team
Powered by GitBook
On this page
  • 0.1 How to find the IP (from one mask & one IP)
  • 0.2 How to find a subnet mask (from one IP and one mask)
  • Level 1 : Simple case
  • Level 2 : Masks are a bit modified

Was this helpful?

  1. 4️⃣ RANK 04
  2. NetPractice

Level 1 & 2

PreviousTheoryNextMiniRT

Last updated 1 year ago

Was this helpful?

Let's go level by level and try to ask ourselves the right questions to solve each exercise.

PS: Don't check the answers immediately. Otherwise you will not learn anything and you'll have a hard time during your evaluation

0.1 How to find the IP (from one mask & one IP)

Find the IP of one machine (Interface 2) using its mask and the IP of the other machine (Interface 1).

  • Convert the IP address and subnet mask to binary.

Interface 1 IP address: 192.168.25.222 -> 11000000.10101000.00011001.11011110 Interface 2 subnet mask: 255.255.255.224 -> 11111111.11111111.11111111.11100000

  • Perform the bitwise "AND" operation between each corresponding bit of the IP address and the subnet mask.

11000000.10101000.00011001.11011110 11111111.11111111.11111111.11100000 = 11000000.10101000.00011001.11000000

  • Convert the binary result back to decimal notation.

--> Thus, the IP address of interface 2 could be 192.168.25.192, assuming the provided subnet mask is applicable to the network configuration in this specific context.

Now, regarding the address range, with a subnet mask of 255.255.255.224 (or /27), . In this case, the address range would be 192.168.25.192 to 192.168.25.223.

It's important to note that every IP address in this range is considered valid for interface 2, as long as it's not already in use by another interface or device on the network.

So, if you mark the response 192.168.25.194, this would also be a valid IP address for interface 2, as it's within the range of addresses available with the given subnet mask.

0.2 How to find a subnet mask (from one IP and one mask)

To find the subnet mask of interface 2 from the IP address of interface 1 and the IP address of interface 2, you can follow these steps:

  • Convert both IP addresses to binary.

Interface 1 IP address: 192.168.25.222 -> 11000000.10101000.00011001.11011110 Interface 2 IP address: 192.168.25.192 -> 11000000.10101000.00011001.11000000

  • Compare the bits of the IP address of interface 1 and the IP address of interface 2

IF1: 11000000.10101000.00011001.11011110 IF2: 11000000.10101000.00011001.11000000

Start with the most significant bit (from left to right) and compare each corresponding bit of the two IP addresses. Find the first instance where the bits differ between the two IP addresses.

From this point onwards, all subsequent bits must be set to 0 in the subnet mask.

= 11111111.11111111.11111111.00000000

In this case, the longest sequence of consecutive 1 bits is "24 bits".

  • Convert this sequence of bits to decimal notation.

Interface 2 subnet mask: 255.255.255.0

Thus, the subnet mask of interface 2 would be 255.255.255.0, assuming the provided IP addresses correspond to a valid network configuration in this specific context.

Let's put what we've just learned into practice :)

Level 1 : Simple case

The aim is to connect one computer with another, twice.

Here we have two separate networks, each consisting of two computers. Try to find their IP using the first method that I told you.

To find the IP address of interface A1, you need to use the mask of A1 and the IP address of B1.

Level 2 : Masks are a bit modified

Here we have two separate networks, each consisting of two computers.

the available address range is 30 addresses
NetPractice : Level 1
Level 1 Example