Added a test for pushing a Mac Management Message.

This commit is contained in:
feyris-tan 2025-05-24 10:58:50 +02:00
parent daa4ee87d4
commit 92364dbb03
8 changed files with 142 additions and 43 deletions

View File

@ -0,0 +1,40 @@
using skyscraper5.Docsis;
using skyscraper5.Docsis.MacManagement;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Tests.ClassDependencies.DocsisTests
{
internal class DocsisEventHandlerImpl : IDocsisEventHandler
{
public void OnCmtsTimestamp(PhysicalAddress source, uint timing)
{
throw new NotImplementedException();
}
public void OnDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel)
{
throw new NotImplementedException();
}
public void OnLearnedIpFromMac(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress)
{
throw new NotImplementedException();
}
public void OnParticipantDetected(PhysicalAddress pa)
{
throw new NotImplementedException();
}
public void OnUpstreamChannel(UpstreamChannelDescriptor mmm)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,12 +1,15 @@
using skyscraper5;
using skyscraper5.Docsis;
using skyscraper5.Docsis.AnnexC;
using skyscraper5.Docsis.MacManagement;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.Skyscraper.IO;
using skyscraper8.Tests.ClassDependencies.DocsisTests;
using skyscraper8.Tests.Properties;
using System;
using System.Collections.Generic;
@ -21,46 +24,6 @@ namespace skyscraper8.Tests
{
public class DocsisTests
{
[Fact]
public void TestLongBoiSingleStreams()
{
DirectoryInfo di = new DirectoryInfo("D:\\DocsisDemo");
Skip.If(!di.Exists, "Files not available.");
FilesystemScraperStorageFactory storageFactory = new FilesystemScraperStorageFactory();
storageFactory.Directory = "docsis_longboi";
Passing passing = new Passing();
passing.ScraperStorage = storageFactory.CreateScraperStroage();
passing.MassImportDirectory(di);
}
[Fact]
public void TestM3u8Stream()
{
FileInfo docsisM3u8 = new FileInfo("D:\\DocsisDemo\\docsis.m3u8");
Skip.If(!docsisM3u8.Exists, "Index file not available.");
FileInfo alreadyTested = new FileInfo("docsis_m3u8_test.complete");
if (alreadyTested.Exists)
{
Debug.WriteLine("Hello!");
return;
}
M3U8Stream m3u8 = new M3U8Stream(docsisM3u8.FullName);
TsContext tsContext = new TsContext();
InMemoryScraperStorageFactory storageFactory = new InMemoryScraperStorageFactory();
IScraperStroage scraperStorage = storageFactory.CreateScraperStroage();
SkyscraperContext skyscraperContext = new SkyscraperContext(tsContext, null, scraperStorage);
skyscraperContext.InitalizeFilterChain();
skyscraperContext.IngestFromStream(m3u8);
File.WriteAllText("docsis_m3u8_test.complete", "1");
}
[Fact]
public void AAA_ModemCapabilitiesEncodingTest()
{
@ -88,5 +51,25 @@ namespace skyscraper8.Tests
T45_V4_MultipartRegistrationResponse test = new T45_V4_MultipartRegistrationResponse(source, target, buffer);
Assert.True(test.Valid);
}
[Fact]
public void AAC_MacManagement_4_45()
{
DocsisEventHandlerImpl docsisEventHandler = new DocsisEventHandlerImpl();
DocsisEnvironment environment = new DocsisEnvironment(docsisEventHandler);
byte[] testPayload = Resources.PushMacManagementMessage_Version4_Type45;
Random rng = new Random();
byte[] sourceBuffer = new byte[6];
rng.NextBytes(sourceBuffer);
PhysicalAddress source = new PhysicalAddress(sourceBuffer);
byte[] targetBuffer = new byte[6];
rng.NextBytes(targetBuffer);
PhysicalAddress target = new PhysicalAddress(targetBuffer);
environment.PushMacManagementMessage(testPayload, 4, 45, source, target, testPayload);
}
}
}

View File

@ -0,0 +1,60 @@
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5;
using skyscraper8.Skyscraper.IO;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace skyscraper8.Tests
{
public class DocsisTestsLong
{
[Fact]
public void TestLongBoiSingleStreams()
{
DirectoryInfo di = new DirectoryInfo("D:\\DocsisDemo");
Skip.If(!di.Exists, "Files not available.");
FilesystemScraperStorageFactory storageFactory = new FilesystemScraperStorageFactory();
storageFactory.Directory = "docsis_longboi";
Passing passing = new Passing();
passing.ScraperStorage = storageFactory.CreateScraperStroage();
passing.MassImportDirectory(di);
}
[Fact]
public void TestM3u8Stream()
{
FileInfo docsisM3u8 = new FileInfo("D:\\DocsisDemo\\docsis.m3u8");
Skip.If(!docsisM3u8.Exists, "Index file not available.");
FileInfo alreadyTested = new FileInfo("docsis_m3u8_test.complete");
if (alreadyTested.Exists)
{
Debug.WriteLine("Hello!");
return;
}
M3U8Stream m3u8 = new M3U8Stream(docsisM3u8.FullName);
TsContext tsContext = new TsContext();
InMemoryScraperStorageFactory storageFactory = new InMemoryScraperStorageFactory();
IScraperStroage scraperStorage = storageFactory.CreateScraperStroage();
SkyscraperContext skyscraperContext = new SkyscraperContext(tsContext, null, scraperStorage);
skyscraperContext.InitalizeFilterChain();
skyscraperContext.IngestFromStream(m3u8);
File.WriteAllText("docsis_m3u8_test.complete", "1");
}
}
}

View File

@ -80,6 +80,16 @@ namespace skyscraper8.Tests.Properties {
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
/// </summary>
internal static byte[] PushMacManagementMessage_Version4_Type45 {
get {
object obj = ResourceManager.GetObject("PushMacManagementMessage_Version4_Type45", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
/// </summary>

View File

@ -124,6 +124,9 @@
<data name="MultipartRegistrationResponseTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\T45_V4_MultipartRegistrationResponseTest.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="PushMacManagementMessage_Version4_Type45" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PushMacManagementMessage_Version4_Type45.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="ranging_response_test" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ranging_response_test.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>

View File

@ -28,7 +28,7 @@ namespace skyscraper5.Docsis
{
private readonly IDocsisEventHandler eventHandler;
internal DocsisEnvironment(IDocsisEventHandler eventHandler)
public DocsisEnvironment(IDocsisEventHandler eventHandler)
{
this.eventHandler = eventHandler;
this._stats = new Statistics();
@ -276,7 +276,7 @@ namespace skyscraper5.Docsis
private ReadOnlyDictionary<MacManagementMessageTypeAttribute, Type> _macManagementMessageTypes;
private void PushMacManagementMessage(byte[] ms, byte version, byte type, PhysicalAddress sourceAddress, PhysicalAddress destinationAddress, byte[] readBytes)
public void PushMacManagementMessage(byte[] ms, byte version, byte type, PhysicalAddress sourceAddress, PhysicalAddress destinationAddress, byte[] readBytes)
{
if (_macManagementMessageTypes == null)
@ -367,6 +367,9 @@ namespace skyscraper5.Docsis
case nameof(DynamicServiceDeletionResponse):
//nothing in there
break;
case nameof(T45_V4_MultipartRegistrationResponse):
//doesn't look interesting either
break;
default:
throw new NotImplementedException();
}

View File

@ -9,7 +9,7 @@ using skyscraper5.Docsis.MacManagement;
namespace skyscraper5.Docsis
{
internal interface IDocsisEventHandler
public interface IDocsisEventHandler
{
void OnParticipantDetected(PhysicalAddress pa);
void OnCmtsTimestamp(PhysicalAddress source, uint timing);