Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
acb5923
first commit
cripson1994 Sep 18, 2018
3294ae4
add ignore
cripson1994 Sep 18, 2018
68c91ee
simple client and server
cripson1994 Dec 10, 2018
d180a5b
fix data holder
cripson1994 Dec 10, 2018
82f0501
change server structure
cripson1994 Dec 11, 2018
fbc5d6f
add update command
cripson1994 Dec 11, 2018
f1f3943
add server request processing
cripson1994 Dec 11, 2018
3c28b89
server can send responce
cripson1994 Dec 12, 2018
abc5df9
writer minor fix
cripson1994 Dec 12, 2018
ab0bcc1
slightly extend client
cripson1994 Dec 12, 2018
ab198f9
compleat client cli
cripson1994 Dec 12, 2018
e2619b1
minor fix
cripson1994 Dec 12, 2018
a8f9ef9
saving server intermediate data
cripson1994 Dec 12, 2018
af79aea
split client to seeder and leech
cripson1994 Dec 13, 2018
732fd88
implement simple leech
cripson1994 Dec 13, 2018
e158891
server jar
cripson1994 Dec 13, 2018
8ca9dc5
fix server jar
cripson1994 Dec 13, 2018
4cd2eb2
fix server jar 2
cripson1994 Dec 13, 2018
b00bc9b
add MetaDataManager
cripson1994 Dec 13, 2018
657bc01
connected leech and seed
cripson1994 Dec 15, 2018
d81a50f
fix command source
cripson1994 Dec 15, 2018
8ced43f
client jar
cripson1994 Dec 15, 2018
3b037da
catch chanel closing
cripson1994 Dec 15, 2018
adacc9b
singleton reader
cripson1994 Dec 16, 2018
d83e80f
minor fix
cripson1994 Dec 16, 2018
6780a34
limited the number of leech tasks
cripson1994 Dec 16, 2018
2c4b5f0
remove debug logs
cripson1994 Dec 16, 2018
37da8cf
complet ha
cripson1994 Dec 16, 2018
1011e93
readme
cripson1994 Dec 16, 2018
f2f8751
minor fix
cripson1994 Mar 16, 2019
127383d
Update README.md
cripson1994 Mar 16, 2019
6e0c521
Merge commit '86189d8ef716a08559da4b341e101ec41a61855b' into task2
cripson1994 Mar 16, 2019
1d331a6
Merge branch 'task2' of https://github.com/cripson1994/NetworksLab201…
cripson1994 Mar 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 149 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,149 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
# Created by https://www.gitignore.io/api/java,macos,gradle,intellij

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
.idea/sonarlint

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Gradle ###
.gradle
/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache

# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties


# End of https://www.gitignore.io/api/java,macos,gradle,intellij
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# NetworksLab2017
### Сервер
```sh
java -jar server/build/libs/TorrentServer-1.0-SNAPSHOT.jar <server host>
```

### Клиент
```sh
java -jar client/build/libs/TorrentClient-1.0-SNAPSHOT.jar <tracker host> <working directory>
```

### Torrent
* На трекере хранится список файлов и информация об активных пользователях, у которых есть те или иные файлы (возможно не целиком).
* С помощью клиентского приложения можно просматривать список файлов на трекере, а также добавлять новые и выбирать файлы из списка для скачивания.
* Файлы условно разбиваются на последовательные блоки бинарных данных константного размера (10Mб)
* Клиент при подключении отправляет на трекер список раздаваемых им файлов.
* При скачивании файла клиент получает у трекера информацию о клиентах, раздающих файл (сидах), и далее общается с ними напрямую.
* У отдельного сида можно узнать о том, какие полные части у него есть, а также скачать их.
* После скачивания отдельных блоков некоторого файла клиент становится сидом.

### Torrent-tracker
* Хранит мета-информацию о раздаваемых файлах:
* идентификатор
* активные клиенты (недавно был update), у которых есть этот файл целиком или некоторые его части
* Порт сервера: 8081
* Запросы:
* list — список раздаваемых файлов
* upload — публикация нового файла
* sources — список клиентов, владеющих определенным файлов целиком или некоторыми его частями
* update — загрузка клиентом данных о раздаваемых файлах

#### List
Формат запроса: <1: Byte> Формат ответа: <count: Int> (<id: Int> <name: String> <size: Long>)*, count — количество файлов id — идентификатор файла name — название файла size — размер файла

#### Upload
Формат запроса: <2: Byte> <name: String> <size: Long>, name — название файла size — размер файла Формат ответа: <id: Int>, id — идентификатор файла

#### Sources
Формат запроса: <3: Byte> <id: Int>, id — идентификатор файла Формат ответа: <size: Int> (<ip: ByteByteByteByte> <clientPort: Short>)*, size — количество клиентов, раздающих файл ip — ip клиента

#### Update
Формат запроса: <4: Byte> <clientPort: Short> <count: Int> (<id: Int>)*, clientPort — порт клиента, count — количество раздаваемых файлов, id — идентификатор файла Формат ответа: <status: Boolean>, status — True, если информация успешно обновлена

Клиент обязан исполнять данный запрос каждые 5 минут, иначе сервер считает, что клиент ушел с раздачи

### Torrent-client
* Порт клиента указывается при запуске и передается на трекер в рамках запроса update
* Каждый файл раздается по частям, размер части — константа на всё приложение
* Клиент хранит и раздает эти самые части
* Запросы:
* stat — доступные для раздачи части определенного файла
* get — скачивание части определенного файла

#### Stat
Формат запроса: <1: Byte> <id: Int>, id — идентификатор файла Формат ответа: <count: Int> (<part: Int>)*, count — количество доступных частей part — номер части

#### Get
Формат запроса: <2: Byte> <id: Int> <part: Int> id — идентификатор файла, part — номер части Формат ответа: <content: Bytes>
28 changes: 28 additions & 0 deletions client/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
plugins {
id 'java'
}

group 'itmo2018.se'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
mavenCentral()
}

jar {
manifest {
attributes 'Main-Class': 'itmo2018.se.ClientMain'
}

from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.commons', name: 'commons-io', version: '1.3.2'
compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.2'
}
Binary file added client/build/libs/TorrentClient-1.0-SNAPSHOT.jar
Binary file not shown.
Binary file added client/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions client/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading