{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "2aef32413fa5421964c19ca2155ff144",
     "grade": false,
     "grade_id": "cell-fdd9aaf71771f5cc",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "\n",
    "<h1>Tutorial 1 - Introduction</h1>\n",
    "\n",
    "<p>\n",
    "Submission process:\n",
    "</p>\n",
    "<ul>\n",
    "<li>Submission deadline is November 5, 14:00 CET (before the lecture) .</li>\n",
    "<li>Commit and push your solution as separate notebook files per subtask via git as <span style=\"font-family: monospace\">./tutorial/tutorial1/tutorial1_3.ipynb</span>. Please take care of the correct subfolder/filename since submission is denied otherwise.</li>\n",
    "<li>During the first lecture after the deadline we will discuss a sample solution in class.</li>\n",
    "<li>Afterwards, you have time until November 10, 16:00 CET (before the lecture) to submit a corrected version of your submission:</li>\n",
    "<ol>\n",
    "  <li>Rework your solution according to our discussion in class.</li>\n",
    "  <li>Commit and push the corrected version as a separate file per subtask via git as <span style=\"font-family: monospace\">./tutorial/tutorial1/tutorial1_3.ipynb</span>. Please take care of the correct filename since submission is denied otherwise.</li>\n",
    "</ol>\n",
    "</ul>\n",
    "\n",
    "<p>\n",
    "Remarks:\n",
    "</p>\n",
    "<ul>\n",
    "<li>Grading is done based on both versions of your submission.</li>\n",
    "<li>If the first submission is missing or contains major flaws a deduction of up to 50% of the achieved points will be applied</li>\n",
    "<li>A sample solution is provided after November 10, 16:00 CET eventually.</li>\n",
    "<li>Do NOT duplicate cells or change the type of cells, otherwise you might receive zero points for your submission</li>\n",
    "<li>\n",
    "Please use <a href=\"mailto:acn@net.cit.tum.de\">acn@net.cit.tum.de</a> for questions regarding lecture, tutorial, and project of ACN.\n",
    "</li>\n",
    "</ul>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "6f7c435b17e86ea6a72ffe9d89cf3ccd",
     "grade": false,
     "grade_id": "cell-cf1bf85852242b36",
     "locked": true,
     "points": 0,
     "schema_version": 3,
     "solution": false,
     "task": true
    }
   },
   "source": [
    "<div style=\"background-color:rgba(200, 100, 100, 0.33);\">\n",
    "    <p>This cell is used to verify the structure of the submission </p>\n",
    "    DO NOT DELETE OR CHANGE THIS CELL, otherwise the task will be graded with 0 points\n",
    "    </div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "fa0285c2d345f090114c75dd90c734cb",
     "grade": false,
     "grade_id": "cell-2ffff55b3cba9976",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<h3>Problem 3 Jupyter Introduction (0 credits)</h3>\n",
    "\n",
    "<p>\n",
    "    We will shortly introduce <a href=\"https://jupyter.org/\">Jupyter</a> and its functionality:\n",
    "Jupyter is an interactive programming interface running in your browser. \n",
    "We use the interactive Python interface.\n",
    "</p>\n",
    "\n",
    "<p>\n",
    "    This problem does not give any bonus credits and its purpose is to familiarize yourself with jupyter.\n",
    "</p>\n",
    "\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "3c5c83e55ae9c8633b9ed4f6b681162f",
     "grade": false,
     "grade_id": "cell-f66fca4ddc9a561c",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "<b>a) [0 credits]</b> Jupyter notebooks consist of cells with different types, e.g., code and markdown. Explain the differences between those two types and what they can be used for.\n",
    "</p>\n",
    "</div>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "051d9b6d81df0dc04f936209e6bd9eca",
     "grade": true,
     "grade_id": "cell-f0c7c0cd3cb9a463",
     "locked": false,
     "points": 0,
     "schema_version": 3,
     "solution": true,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "YOUR ANSWER HERE"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "bfae533eefbcf9403fcf13c6fedce354",
     "grade": false,
     "grade_id": "cell-a8b8ba3f1d346476",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "To run cells (run Python code or show layouted markdown) either press the \"Play/Run\" button on top of the page or press Shift+Enter.\n",
    "</p>\n",
    "</div>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "b6d5f5745ee222a81e14f615a5c1f6b3",
     "grade": false,
     "grade_id": "cell-e1dd3b94ed739fed",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(217, 81, 23, 0.33);\">\n",
    "<p>\n",
    "Code type cells fail to execute when the content is not valid Python code. We use automated tests to validate your exercises. If your solution fails to execute due to syntax errors, the automated test will also fail. <b>Such hand-ins will be graded with 0 credits.</b> Therefore, always execute your solution at least once <b>on the provided virtual machine</b>. This way you can make sure the provided solution works in our environment.\n",
    "\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "dfdfce04dd9d835a1bde77b01f9eb5e6",
     "grade": false,
     "grade_id": "cell-2d2929b4d292a6ae",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>    \n",
    "<b>b) [0 credits]</b> The following cell contains the typical format for programming exercises. This function is used to test your solution. <b>Never change anything outside</b> the <i>begin/end insert code</i> comments and <b>only insert code in between</b>:\n",
    "<pre>#begin insert code\n",
    "...\n",
    "\n",
    "#YOUR CODE HERE\n",
    "raise NotImplementedError()\n",
    "...\n",
    "#end insert code\n",
    "</pre> \n",
    "The <span style=\"font-family: monospace\">print</span> command will show your result in the cell output. \n",
    "</p>\n",
    "\n",
    "<p>\n",
    "Errors should never occur in your handed-in notebook.\n",
    "Fix this code by defining the <span style=\"font-family: monospace\">hello_world</span> variable, assigning it a value, and returning it.\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "fcf52ec841dfb99b9ed49e6012e9226f",
     "grade": true,
     "grade_id": "cell-0ef64a84b689c23e",
     "locked": false,
     "points": 0,
     "schema_version": 3,
     "solution": true,
     "task": false
    }
   },
   "outputs": [],
   "source": [
    "def hello_world_text():\n",
    "    #begin insert code\n",
    "    # YOUR CODE HERE\n",
    "    raise NotImplementedError()\n",
    "    #end insert code\n",
    "    return None\n",
    "\n",
    "print(hello_world_text())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "98880ecdeb105a129e1dd46ac0352aed",
     "grade": false,
     "grade_id": "cell-cfa72e6debe432d9",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "<b>d) [0 credits]</b> Code cells also allow to execute shell commands. These are executed as the user who started the jupyter server. \n",
    "    On your virtual machine this is <span style=\"font-family: monospace\">root</span>.\n",
    "    Shell commands can be executed by prefixing them with the '!' character.\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "7e54b4f271b7e2e4a55a7bac119a8ad7",
     "grade": false,
     "grade_id": "cell-4007ef4cc1ff5888",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "outputs": [],
   "source": [
    "# just execute this cell\n",
    "!pwd  # the path where jupyter has been started\n",
    "!echo This user is executing the commands: $USER\n",
    "!ping -c 1 net.in.tum.de"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "9ce59d5f795c1c9af5e27258fd160ef4",
     "grade": false,
     "grade_id": "cell-53fc3a75b1451b26",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "<b>e) [0 credits]</b>\n",
    "In some exercise sheets we will use such shell commands to install missing Python modules.\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "f923e23635010a5b70f4fcdf8c43a54a",
     "grade": false,
     "grade_id": "cell-7c60b1ced15dcade",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(217, 81, 23, 0.33);\">\n",
    "<p>\n",
    "    Note that Python 3.11 wants you to install packages in a virtual environment (venv) to not interfere with system-site packages.\n",
    "    You will be shown an error if you try to do so without any venv.\n",
    "    The tutorial image uses a venv with relevant packages preinstalled.\n",
    "    It runs the jupyter server inside this venv. \n",
    "    If you run the notebook locally we suggest to use a venv.\n",
    "    If you do not know how to setup a venv you can follow <a href=\"https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/\" target=\"_blank\">this tutorial</a>.\n",
    "    Make sure that your jupyter process is executed within the venv.\n",
    "</p>\n",
    "\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "e68ac738b059b775f278627497c806c3",
     "grade": false,
     "grade_id": "cell-20646714afb68b73",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "outputs": [],
   "source": [
    "!pip3 install matplotlib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "63678abac7eea00cea6dfd03f96101a2",
     "grade": false,
     "grade_id": "cell-022ca3978961dd03",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "In order to visualize measurement data tools such as <span style=\"font-family: monospace\">matplotlib</span> are very useful.\n",
    "Jupyter notebook supports inline presentation of <span style=\"font-family: monospace\">matplotlib</span> plots.\n",
    "This is a convenient way to visualize data.\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "e92531d87e97f44d864e68d64924cfe8",
     "grade": false,
     "grade_id": "cell-454f1cc87b2ee4e8",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "In this exercise you can see how matplotlib is used. Just execute the first cell. It should show you a histogram of datapoints following a normal distribution.\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "c815e27b0cfd73203b11dbee677a425a",
     "grade": false,
     "grade_id": "cell-cfbb6acec5b1bec7",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "outputs": [],
   "source": [
    "# This enables inline plots\n",
    "%matplotlib inline\n",
    "\n",
    "# Example taken from https://matplotlib.org/3.1.1/gallery/statistics/histogram_features.html\n",
    "\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# example data\n",
    "mu = 0  # mean of distribution\n",
    "sigma = 1  # standard deviation of distribution\n",
    "x = mu + sigma * np.random.randn(10000) # 10k data samples\n",
    "\n",
    "num_bins = 50\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "\n",
    "# the histogram of the data\n",
    "counts, bins, patches = ax.hist(x, num_bins)\n",
    "\n",
    "ax.set_xlabel('Value')\n",
    "ax.set_ylabel('Count')\n",
    "ax.set_title(r'Histogram of a normal distribution: $\\mu=0$, $\\sigma=1$')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "b465338236ccfcad92c19686eeef2fd0",
     "grade": false,
     "grade_id": "cell-00da4925951ec5ac",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    },
    "scrolled": false
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p>\n",
    "<b>f) [0 credits]</b>\n",
    "Use the data from the previous cell to produce a CDF.\n",
    "(<a href=\"https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html\">This</a> and <a href=\"https://en.wikipedia.org/wiki/Cumulative_distribution_function\">this</a> might help you)\n",
    "</p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "deletable": false,
    "nbgrader": {
     "cell_type": "code",
     "checksum": "08c04fafd40e7b077af5a2dfaf7157d9",
     "grade": true,
     "grade_id": "cell-754e8eff7810989e",
     "locked": false,
     "points": 0,
     "schema_version": 3,
     "solution": true,
     "task": false
    }
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "\n",
    "# begin insert code\n",
    "# YOUR CODE HERE\n",
    "raise NotImplementedError()\n",
    "# end insert code\n",
    "\n",
    "ax.set_xlabel('Value')\n",
    "ax.set_ylabel('Cumulated Probability')\n",
    "ax.set_title(r'CDF of normal distribution: $\\mu=0$, $\\sigma=1$')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": false,
    "editable": false,
    "nbgrader": {
     "cell_type": "markdown",
     "checksum": "98175e258e37ad6f23951e183434b81f",
     "grade": false,
     "grade_id": "cell-9d0b2555f8ed32c3",
     "locked": true,
     "schema_version": 3,
     "solution": false,
     "task": false
    }
   },
   "source": [
    "<div style=\"background-color:rgba(100, 160, 200, 0.33);\">\n",
    "<p><b>Advanced Computer Networking by Prof. Dr.-Ing. Georg Carle</b></p>\n",
    "Teaching assistants: Christian Dietze, Sebastian Gallenmüller, Marcel Kempf, Lorenz Lehle, Patrick Dirks, Oliver Dürer\n",
    "</div>"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
